mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Enables ENR auto-update based on new listen address (#610)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user