@ -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<CryptoPP::ECP> const& _k, Public& o_p)
@ -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<shared_ptr<Peer>> toConnect;
RecursiveGuard l(x_sessions);
toConnect.push_back(p.second);
for (auto p: toConnect)
if (openSlots--)
connect(p);
else
break;
m_nodeTable->discover();
@ -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())