From 6cad687c3b42280a8a2f8ce50dba7e94a58650b2 Mon Sep 17 00:00:00 2001 From: subtly Date: Tue, 14 Apr 2015 17:47:00 -0400 Subject: [PATCH] Fix neighbours timeout to timeout-based on destination nodeid and not nodeid of the query. Update timeout to allow multiple packets. --- libp2p/NodeTable.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index 652aec745..447a7f3c9 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -178,7 +178,7 @@ void NodeTable::discover(NodeId _node, unsigned _round, shared_ptrendpoint.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)