Browse Source

Merge pull request #1276 from ethereum/p2p

p2p: fixes
cl-refactor
Gav Wood 10 years ago
parent
commit
11b6fb507c
  1. 3
      libdevcrypto/CryptoPP.cpp
  2. 1
      libethereum/Client.h
  3. 16
      libp2p/Host.cpp
  4. 1
      test/peer.cpp

3
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)); assert(d.AgreedValueLength() == sizeof(o_s));
byte remote[65] = {0x04}; byte remote[65] = {0x04};
memcpy(&remote[1], _r.data(), 64); memcpy(&remote[1], _r.data(), 64);
bool result = d.Agree(o_s.data(), _s.data(), remote); d.Agree(o_s.data(), _s.data(), remote);
assert(result);
} }
void Secp256k1::exportPublicKey(CryptoPP::DL_PublicKey_EC<CryptoPP::ECP> const& _k, Public& o_p) void Secp256k1::exportPublicKey(CryptoPP::DL_PublicKey_EC<CryptoPP::ECP> const& _k, Public& o_p)

1
libethereum/Client.h

@ -46,7 +46,6 @@
namespace dev namespace dev
{ {
namespace eth namespace eth
{ {

16
libp2p/Host.cpp

@ -550,15 +550,23 @@ void Host::run(boost::system::error_code const&)
// is always live and to ensure reputation and fallback timers are properly // is always live and to ensure reputation and fallback timers are properly
// updated. // disconnectLatePeers(); // updated. // disconnectLatePeers();
if (peerCount() < m_idealPeerCount) auto openSlots = m_idealPeerCount - peerCount();
if (openSlots > 0)
{
list<shared_ptr<Peer>> toConnect;
{ {
RecursiveGuard l(x_sessions);
for (auto p: m_peers) for (auto p: m_peers)
if (p.second->shouldReconnect()) if (p.second->shouldReconnect())
{ toConnect.push_back(p.second);
connect(p.second);
break;
} }
for (auto p: toConnect)
if (openSlots--)
connect(p);
else
break;
m_nodeTable->discover(); m_nodeTable->discover();
} }

1
test/peer.cpp

@ -63,6 +63,7 @@ BOOST_AUTO_TEST_CASE(save_nodes)
for (auto i:{0,1,2,3,4,5}) for (auto i:{0,1,2,3,4,5})
{ {
Host* h = new Host("Test", NetworkPreferences(30300 + i, "127.0.0.1", true, true)); 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 // starting host is required so listenport is available
h->start(); h->start();
while (!h->isStarted()) while (!h->isStarted())

Loading…
Cancel
Save