Browse Source

add version to packet payload

cl-refactor
subtly 10 years ago
parent
commit
74335368ff
  1. 2
      libp2p/Host.cpp
  2. 4
      libp2p/NodeTable.h
  3. 2
      libp2p/RLPxHandshake.cpp

2
libp2p/Host.cpp

@ -560,7 +560,7 @@ void Host::run(boost::system::error_code const&)
{ {
RecursiveGuard l(x_sessions); RecursiveGuard l(x_sessions);
for (auto p: m_peers) for (auto p: m_peers)
if (p.second->shouldReconnect()) if (p.second->shouldReconnect() && !havePeerSession(p.second->id))
toConnect.push_back(p.second); toConnect.push_back(p.second);
} }

4
libp2p/NodeTable.h

@ -321,8 +321,8 @@ struct PingNode: RLPXDatagram<PingNode>
unsigned port; unsigned port;
unsigned expiration; unsigned expiration;
void streamRLP(RLPStream& _s) const { _s.appendList(3); _s << ipAddress << port << expiration; } void streamRLP(RLPStream& _s) const { _s.appendList(4); _s << dev::p2p::c_protocolVersion << ipAddress << port << expiration; }
void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); ipAddress = r[0].toString(); port = r[1].toInt<unsigned>(); expiration = r[2].toInt<unsigned>(); } void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); version = r[0].toInt<unsigned>(); ipAddress = r[1].toString(); port = r[2].toInt<unsigned>(); expiration = r[3].toInt<unsigned>(); }
}; };
/** /**

2
libp2p/RLPxHandshake.cpp

@ -252,7 +252,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
} }
clog(NetNote) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "hello frame: success. starting session."; clog(NetNote) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "hello frame: success. starting session.";
RLP rlp(frame.cropped(1)); RLP rlp(frame.cropped(1), RLP::ThrowOnFail | RLP::FailIfTooSmall);
m_host->startPeerSession(m_remote, rlp, m_io, m_socket->remoteEndpoint()); m_host->startPeerSession(m_remote, rlp, m_io, m_socket->remoteEndpoint());
} }
}); });

Loading…
Cancel
Save