diff --git a/libdevcrypto/CryptoPP.cpp b/libdevcrypto/CryptoPP.cpp index 11e4c1472..79fd62262 100644 --- a/libdevcrypto/CryptoPP.cpp +++ b/libdevcrypto/CryptoPP.cpp @@ -319,8 +319,7 @@ void Secp256k1::agree(Secret const& _s, Public const& _r, h256& o_s) assert(d.AgreedValueLength() == sizeof(o_s)); byte remote[65] = {0x04}; memcpy(&remote[1], _r.data(), 64); - bool result = d.Agree(o_s.data(), _s.data(), remote); - assert(result); + d.Agree(o_s.data(), _s.data(), remote); } void Secp256k1::exportPublicKey(CryptoPP::DL_PublicKey_EC const& _k, Public& o_p) diff --git a/libethereum/Client.h b/libethereum/Client.h index 9cbfd7989..2c8db2aed 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -46,7 +46,6 @@ namespace dev { - namespace eth { diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 8f4f8a69d..19df5ee2e 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -550,14 +550,22 @@ void Host::run(boost::system::error_code const&) // is always live and to ensure reputation and fallback timers are properly // updated. // disconnectLatePeers(); - if (peerCount() < m_idealPeerCount) + auto openSlots = m_idealPeerCount - peerCount(); + if (openSlots > 0) { - for (auto p: m_peers) - if (p.second->shouldReconnect()) - { - connect(p.second); + list> toConnect; + { + RecursiveGuard l(x_sessions); + for (auto p: m_peers) + if (p.second->shouldReconnect()) + toConnect.push_back(p.second); + } + + for (auto p: toConnect) + if (openSlots--) + connect(p); + else break; - } m_nodeTable->discover(); } diff --git a/test/peer.cpp b/test/peer.cpp index 0fe3fd1ed..14712d4f1 100644 --- a/test/peer.cpp +++ b/test/peer.cpp @@ -63,6 +63,7 @@ BOOST_AUTO_TEST_CASE(save_nodes) for (auto i:{0,1,2,3,4,5}) { Host* h = new Host("Test", NetworkPreferences(30300 + i, "127.0.0.1", true, true)); + h->setIdealPeerCount(10); // starting host is required so listenport is available h->start(); while (!h->isStarted())