Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit 7dc369f

Browse files
committed
Update host ENR when receiving Pong with new endpoint in destination
1 parent 351a38d commit 7dc369f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

libp2p/NodeTable.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,19 @@ shared_ptr<NodeEntry> NodeTable::handlePong(
544544
isPublicAddress(pong.destination.address()))
545545
m_hostNodeEndpoint.setAddress(pong.destination.address());
546546
m_hostNodeEndpoint.setUdpPort(pong.destination.udpPort());
547+
548+
if (m_hostENRInfo.ip != m_hostNodeEndpoint.address() ||
549+
m_hostENRInfo.udpPort != pong.destination.udpPort())
550+
{
551+
{
552+
Guard l(m_hostENRMutex);
553+
m_hostENR =
554+
IdentitySchemeV4::updateENR(m_hostENR, m_secret, m_hostNodeEndpoint.address(),
555+
m_hostNodeEndpoint.tcpPort(), pong.destination.udpPort());
556+
m_hostENRInfo = IdentitySchemeV4::info(m_hostENR);
557+
}
558+
clog(VerbosityInfo, "net") << "ENR updated: " << m_hostENR;
559+
}
547560
}
548561

549562
return sourceNodeEntry;

0 commit comments

Comments
 (0)