Struct everscale_network::AdnlNode
source · [−]pub struct AdnlNode { /* private fields */ }Expand description
Unreliable UDP transport layer
Implementations
sourceimpl AdnlNode
impl AdnlNode
sourcepub fn new<T>(
socket_addr: T,
keystore: Keystore,
options: AdnlNodeOptions,
peer_filter: Option<Arc<dyn AdnlPeerFilter>>
) -> Arc<Self> where
T: Into<PackedSocketAddr>,
pub fn new<T>(
socket_addr: T,
keystore: Keystore,
options: AdnlNodeOptions,
peer_filter: Option<Arc<dyn AdnlPeerFilter>>
) -> Arc<Self> where
T: Into<PackedSocketAddr>,
Create new ADNL node on the specified address
sourcepub fn options(&self) -> &AdnlNodeOptions
pub fn options(&self) -> &AdnlNodeOptions
ADNL node options
sourcepub fn metrics(&self) -> AdnlNodeMetrics
pub fn metrics(&self) -> AdnlNodeMetrics
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: &AdnlNodeIdShort
) -> Result<&Arc<StoredAdnlNodeKey>, KeystoreError>
pub fn key_by_id(
&self,
id: &AdnlNodeIdShort
) -> Result<&Arc<StoredAdnlNodeKey>, KeystoreError>
Searches for the stored ADNL key by it’s short id
sourcepub fn key_by_tag(
&self,
tag: usize
) -> Result<&Arc<StoredAdnlNodeKey>, KeystoreError>
pub fn key_by_tag(
&self,
tag: usize
) -> Result<&Arc<StoredAdnlNodeKey>, KeystoreError>
Searches for the stored ADNL key by it’s tag
sourcepub fn add_peer(
&self,
ctx: NewPeerContext,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
peer_ip_address: PackedSocketAddr,
peer_full_id: AdnlNodeIdFull
) -> Result<bool>
pub fn add_peer(
&self,
ctx: NewPeerContext,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
peer_ip_address: PackedSocketAddr,
peer_full_id: AdnlNodeIdFull
) -> Result<bool>
Adds new remote peer. Returns whether the peer was added
sourcepub fn remove_peer(
&self,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort
) -> Result<bool>
pub fn remove_peer(
&self,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort
) -> Result<bool>
Removes remote peer.
NOTE: This method will return an error if there is no peers table for the specified local id.
sourcepub fn get_peer_ip(
&self,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort
) -> Option<PackedSocketAddr>
pub fn get_peer_ip(
&self,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort
) -> Option<PackedSocketAddr>
Searches for remote peer ip in the known peers
sourcepub async fn query<Q, A>(
&self,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
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: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
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: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
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: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
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: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
query: Bytes,
timeout: Option<u64>
) -> Result<Option<Vec<u8>>>
pub async fn query_raw(
&self,
local_id: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
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: &AdnlNodeIdShort,
peer_id: &AdnlNodeIdShort,
data: &[u8]
) -> Result<()>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for AdnlNode
impl Send for AdnlNode
impl Sync for AdnlNode
impl Unpin for AdnlNode
impl !UnwindSafe for AdnlNode
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