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)