Browse Source

Fix for fix #1475, #1476.

cl-refactor
subtly 10 years ago
parent
commit
da63cac309
  1. 2
      libp2p/Host.cpp
  2. 6
      test/peer.cpp

2
libp2p/Host.cpp

@ -703,7 +703,7 @@ bytes Host::saveNetwork() const
if (chrono::system_clock::now() - p.m_lastConnected < chrono::seconds(3600 * 48) && endpoint.port() > 0 && endpoint.port() < /*49152*/32768 && p.id != id() && !isPrivateAddress(p.endpoint.udp.address()) && !isPrivateAddress(endpoint.address()))
{
network.appendList(10);
network << endpoint.port() << p.id << p.required
network << endpoint.address().to_v4().to_bytes() << endpoint.port() << p.id << p.required
<< chrono::duration_cast<chrono::seconds>(p.m_lastConnected.time_since_epoch()).count()
<< chrono::duration_cast<chrono::seconds>(p.m_lastAttempted.time_since_epoch()).count()
<< p.m_failedAttempts << (unsigned)p.m_lastDisconnect << p.m_score << p.m_rating;

6
test/peer.cpp

@ -102,6 +102,12 @@ BOOST_AUTO_TEST_CASE(save_nodes)
BOOST_REQUIRE(r[0].toInt<unsigned>() == dev::p2p::c_protocolVersion);
BOOST_REQUIRE_EQUAL(r[1].toBytes().size(), 32); // secret
BOOST_REQUIRE_EQUAL(r[2].itemCount(), 5);
for (auto i: r[2])
{
BOOST_REQUIRE(i.itemCount() == 3 || i.itemCount() == 10);
BOOST_REQUIRE(i[0].itemCount() == 4 || i[0].itemCount() == 16);
}
}
BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save