[−][src]Struct discv5::Discv5
Fields
events: VecDeque<Discv5Event>
Events yielded by this behaviour.
config: Discv5Config
Configuration parameters for the Discv5 service
kbuckets: KBucketsTable<NodeId, RawEnr<CombinedKey>>
Storage of the ENR record for each node.
queries: QueryPool<QueryInfo, NodeId, RawEnr<CombinedKey>>
All the iterative queries we are currently performing.
active_rpc_requests: FnvHashMap<RpcRequest, (Option<QueryId>, Request)>
RPC requests that have been sent and are awaiting a response. Some requests are linked to a query.
active_nodes_responses: HashMap<NodeId, NodesResponse>
Keeps track of the number of responses received from a NODES response.
ip_votes: Option<IpVote>
A map of votes nodes have made about our external IP address. We accept the majority.
connected_peers: HashMap<NodeId, Interval>
List of peers we have established sessions with and an interval for when to send a PING.
service: Service
Main discv5 UDP service that establishes sessions with peers.
Implementations
impl Discv5
[src]
pub fn new(
local_enr: RawEnr<CombinedKey>,
enr_key: CombinedKey,
config: Discv5Config,
listen_socket: SocketAddr
) -> Result<Self, Discv5Error>
[src]
local_enr: RawEnr<CombinedKey>,
enr_key: CombinedKey,
config: Discv5Config,
listen_socket: SocketAddr
) -> Result<Self, Discv5Error>
Builds the Discv5
main struct.
local_enr
is the ENR
representing the local node. This contains node identifying information, such
as IP addresses and ports which we wish to broadcast to other nodes via this discovery
mechanism. The listen_socket
determines which UDP socket address the behaviour will listen on.
pub fn add_enr(&mut self, enr: RawEnr<CombinedKey>) -> Result<(), &'static str>
[src]
Adds a known ENR of a peer participating in Discv5 to the routing table.
This allows pre-populating the Kademlia routing table with known addresses, so that they can be used immediately in following DHT operations involving one of these peers, without having to dial them upfront.
pub fn remove_node(&mut self, node_id: &NodeId) -> bool
[src]
Removes a node_id
from the routing table.
This allows applications, for whatever reason, to remove nodes from the local routing
table. Returns true
if the node was in the table and false
otherwise.
pub fn connected_peers(&self) -> usize
[src]
Returns the number of connected peers the service knows about.
pub fn local_enr(&self) -> &RawEnr<CombinedKey>
[src]
Returns the local ENR of the node.
pub fn update_local_enr_socket(
&mut self,
socket_addr: SocketAddr,
is_tcp: bool
) -> bool
[src]
&mut self,
socket_addr: SocketAddr,
is_tcp: bool
) -> bool
Allows the application layer to update the local ENR's UDP socket. The second parameter
determines whether the port is a TCP port. If this parameter is false, this is
interpreted as a UDP SocketAddr
.
pub fn enr_insert(
&mut self,
key: &str,
value: Vec<u8>
) -> Result<Option<Vec<u8>>, EnrError>
[src]
&mut self,
key: &str,
value: Vec<u8>
) -> Result<Option<Vec<u8>>, EnrError>
Allows application layer to insert an arbitrary field into the local ENR.
pub fn kbuckets_entries(&mut self) -> impl Iterator<Item = &NodeId>
[src]
Returns an iterator over all ENR node IDs of nodes currently contained in a bucket of the Kademlia routing table.
pub fn enr_entries(&mut self) -> impl Iterator<Item = &RawEnr<CombinedKey>>
[src]
Returns an iterator over all the ENR's of nodes currently contained in a bucket of the Kademlia routing table.
pub fn find_node(&mut self, target_node: NodeId) -> QueryId
[src]
Starts an iterative FIND_NODE
request.
This will eventually produce an event containing the nodes of the DHT closest to the
requested PeerId
.
pub fn find_enr_predicate<F>(
&mut self,
node_id: NodeId,
predicate: F,
num_nodes: usize
) -> QueryId where
F: Fn(&RawEnr<CombinedKey>) -> bool + Send + Clone + 'static,
[src]
&mut self,
node_id: NodeId,
predicate: F,
num_nodes: usize
) -> QueryId where
F: Fn(&RawEnr<CombinedKey>) -> bool + Send + Clone + 'static,
Starts a FIND_NODE
request.
This will eventually produce an event containing <= num
nodes which satisfy the
predicate
with passed value
.
pub fn find_enr(&mut self, node_id: &NodeId) -> Option<RawEnr<CombinedKey>>
[src]
Returns an ENR if one is known for the given NodeId.
fn handle_rpc_request(
&mut self,
src: SocketAddr,
node_id: NodeId,
rpc_id: u64,
req: Request
)
[src]
&mut self,
src: SocketAddr,
node_id: NodeId,
rpc_id: u64,
req: Request
)
Processes an RPC request from a peer. Requests respond to the received socket address, rather than the IP of the known ENR.
fn handle_rpc_response(&mut self, node_id: NodeId, rpc_id: u64, res: Response)
[src]
Processes an RPC response from a peer.
fn send_ping(&mut self, node_id: &NodeId)
[src]
Sends a PING request to a node.
fn ping_connected_peers(&mut self)
[src]
fn request_enr(&mut self, node_id: &NodeId, src: SocketAddr)
[src]
Request an external node's ENR.
fn send_nodes_response(
&mut self,
dst: SocketAddr,
dst_id: NodeId,
rpc_id: u64,
distance: u64
)
[src]
&mut self,
dst: SocketAddr,
dst_id: NodeId,
rpc_id: u64,
distance: u64
)
Sends a NODES response, given a list of found ENR's. This function splits the nodes up into multiple responses to ensure the response stays below the maximum packet size.
fn send_rpc_query(
&mut self,
query_id: QueryId,
query_info: QueryInfo,
return_peer: &ReturnPeer<NodeId>
)
[src]
&mut self,
query_id: QueryId,
query_info: QueryInfo,
return_peer: &ReturnPeer<NodeId>
)
Constructs and sends a request RPC to the session service given a QueryInfo
.
fn send_rpc_request(
&mut self,
node_id: &NodeId,
req: Request,
query_id: Option<QueryId>
)
[src]
&mut self,
node_id: &NodeId,
req: Request,
query_id: Option<QueryId>
)
Sends generic RPC requests. Each request gets added to known outputs, awaiting a response.
fn start_findnode_query(&mut self, target_node: NodeId) -> QueryId
[src]
Internal function that starts a query.
fn start_predicate_query<F>(
&mut self,
target_node: NodeId,
predicate: F,
num_nodes: usize
) -> QueryId where
F: Fn(&RawEnr<CombinedKey>) -> bool + Send + Clone + 'static,
[src]
&mut self,
target_node: NodeId,
predicate: F,
num_nodes: usize
) -> QueryId where
F: Fn(&RawEnr<CombinedKey>) -> bool + Send + Clone + 'static,
Internal function that starts a query.
fn discovered(
&mut self,
source: &NodeId,
enrs: Vec<RawEnr<CombinedKey>>,
query_id: Option<QueryId>
)
[src]
&mut self,
source: &NodeId,
enrs: Vec<RawEnr<CombinedKey>>,
query_id: Option<QueryId>
)
Processes discovered peers from a query.
fn connection_updated(
&mut self,
node_id: NodeId,
enr: Option<RawEnr<CombinedKey>>,
new_status: NodeStatus
)
[src]
&mut self,
node_id: NodeId,
enr: Option<RawEnr<CombinedKey>>,
new_status: NodeStatus
)
Update the connection status of a node in the routing table.
fn inject_session_established(&mut self, enr: RawEnr<CombinedKey>)
[src]
The equivalent of libp2p inject_connected()
for a udp session. We have no stream, but a
session key-pair has been negotiated.
fn rpc_failure(&mut self, node_id: NodeId, failed_rpc_id: u64)
[src]
A session could not be established or an RPC request timed-out (after a few retries, if specified).
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Discv5
impl Send for Discv5
impl !Sync for Discv5
impl Unpin for Discv5
impl !UnwindSafe for Discv5
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> StreamExt for T where
T: Stream + ?Sized,
[src]
T: Stream + ?Sized,
fn next(&mut self) -> Next<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn into_future(self) -> StreamFuture<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn map<T, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> T,
[src]
F: FnMut(Self::Item) -> T,
fn enumerate(self) -> Enumerate<Self>
[src]
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F> where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
[src]
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
[src]
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
[src]
F: FnMut(Self::Item) -> Fut,
Fut: Future,
fn collect<C>(self) -> Collect<Self, C> where
C: Default + Extend<Self::Item>,
[src]
C: Default + Extend<Self::Item>,
fn concat(self) -> Concat<Self> where
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
Self::Item: Default,
[src]
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
Self::Item: Default,
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F> where
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
[src]
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
fn flatten(self) -> Flatten<Self> where
Self::Item: Stream,
[src]
Self::Item: Stream,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: Stream,
[src]
F: FnMut(Self::Item) -> U,
U: Stream,
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F> where
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
[src]
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F> where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
[src]
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F> where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
[src]
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut> where
Fut: Future,
[src]
Fut: Future,
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
[src]
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
fn for_each_concurrent<Fut, F>(
self,
limit: impl Into<Option<usize>>,
f: F
) -> ForEachConcurrent<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
[src]
self,
limit: impl Into<Option<usize>>,
f: F
) -> ForEachConcurrent<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
fn take(self, n: usize) -> Take<Self>
[src]
fn skip(self, n: usize) -> Skip<Self>
[src]
fn fuse(self) -> Fuse<Self>
[src]
fn by_ref(&mut self) -> &mut Self
[src]
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
[src]
Self: UnwindSafe,
fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a + Send>> where
Self: Send + 'a,
[src]
Self: Send + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>> where
Self: 'a,
[src]
Self: 'a,
fn buffered(self, n: usize) -> Buffered<Self> where
Self::Item: Future,
[src]
Self::Item: Future,
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self> where
Self::Item: Future,
[src]
Self::Item: Future,
fn zip<St>(self, other: St) -> Zip<Self, St> where
St: Stream,
[src]
St: Stream,
fn chain<St>(self, other: St) -> Chain<Self, St> where
St: Stream<Item = Self::Item>,
[src]
St: Stream<Item = Self::Item>,
fn peekable(self) -> Peekable<Self>
[src]
fn chunks(self, capacity: usize) -> Chunks<Self>
[src]
fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>
[src]
fn forward<S>(self, sink: S) -> Forward<Self, S> where
S: Sink<Self::Ok, Error = Self::Error>,
Self: TryStream,
[src]
S: Sink<Self::Ok, Error = Self::Error>,
Self: TryStream,
fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>) where
Self: Sink<Item>,
[src]
Self: Sink<Item>,
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
[src]
F: FnMut(&Self::Item),
fn left_stream<B>(self) -> Either<Self, B> where
B: Stream<Item = Self::Item>,
[src]
B: Stream<Item = Self::Item>,
fn right_stream<B>(self) -> Either<B, Self> where
B: Stream<Item = Self::Item>,
[src]
B: Stream<Item = Self::Item>,
fn poll_next_unpin(&mut self, cx: &mut Context) -> Poll<Option<Self::Item>> where
Self: Unpin,
[src]
Self: Unpin,
fn select_next_some(&mut self) -> SelectNextSome<Self> where
Self: Unpin + FusedStream,
[src]
Self: Unpin + FusedStream,
impl<St> StreamExt for St where
St: Stream + ?Sized,
[src]
St: Stream + ?Sized,
fn next(&mut self) -> Next<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn try_next<T, E>(&mut self) -> TryNext<Self> where
Self: Stream<Item = Result<T, E>> + Unpin,
[src]
Self: Stream<Item = Result<T, E>> + Unpin,
fn map<T, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> T,
[src]
F: FnMut(Self::Item) -> T,
fn merge<U>(self, other: U) -> Merge<Self, U> where
U: Stream<Item = Self::Item>,
[src]
U: Stream<Item = Self::Item>,
fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<T>,
[src]
F: FnMut(Self::Item) -> Option<T>,
fn fuse(self) -> Fuse<Self>
[src]
fn take(self, n: usize) -> Take<Self>
[src]
fn take_while<F>(self, f: F) -> TakeWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
fn skip(self, n: usize) -> Skip<Self>
[src]
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
fn all<F>(&mut self, f: F) -> AllFuture<Self, F> where
F: FnMut(Self::Item) -> bool,
Self: Unpin,
[src]
F: FnMut(Self::Item) -> bool,
Self: Unpin,
fn any<F>(&mut self, f: F) -> AnyFuture<Self, F> where
F: FnMut(Self::Item) -> bool,
Self: Unpin,
[src]
F: FnMut(Self::Item) -> bool,
Self: Unpin,
fn chain<U>(self, other: U) -> Chain<Self, U> where
U: Stream<Item = Self::Item>,
[src]
U: Stream<Item = Self::Item>,
fn fold<B, F>(self, init: B, f: F) -> FoldFuture<Self, B, F> where
F: FnMut(B, Self::Item) -> B,
[src]
F: FnMut(B, Self::Item) -> B,
fn collect<T>(self) -> Collect<Self, T> where
T: FromStream<Self::Item>,
[src]
T: FromStream<Self::Item>,
fn timeout(self, duration: Duration) -> Timeout<Self>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,