This repository was archived by the owner on Oct 28, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -481,21 +481,29 @@ void NodeTable::onPacketReceived(
481481 }
482482
483483 auto const & pong = dynamic_cast <Pong const &>(*packet);
484- if (pong.echo != sentPing->second .pingHash )
484+ auto const & nodeValidation = sentPing->second ;
485+ if (pong.echo != nodeValidation.pingHash )
485486 {
486487 LOG (m_logger) << " Invalid PONG from " << _from.address ().to_string () << " :"
487488 << _from.port ();
488489 return ;
489490 }
490491
492+ // in case the node answers with new NodeID, drop the record with the old NodeID
493+ auto const & sourceId = pong.sourceid ;
494+ if (sourceId != nodeValidation.nodeID )
495+ {
496+ if (auto node = nodeEntry (nodeValidation.nodeID ))
497+ dropNode (move (node));
498+ }
499+
491500 // create or update nodeEntry with new Pong received time
492501 DEV_GUARDED (x_nodes)
493502 {
494- auto const & sourceId = pong.sourceid ;
495503 auto it = m_allNodes.find (sourceId);
496504 if (it == m_allNodes.end ())
497505 sourceNodeEntry = make_shared<NodeEntry>(m_hostNodeID, sourceId,
498- NodeIPEndpoint{_from.address (), _from.port (), sentPing-> second .tcpPort },
506+ NodeIPEndpoint{_from.address (), _from.port (), nodeValidation .tcpPort },
499507 RLPXDatagramFace::secondsSinceEpoch (), 0 );
500508 else
501509 {
You can’t perform that action at this time.
0 commit comments