Browse Source

Fix neighbours timeout to timeout-based on destination nodeid and not nodeid of the query. Update timeout to allow multiple packets.

cl-refactor
subtly 10 years ago
parent
commit
6cad687c3b
  1. 9
      libp2p/NodeTable.cpp

9
libp2p/NodeTable.cpp

@ -178,7 +178,7 @@ void NodeTable::discover(NodeId _node, unsigned _round, shared_ptr<set<shared_pt
tried.push_back(r);
FindNode p(r->endpoint.udp, _node);
p.sign(m_secret);
m_findNodeTimeout.push_back(make_pair(_node, chrono::steady_clock::now()));
m_findNodeTimeout.push_back(make_pair(r->id, chrono::steady_clock::now()));
m_socketPointer->send(p);
}
@ -459,11 +459,14 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes
case Neighbours::type:
{
bool expected = false;
auto now = chrono::steady_clock::now();
m_findNodeTimeout.remove_if([&](NodeIdTimePoint const& t)
{
if (t.first == nodeid && chrono::steady_clock::now() - t.second < c_reqTimeout)
if (t.first == nodeid && now - t.second < c_reqTimeout)
expected = true;
return t.first == nodeid;
else if (t.first == nodeid)
return true;
return false;
});
if (!expected)

Loading…
Cancel
Save