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

Commit

Permalink
Update host ENR when receiving Pong with new endpoint in destination
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed May 15, 2019
1 parent 351a38d commit 7dc369f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libp2p/NodeTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,19 @@ shared_ptr<NodeEntry> NodeTable::handlePong(
isPublicAddress(pong.destination.address()))
m_hostNodeEndpoint.setAddress(pong.destination.address());
m_hostNodeEndpoint.setUdpPort(pong.destination.udpPort());

if (m_hostENRInfo.ip != m_hostNodeEndpoint.address() ||
m_hostENRInfo.udpPort != pong.destination.udpPort())
{
{
Guard l(m_hostENRMutex);
m_hostENR =
IdentitySchemeV4::updateENR(m_hostENR, m_secret, m_hostNodeEndpoint.address(),
m_hostNodeEndpoint.tcpPort(), pong.destination.udpPort());
m_hostENRInfo = IdentitySchemeV4::info(m_hostENR);
}
clog(VerbosityInfo, "net") << "ENR updated: " << m_hostENR;
}
}

return sourceNodeEntry;
Expand Down

0 comments on commit 7dc369f

Please sign in to comment.