pub struct Discv5 { /* private fields */ }Expand description
Transparent wrapper around [discv5::Discv5].
Implementations§
Source§impl Discv5
impl Discv5
Sourcepub fn add_node(&self, node_record: Enr<SecretKey>) -> Result<(), Error>
pub fn add_node(&self, node_record: Enr<SecretKey>) -> Result<(), Error>
Adds the node to the table, if it is not already present.
Sourcepub fn set_eip868_in_local_enr(&self, key: Vec<u8>, rlp: Bytes)
pub fn set_eip868_in_local_enr(&self, key: Vec<u8>, rlp: Bytes)
Sets the pair in the EIP-868 Enr of the node.
If the key already exists, this will update it.
CAUTION: The value must be rlp encoded
Sourcepub fn encode_and_set_eip868_in_local_enr(
&self,
key: Vec<u8>,
value: impl Encodable,
)
pub fn encode_and_set_eip868_in_local_enr( &self, key: Vec<u8>, value: impl Encodable, )
Sets the pair in the EIP-868 Enr of the node.
If the key already exists, this will update it.
Sourcepub fn ban(&self, peer_id: PeerId, ip: IpAddr)
pub fn ban(&self, peer_id: PeerId, ip: IpAddr)
Adds the peer and id to the ban list.
This will prevent any future inclusion in the table
Sourcepub fn ban_ip(&self, ip: IpAddr)
pub fn ban_ip(&self, ip: IpAddr)
Adds the ip to the ban list.
This will prevent any future inclusion in the table
Sourcepub fn node_record(&self) -> Option<NodeRecord>
pub fn node_record(&self) -> Option<NodeRecord>
Returns the NodeRecord of the local node.
This includes the currently tracked external IP address of the node.
Returns None if the local ENR does not contain the required fields.
Sourcepub fn local_enr(&self) -> Enr<CombinedKey>
pub fn local_enr(&self) -> Enr<CombinedKey>
Returns the local Enr of the service.
Sourcepub const fn local_port(&self) -> u16
pub const fn local_port(&self) -> u16
The port the discv5 service is listening on.
Sourcepub async fn start(
sk: &SecretKey,
discv5_config: Config,
) -> Result<(Self, Receiver<Event>), Error>
pub async fn start( sk: &SecretKey, discv5_config: Config, ) -> Result<(Self, Receiver<Event>), Error>
Spawns [discv5::Discv5]. Returns [discv5::Discv5] handle in reth compatible wrapper type
Discv5, a receiver of [discv5::Event]s from the underlying node, and the local
Enr converted into the reth compatible NodeRecord type.
Sourcepub fn on_discv5_update(&self, update: Event) -> Option<DiscoveredPeer>
pub fn on_discv5_update(&self, update: Event) -> Option<DiscoveredPeer>
Process an event from the underlying [discv5::Discv5] node.
Sourcepub fn on_discovered_peer(
&self,
enr: &Enr,
socket: SocketAddr,
) -> Option<DiscoveredPeer>
pub fn on_discovered_peer( &self, enr: &Enr, socket: SocketAddr, ) -> Option<DiscoveredPeer>
Processes a discovered peer. Returns true if peer is added to
Sourcepub fn try_into_reachable(
&self,
enr: &Enr,
socket: SocketAddr,
) -> Result<NodeRecord, Error>
pub fn try_into_reachable( &self, enr: &Enr, socket: SocketAddr, ) -> Result<NodeRecord, Error>
Tries to recover an unreachable Enr received via
[discv5::Event::UnverifiableEnr], into a NodeRecord usable by RLPx.
NOTE: Fallback solution to be compatible with Geth which includes peers into the discv5 WAN topology which, for example, advertise in their ENR that localhost is their UDP IP address. These peers are only discovered if they initiate a connection attempt, and we by such means learn their reachable IP address. If we receive their ENR from any other peer as part of a lookup query, we won’t find a reachable IP address on which to dial them by reading their ENR.
Sourcepub fn filter_discovered_peer(&self, enr: &Enr) -> FilterOutcome
pub fn filter_discovered_peer(&self, enr: &Enr) -> FilterOutcome
Sourcepub fn get_fork_id<K: EnrKey>(&self, enr: &Enr<K>) -> Result<ForkId, Error>
pub fn get_fork_id<K: EnrKey>(&self, enr: &Enr<K>) -> Result<ForkId, Error>
Returns the [ForkId] of the given Enr w.r.t. the local node’s network
stack, if field is set.
Sourcepub fn with_discv5<F, R>(&self, f: F) -> Rwhere
F: FnOnce(&Discv5) -> R,
pub fn with_discv5<F, R>(&self, f: F) -> Rwhere
F: FnOnce(&Discv5) -> R,
Exposes API of [discv5::Discv5].
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Discv5
impl !UnwindSafe for Discv5
impl Freeze for Discv5
impl Send for Discv5
impl Sync for Discv5
impl Unpin for Discv5
impl UnsafeUnpin for Discv5
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
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: 336 bytes