[−][src]Struct discv5::service::Service
Fields
events: VecDeque<ServiceEvent>
Queue of events produced by the session service.
config: Discv5Config
Configuration for the discv5 service.
enr: Enr<CombinedKey>
The local ENR.
key: CombinedKey
The key to sign the ENR and set up encrypted communication with peers.
pending_requests: TimedRequests
Pending raw requests. A list of raw messages we are awaiting a response from the remote. These are indexed by SocketAddr as WHOAREYOU messages do not return a source node id to match against.
pending_messages: HashMap<NodeId, Vec<ProtocolMessage>>
Pending messages. Messages awaiting to be sent, once a handshake has been established.
sessions: TimedSessions
Sessions that have been created for each node id. These can be established or awaiting response from remote nodes.
transport: Transport
The discovery v5 UDP service.
Implementations
impl Service
[src]
pub(crate) fn new(
enr: Enr<CombinedKey>,
key: CombinedKey,
listen_socket: SocketAddr,
config: Discv5Config
) -> Result<Self, Discv5Error>
[src]
enr: Enr<CombinedKey>,
key: CombinedKey,
listen_socket: SocketAddr,
config: Discv5Config
) -> Result<Self, Discv5Error>
A new Session service which instantiates the UDP socket.
pub(crate) fn enr(&self) -> &Enr<CombinedKey>
[src]
The local ENR of the service.
pub(crate) 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>
Generic function to modify a field in the local ENR.
pub(crate) fn update_local_enr_socket(
&mut self,
socket: SocketAddr,
is_tcp: bool
) -> Result<(), EnrError>
[src]
&mut self,
socket: SocketAddr,
is_tcp: bool
) -> Result<(), EnrError>
Updates the local ENR SocketAddr
for either the TCP or UDP port.
pub(crate) fn update_enr(&mut self, enr: Enr<CombinedKey>)
[src]
Updates a session if a new ENR or an updated ENR is discovered.
pub(crate) fn send_request(
&mut self,
dst_enr: &Enr<CombinedKey>,
message: ProtocolMessage
) -> Result<(), Discv5Error>
[src]
&mut self,
dst_enr: &Enr<CombinedKey>,
message: ProtocolMessage
) -> Result<(), Discv5Error>
Sends a ProtocolMessage
request to a known ENR. It is possible to send requests to IP
addresses not related to the ENR.
pub(crate) fn send_request_unknown_enr(
&mut self,
dst: SocketAddr,
dst_id: &NodeId,
message: ProtocolMessage
) -> Result<(), Discv5Error>
[src]
&mut self,
dst: SocketAddr,
dst_id: &NodeId,
message: ProtocolMessage
) -> Result<(), Discv5Error>
Similar to send_request
but for requests which an ENR may be unknown. A session is
therefore assumed to be valid.
pub(crate) fn send_response(
&mut self,
dst: SocketAddr,
dst_id: &NodeId,
message: ProtocolMessage
) -> Result<(), Discv5Error>
[src]
&mut self,
dst: SocketAddr,
dst_id: &NodeId,
message: ProtocolMessage
) -> Result<(), Discv5Error>
Sends an RPC Response. This differs from send request as responses do not require a known ENR to send messages and session's should already be established.
pub(crate) fn send_whoareyou(
&mut self,
dst: SocketAddr,
node_id: &NodeId,
enr_seq: u64,
remote_enr: Option<Enr<CombinedKey>>,
auth_tag: AuthTag
)
[src]
&mut self,
dst: SocketAddr,
node_id: &NodeId,
enr_seq: u64,
remote_enr: Option<Enr<CombinedKey>>,
auth_tag: AuthTag
)
This is called in response to a ServiceMessage::WhoAreYou event. The protocol finds the highest known ENR then calls this function to send a WHOAREYOU packet.
fn src_id(&self, tag: &Tag) -> NodeId
[src]
Calculates the src NodeId
given a tag.
fn tag(&self, dst_id: &NodeId) -> Tag
[src]
Calculates the tag given a NodeId
.
fn handle_whoareyou(
&mut self,
src: SocketAddr,
token: AuthTag,
id_nonce: Nonce,
enr_seq: u64
) -> Result<(), ()>
[src]
&mut self,
src: SocketAddr,
token: AuthTag,
id_nonce: Nonce,
enr_seq: u64
) -> Result<(), ()>
Handles a WHOAREYOU packet that was received from the network.
fn handle_auth_message(
&mut self,
src: SocketAddr,
tag: Tag,
auth_header: AuthHeader,
message: &[u8]
) -> Result<(), ()>
[src]
&mut self,
src: SocketAddr,
tag: Tag,
auth_header: AuthHeader,
message: &[u8]
) -> Result<(), ()>
Handle a message that contains an authentication header.
fn handle_message(
&mut self,
src: SocketAddr,
src_id: NodeId,
auth_tag: AuthTag,
message: &[u8],
tag: Tag
) -> Result<(), ()>
[src]
&mut self,
src: SocketAddr,
src_id: NodeId,
auth_tag: AuthTag,
message: &[u8],
tag: Tag
) -> Result<(), ()>
Handle a standard message that does not contain an authentication header.
fn flush_messages(&mut self, dst: SocketAddr, dst_id: &NodeId) -> Result<(), ()>
[src]
Encrypts and sends any messages that were waiting for a session to be established.
fn process_request(
&mut self,
dst: SocketAddr,
dst_id: NodeId,
packet: Packet,
message: Option<ProtocolMessage>
)
[src]
&mut self,
dst: SocketAddr,
dst_id: NodeId,
packet: Packet,
message: Option<ProtocolMessage>
)
Wrapper around transport.send()
that adds all sent messages to the pending_requests
. This
builds a request adds a timeout and sends the request.
fn check_timeouts(&mut self, cx: &mut Context)
[src]
The heartbeat which checks for timeouts and reports back failed RPC requests/sessions.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl !UnwindSafe for Service
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>,