Browse Source

codingstandards

cl-refactor
subtly 10 years ago
parent
commit
8cc7fb94ba
  1. 4
      libp2p/Host.cpp
  2. 2
      libp2p/NodeTable.cpp
  3. 2
      libp2p/NodeTable.h
  4. 2
      test/peer.cpp

4
libp2p/Host.cpp

@ -709,7 +709,7 @@ bytes Host::saveNetwork() const
} }
RLPStream ret(3); RLPStream ret(3);
ret << NodeTable::s_version << m_alias.secret(); ret << NodeTable::c_version << m_alias.secret();
ret.appendList(count).appendRaw(network.out(), count); ret.appendList(count).appendRaw(network.out(), count);
return ret.out(); return ret.out();
} }
@ -722,7 +722,7 @@ void Host::restoreNetwork(bytesConstRef _b)
RecursiveGuard l(x_sessions); RecursiveGuard l(x_sessions);
RLP r(_b); RLP r(_b);
if (r.itemCount() > 0 && r[0].isInt() && r[0].toInt<int>() == NodeTable::s_version) if (r.itemCount() > 0 && r[0].isInt() && r[0].toInt<int>() == NodeTable::c_version)
{ {
// r[0] = version // r[0] = version
// r[1] = key // r[1] = key

2
libp2p/NodeTable.cpp

@ -477,7 +477,7 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes
case PingNode::type: case PingNode::type:
{ {
PingNode in = PingNode::fromBytesConstRef(_from, rlpBytes); PingNode in = PingNode::fromBytesConstRef(_from, rlpBytes);
if (in.version != s_version) if (in.version != c_version)
{ {
if (auto n = nodeEntry(nodeid)) if (auto n = nodeEntry(nodeid))
dropNode(n); dropNode(n);

2
libp2p/NodeTable.h

@ -136,7 +136,7 @@ class NodeTable: UDPSocketEvents, public std::enable_shared_from_this<NodeTable>
public: public:
/// Version of Discovery protocol /// Version of Discovery protocol
static unsigned const s_version = 2; static unsigned const c_version = 2;
/// Constructor requiring host for I/O, credentials, and IP Address,port to listen on. /// Constructor requiring host for I/O, credentials, and IP Address,port to listen on.
NodeTable(ba::io_service& _io, KeyPair _alias, uint16_t _udpPort = 30303); NodeTable(ba::io_service& _io, KeyPair _alias, uint16_t _udpPort = 30303);

2
test/peer.cpp

@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(save_nodes)
RLP r(firstHostNetwork); RLP r(firstHostNetwork);
BOOST_REQUIRE(r.itemCount() == 3); BOOST_REQUIRE(r.itemCount() == 3);
BOOST_REQUIRE(r[0].toInt<int>() == NodeTable::s_version); BOOST_REQUIRE(r[0].toInt<int>() == NodeTable::c_version);
BOOST_REQUIRE_EQUAL(r[1].toBytes().size(), 32); // secret BOOST_REQUIRE_EQUAL(r[1].toBytes().size(), 32); // secret
BOOST_REQUIRE_EQUAL(r[2].itemCount(), 5); BOOST_REQUIRE_EQUAL(r[2].itemCount(), 5);
} }

Loading…
Cancel
Save