pub struct LocalAddress {
address: AddrV2,
last_connected: u64,
state: AddressState,
services: ServiceFlags,
port: u16,
pub id: usize,
}Expand description
How do we store peers locally
Fields§
§address: AddrV2An actual address
last_connected: u64Last time we successfully connected to this peer, only relevant is state == State::Tried
state: AddressStateOur local state for this peer, as defined in AddressState
services: ServiceFlagsNetwork services announced by this peer
port: u16Network port this peers listens to
id: usizeRandom id for this peer
Implementations§
Source§impl LocalAddress
impl LocalAddress
pub fn new( address: AddrV2, last_connected: u64, state: AddressState, services: ServiceFlags, port: u16, id: usize, ) -> LocalAddress
Sourcepub fn get_addrv2(&self) -> AddrV2
pub fn get_addrv2(&self) -> AddrV2
Get the [AddrV2] for this LocalAddress.
Sourcepub fn get_socket_address(&self) -> SocketAddr
pub fn get_socket_address(&self) -> SocketAddr
Get the SocketAddr for this LocalAddress.
Sourcepub fn get_port(&self) -> u16
pub fn get_port(&self) -> u16
Get the port for this LocalAddress.
Sourcepub fn set_port(&mut self, port: u16)
pub fn set_port(&mut self, port: u16)
Set the port for this LocalAddress.
Sourcepub fn get_services(&self) -> ServiceFlags
pub fn get_services(&self) -> ServiceFlags
Get the [ServiceFlags] for this LocalAddress.
Sourcepub fn set_services(&mut self, services: ServiceFlags)
pub fn set_services(&mut self, services: ServiceFlags)
Set the [ServiceFlags] for this LocalAddress.
Sourcepub fn get_net_address(&self) -> IpAddr
pub fn get_net_address(&self) -> IpAddr
Get the IpAddr for with this LocalAddress.
Sourceconst fn is_routable(&self) -> bool
const fn is_routable(&self) -> bool
Return whether the address can be reached from our node
Some addresses are not reachable from the global internet, those includes documentation, reserved and private ones ranges. Since we can’t connect with them, there’s no point into keeping them
Sourceconst fn is_routable_ipv4(ip: &Ipv4Addr) -> bool
const fn is_routable_ipv4(ip: &Ipv4Addr) -> bool
Returns whether an ipv4 address is publicly routable
Sourceconst fn is_routable_ipv6(ip: &Ipv6Addr) -> bool
const fn is_routable_ipv6(ip: &Ipv6Addr) -> bool
Returns whether an ipv6 address is publicly routable
Sourcepub fn is_good_address(&self) -> bool
pub fn is_good_address(&self) -> bool
Return whether an address is good to connect to
Trait Implementations§
Source§impl Clone for LocalAddress
impl Clone for LocalAddress
Source§fn clone(&self) -> LocalAddress
fn clone(&self) -> LocalAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more