Struct everscale_network::adnl::Node
source · [−]pub struct Node { /* private fields */ }
Expand description
Unreliable UDP transport layer
Implementations
sourceimpl Node
impl Node
sourcepub fn new<T>(
socket_addr: T,
keystore: Keystore,
options: NodeOptions,
peer_filter: Option<Arc<dyn PeerFilter>>
) -> Arc<Self> where
T: Into<PackedSocketAddr>,
pub fn new<T>(
socket_addr: T,
keystore: Keystore,
options: NodeOptions,
peer_filter: Option<Arc<dyn PeerFilter>>
) -> Arc<Self> where
T: Into<PackedSocketAddr>,
Create new ADNL node on the specified address
sourcepub fn options(&self) -> &NodeOptions
pub fn options(&self) -> &NodeOptions
ADNL node options
sourcepub fn metrics(&self) -> NodeMetrics
pub fn metrics(&self) -> NodeMetrics
Instant metrics
pub fn add_message_subscriber(
&self,
message_subscriber: Arc<dyn MessageSubscriber>
) -> Result<()>
pub fn add_query_subscriber(
&self,
query_subscriber: Arc<dyn QuerySubscriber>
) -> Result<()>
sourcepub fn compute_query_timeout(&self, roundtrip: Option<u64>) -> u64
pub fn compute_query_timeout(&self, roundtrip: Option<u64>) -> u64
Computes ADNL query timeout, based on the roundtrip and the configured options
sourcepub fn socket_addr(&self) -> PackedSocketAddr
pub fn socket_addr(&self) -> PackedSocketAddr
Socket address of the node
sourcepub fn start_time(&self) -> u32
pub fn start_time(&self) -> u32
Node start timestamp
sourcepub fn build_address_list(&self) -> AddressList
pub fn build_address_list(&self) -> AddressList
Builds new address list for the current ADNL node with no expiration date
sourcepub fn key_by_id(&self, id: &NodeIdShort) -> Result<&Arc<Key>, KeystoreError>
pub fn key_by_id(&self, id: &NodeIdShort) -> Result<&Arc<Key>, KeystoreError>
Searches for the stored ADNL key by it’s short id
See Node::key_by_tag
sourcepub fn key_by_tag(&self, tag: usize) -> Result<&Arc<Key>, KeystoreError>
pub fn key_by_tag(&self, tag: usize) -> Result<&Arc<Key>, KeystoreError>
Searches for the stored ADNL key by it’s tag
See Node::key_by_id
sourcepub fn add_peer(
&self,
ctx: NewPeerContext,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
peer_ip_address: PackedSocketAddr,
peer_full_id: NodeIdFull
) -> Result<bool>
pub fn add_peer(
&self,
ctx: NewPeerContext,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
peer_ip_address: PackedSocketAddr,
peer_full_id: NodeIdFull
) -> Result<bool>
Adds new remote peer. Returns whether the peer was added
sourcepub fn remove_peer(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort
) -> Result<bool>
pub fn remove_peer(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort
) -> Result<bool>
Removes remote peer.
NOTE: This method will return an error if there is no peers table for the specified local id.
See Node::add_peer
sourcepub fn get_peer_ip(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort
) -> Option<PackedSocketAddr>
pub fn get_peer_ip(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort
) -> Option<PackedSocketAddr>
Searches for remote peer ip in the known peers
sourcepub fn match_peer_ips<T>(
&self,
local_id: &NodeIdShort,
entries: FxHashMap<PackedSocketAddr, T>
) -> Option<FxHashMap<T, NodeIdShort>> where
T: Hash + Eq,
pub fn match_peer_ips<T>(
&self,
local_id: &NodeIdShort,
entries: FxHashMap<PackedSocketAddr, T>
) -> Option<FxHashMap<T, NodeIdShort>> where
T: Hash + Eq,
Matches entries with peer id by ip
NOTE: It is a quite expensive method that iterates over all peers and may block new peers from being added during the execution time. Use it with caution.
sourcepub async fn query<Q, A>(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
query: Q,
timeout: Option<u64>
) -> Result<Option<A>> where
Q: TlWrite,
for<'a> A: TlRead<'a, Repr = Boxed> + 'static,
pub async fn query<Q, A>(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
query: Q,
timeout: Option<u64>
) -> Result<Option<A>> where
Q: TlWrite,
for<'a> A: TlRead<'a, Repr = Boxed> + 'static,
ADNL query without prefix to the remote peer.
NOTE: In case of timeout returns Ok(None)
sourcepub async fn query_with_prefix<Q, A>(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
prefix: &[u8],
query: Q,
timeout: Option<u64>
) -> Result<Option<A>> where
Q: TlWrite,
for<'a> A: TlRead<'a, Repr = Boxed> + 'static,
pub async fn query_with_prefix<Q, A>(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
prefix: &[u8],
query: Q,
timeout: Option<u64>
) -> Result<Option<A>> where
Q: TlWrite,
for<'a> A: TlRead<'a, Repr = Boxed> + 'static,
ADNL query with prefix to the remote peer
NOTE: In case of timeout returns Ok(None)
sourcepub async fn query_raw(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
query: Bytes,
timeout: Option<u64>
) -> Result<Option<Vec<u8>>>
pub async fn query_raw(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
query: Bytes,
timeout: Option<u64>
) -> Result<Option<Vec<u8>>>
ADNL query to the remote peer
NOTE: In case of timeout returns Ok(None)
pub fn send_custom_message(
&self,
local_id: &NodeIdShort,
peer_id: &NodeIdShort,
data: &[u8]
) -> Result<()>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl !UnwindSafe for Node
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn 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>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more