Struct reth_network_peers::Enr
pub struct Enr<K>where
K: EnrKey,{ /* private fields */ }
Expand description
The ENR, allowing for arbitrary signing algorithms.
This struct will always have a valid signature, known public key type, sequence number and NodeId
. All other parameters are variable/optional.
Implementations§
§impl<K> Enr<K>where
K: EnrKey,
impl<K> Enr<K>where
K: EnrKey,
pub fn builder() -> Builder<K>
pub fn builder() -> Builder<K>
Get a [builder::Builder
] with the default identity scheme.
pub const fn node_id(&self) -> NodeId
pub const fn node_id(&self) -> NodeId
The NodeId
for the record.
pub fn get(&self, key: impl AsRef<[u8]>) -> Option<Bytes>
👎Deprecated since 0.11.2: use get_decodable
pub fn get(&self, key: impl AsRef<[u8]>) -> Option<Bytes>
Reads a custom key from the record if it exists, decoded as data. Caution! Only use for
data that is not an aggregate type. Default to using get_decodable
.
pub fn get_decodable<T>(
&self,
key: impl AsRef<[u8]>,
) -> Option<Result<T, Error>>where
T: Decodable,
pub fn get_decodable<T>(
&self,
key: impl AsRef<[u8]>,
) -> Option<Result<T, Error>>where
T: Decodable,
Reads a custom key from the record if it exists, decoded as T
.
pub fn get_raw_rlp(&self, key: impl AsRef<[u8]>) -> Option<&[u8]>
pub fn get_raw_rlp(&self, key: impl AsRef<[u8]>) -> Option<&[u8]>
Reads a custom key from the record if it exists as raw RLP bytes.
pub fn iter(&self) -> impl Iterator<Item = (&Vec<u8>, &[u8])>
pub fn iter(&self) -> impl Iterator<Item = (&Vec<u8>, &[u8])>
Returns an iterator over all key/value pairs in the ENR.
pub fn client_info(&self) -> Option<(String, String, Option<String>)>
pub fn client_info(&self) -> Option<(String, String, Option<String>)>
Returns EIP-7636 entry if it is defined.
pub fn udp4_socket(&self) -> Option<SocketAddrV4>
pub fn udp4_socket(&self) -> Option<SocketAddrV4>
Provides a socket (based on the UDP port), if the IPv4 and UDP fields are specified.
pub fn udp6_socket(&self) -> Option<SocketAddrV6>
pub fn udp6_socket(&self) -> Option<SocketAddrV6>
Provides a socket (based on the UDP port), if the IPv6 and UDP fields are specified.
pub fn tcp4_socket(&self) -> Option<SocketAddrV4>
pub fn tcp4_socket(&self) -> Option<SocketAddrV4>
Provides a socket (based on the TCP port), if the IP and TCP fields are specified.
pub fn tcp6_socket(&self) -> Option<SocketAddrV6>
pub fn tcp6_socket(&self) -> Option<SocketAddrV6>
Provides a socket (based on the TCP port), if the IPv6 and TCP6 fields are specified.
pub fn public_key(&self) -> <K as EnrKey>::PublicKey
pub fn public_key(&self) -> <K as EnrKey>::PublicKey
pub fn compare_content(&self, other: &Enr<K>) -> bool
pub fn compare_content(&self, other: &Enr<K>) -> bool
Compare if the content of 2 Enr’s match.
pub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Provides the URL-safe base64 encoded “text” version of the ENR prefixed by “enr:”.
pub fn set_seq(&mut self, seq: u64, key: &K) -> Result<(), Error>
pub fn set_seq(&mut self, seq: u64, key: &K) -> Result<(), Error>
Allows setting the sequence number to an arbitrary value.
pub fn insert<T>(
&mut self,
key: impl AsRef<[u8]>,
value: &T,
enr_key: &K,
) -> Result<Option<Bytes>, Error>where
T: Encodable,
pub fn insert<T>(
&mut self,
key: impl AsRef<[u8]>,
value: &T,
enr_key: &K,
) -> Result<Option<Bytes>, Error>where
T: Encodable,
Adds or modifies a key/value to the ENR record. A EnrKey
is required to re-sign the record once
modified.
Returns the previous value as rlp encoded bytes in the record if it exists.
pub fn insert_raw_rlp(
&mut self,
key: impl AsRef<[u8]>,
value: Bytes,
enr_key: &K,
) -> Result<Option<Bytes>, Error>
pub fn insert_raw_rlp( &mut self, key: impl AsRef<[u8]>, value: Bytes, enr_key: &K, ) -> Result<Option<Bytes>, Error>
Adds or modifies a key/value to the ENR record. A EnrKey
is required to re-sign the record once
modified. The value here is interpreted as raw RLP data.
Returns the previous value as rlp encoded bytes in the record if it exists.
pub fn set_ip(&mut self, ip: IpAddr, key: &K) -> Result<Option<IpAddr>, Error>
pub fn set_ip(&mut self, ip: IpAddr, key: &K) -> Result<Option<IpAddr>, Error>
Sets the ip
field of the ENR. Returns any pre-existing IP address in the record.
pub fn set_udp4(&mut self, udp: u16, key: &K) -> Result<Option<u16>, Error>
pub fn set_udp4(&mut self, udp: u16, key: &K) -> Result<Option<u16>, Error>
Sets the udp
field of the ENR. Returns any pre-existing UDP port in the record.
pub fn set_udp6(&mut self, udp: u16, key: &K) -> Result<Option<u16>, Error>
pub fn set_udp6(&mut self, udp: u16, key: &K) -> Result<Option<u16>, Error>
Sets the udp6
field of the ENR. Returns any pre-existing UDP port in the record.
pub fn set_tcp4(&mut self, tcp: u16, key: &K) -> Result<Option<u16>, Error>
pub fn set_tcp4(&mut self, tcp: u16, key: &K) -> Result<Option<u16>, Error>
Sets the tcp
field of the ENR. Returns any pre-existing tcp port in the record.
pub fn set_tcp6(&mut self, tcp: u16, key: &K) -> Result<Option<u16>, Error>
pub fn set_tcp6(&mut self, tcp: u16, key: &K) -> Result<Option<u16>, Error>
Sets the tcp6
field of the ENR. Returns any pre-existing tcp6 port in the record.
pub fn set_client_info(
&mut self,
name: String,
version: String,
build: Option<String>,
key: &K,
) -> Result<(), Error>
pub fn set_client_info( &mut self, name: String, version: String, build: Option<String>, key: &K, ) -> Result<(), Error>
Sets the EIP-7636 client
field in the record.
pub fn set_udp_socket(
&mut self,
socket: SocketAddr,
key: &K,
) -> Result<(), Error>
pub fn set_udp_socket( &mut self, socket: SocketAddr, key: &K, ) -> Result<(), Error>
Sets the IP and UDP port in a single update with a single increment in sequence number.
pub fn set_tcp_socket(
&mut self,
socket: SocketAddr,
key: &K,
) -> Result<(), Error>
pub fn set_tcp_socket( &mut self, socket: SocketAddr, key: &K, ) -> Result<(), Error>
Sets the IP and TCP port in a single update with a single increment in sequence number.
pub fn remove_insert<'a>(
&mut self,
remove_keys: impl Iterator<Item = impl AsRef<[u8]>>,
insert_key_values: impl Iterator<Item = (impl AsRef<[u8]>, &'a [u8])>,
enr_key: &K,
) -> Result<(Vec<Option<Bytes>>, Vec<Option<Bytes>>), Error>
pub fn remove_insert<'a>( &mut self, remove_keys: impl Iterator<Item = impl AsRef<[u8]>>, insert_key_values: impl Iterator<Item = (impl AsRef<[u8]>, &'a [u8])>, enr_key: &K, ) -> Result<(Vec<Option<Bytes>>, Vec<Option<Bytes>>), Error>
Removes key/value mappings and adds or overwrites key/value mappings to the ENR record as
one sequence number update. An EnrKey
is required to re-sign the record once modified.
Reverts whole ENR record on error.
Returns the previous values as rlp encoded bytes if they exist for the removed and added/ overwritten keys.
pub fn set_public_key(
&mut self,
public_key: &<K as EnrKey>::PublicKey,
key: &K,
) -> Result<(), Error>
pub fn set_public_key( &mut self, public_key: &<K as EnrKey>::PublicKey, key: &K, ) -> Result<(), Error>
Sets a new public key for the record.
pub fn is_udp_reachable(&self) -> bool
pub fn is_udp_reachable(&self) -> bool
Returns whether the node can be reached over UDP or not.
pub fn is_tcp_reachable(&self) -> bool
pub fn is_tcp_reachable(&self) -> bool
Returns whether the node can be reached over TCP or not.
Trait Implementations§
§impl<'de, K> Deserialize<'de> for Enr<K>where
K: EnrKey,
Available on crate feature serde
only.
impl<'de, K> Deserialize<'de> for Enr<K>where
K: EnrKey,
serde
only.§fn deserialize<D>(
deserializer: D,
) -> Result<Enr<K>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Enr<K>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<K> IntoIterator for Enr<K>where
K: EnrKey,
impl<K> IntoIterator for Enr<K>where
K: EnrKey,
§impl<K> Serialize for Enr<K>where
K: EnrKey,
Available on crate feature serde
only.
impl<K> Serialize for Enr<K>where
K: EnrKey,
serde
only.§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
source§impl TryFrom<&Enr<SecretKey>> for NodeRecord
Available on crate feature secp256k1
only.
impl TryFrom<&Enr<SecretKey>> for NodeRecord
secp256k1
only.impl<K> Eq for Enr<K>where
K: EnrKey,
Auto Trait Implementations§
impl<K> Freeze for Enr<K>
impl<K> RefUnwindSafe for Enr<K>where
K: RefUnwindSafe,
impl<K> Send for Enr<K>
impl<K> Sync for Enr<K>
impl<K> Unpin for Enr<K>
impl<K> UnwindSafe for Enr<K>where
K: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 88 bytes