Undo changes to eth2-libp2p/src

This commit is contained in:
Paul Hauner
2019-11-24 07:01:49 +11:00
parent 1c1d86b3ac
commit e94c265036
3 changed files with 62 additions and 1 deletions

View File

@@ -103,6 +103,24 @@ impl<TSubstream> Discovery<TSubstream> {
})
}
/// Allows the application layer to update the `ip` and `port` of the local ENR. The second
/// parameter defines whether the port is a TPC port. If false, this is interpreted as a UDP
/// port.
pub fn update_local_enr(&mut self, socket: std::net::SocketAddr, is_tcp: bool) {
// discv5 checks to see if an update is necessary before performing it, so we do not
// need to check here
if self.discovery.update_local_enr_socket(socket, is_tcp) {
let enr = self.discovery.local_enr();
info!(
self.log,
"ENR Updated";
"enr" => enr.to_base64(),
"seq" => enr.seq(),
"address" => format!("{:?}", socket));
}
}
/// Return the nodes local ENR.
pub fn local_enr(&self) -> &Enr {
self.discovery.local_enr()
}