Struct everscale_network::OverlayShard
source · [−]pub struct OverlayShard { /* private fields */ }Expand description
P2P messages distribution layer
Implementations
sourceimpl OverlayShard
impl OverlayShard
sourcepub fn options(&self) -> &OverlayShardOptions
pub fn options(&self) -> &OverlayShardOptions
Configuration
sourcepub fn metrics(&self) -> OverlayShardMetrics
pub fn metrics(&self) -> OverlayShardMetrics
Instant metrics
sourcepub fn id(&self) -> &OverlayIdShort
pub fn id(&self) -> &OverlayIdShort
Short overlay id
sourcepub fn overlay_key(&self) -> &Arc<StoredAdnlNodeKey>
pub fn overlay_key(&self) -> &Arc<StoredAdnlNodeKey>
Returns local ADNL key for public overlay
sourcepub fn add_public_peer(
&self,
adnl: &AdnlNode,
ip_address: PackedSocketAddr,
node: Node<'_>
) -> Result<Option<AdnlNodeIdShort>>
pub fn add_public_peer(
&self,
adnl: &AdnlNode,
ip_address: PackedSocketAddr,
node: Node<'_>
) -> Result<Option<AdnlNodeIdShort>>
Verifies and adds new peer to the overlay. Returns Some short peer id
if new peer was successfully added and None if peer already existed.
See OverlayShard::add_public_peers for multiple peers.
sourcepub fn add_public_peers<'a, I>(
&self,
adnl: &AdnlNode,
nodes: I
) -> Result<Vec<AdnlNodeIdShort>> where
I: IntoIterator<Item = (PackedSocketAddr, Node<'a>)>,
pub fn add_public_peers<'a, I>(
&self,
adnl: &AdnlNode,
nodes: I
) -> Result<Vec<AdnlNodeIdShort>> where
I: IntoIterator<Item = (PackedSocketAddr, Node<'a>)>,
Verifies and adds new peers to the overlay. Returns a list of successfully added peers.
See OverlayShard::add_public_peer for single peer.
sourcepub fn delete_public_peer(&self, peer_id: &AdnlNodeIdShort) -> bool
pub fn delete_public_peer(&self, peer_id: &AdnlNodeIdShort) -> bool
Removes peer from random peers and adds it to ignored peers
sourcepub fn write_cached_peers(&self, amount: usize, dst: &PeersCache)
pub fn write_cached_peers(&self, amount: usize, dst: &PeersCache)
Fill dst with amount peers from known peers
sourcepub fn query_prefix(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn query_prefix(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Serialized proto::rpc::OverlayQuery with own overlay id
sourcepub fn message_prefix(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn message_prefix(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Serialized proto::overlay::Message with own overlay id
sourcepub fn send_message(
&self,
adnl: &AdnlNode,
peer_id: &AdnlNodeIdShort,
data: &[u8]
) -> Result<()>
pub fn send_message(
&self,
adnl: &AdnlNode,
peer_id: &AdnlNodeIdShort,
data: &[u8]
) -> Result<()>
Sends direct ADNL message (proto::adnl::Message::Custom) to the given peer.
NOTE: Local id (OverlayShard::overlay_key) will be used as sender
sourcepub async fn adnl_query<Q>(
&self,
adnl: &AdnlNode,
peer_id: &AdnlNodeIdShort,
query: Q,
timeout: Option<u64>
) -> Result<Option<Vec<u8>>> where
Q: TlWrite,
pub async fn adnl_query<Q>(
&self,
adnl: &AdnlNode,
peer_id: &AdnlNodeIdShort,
query: Q,
timeout: Option<u64>
) -> Result<Option<Vec<u8>>> where
Q: TlWrite,
Sends ADNL query directly to the given peer. In case of timeout returns Ok(None)
NOTE: Local id (OverlayShard::overlay_key) will be used as sender
sourcepub async fn rldp_query(
&self,
rldp: &RldpNode,
peer_id: &AdnlNodeIdShort,
data: Vec<u8>,
roundtrip: Option<u64>
) -> Result<(Option<Vec<u8>>, u64)>
pub async fn rldp_query(
&self,
rldp: &RldpNode,
peer_id: &AdnlNodeIdShort,
data: Vec<u8>,
roundtrip: Option<u64>
) -> Result<(Option<Vec<u8>>, u64)>
Sends RLDP query directly to the given peer. In case of timeout returns Ok((None, max_timeout))
NOTE: Local id (OverlayShard::overlay_key) will be used as sender
sourcepub fn broadcast(
self: &Arc<Self>,
adnl: &Arc<AdnlNode>,
data: Vec<u8>,
source: Option<&Arc<StoredAdnlNodeKey>>
) -> OutgoingBroadcastInfo
pub fn broadcast(
self: &Arc<Self>,
adnl: &Arc<AdnlNode>,
data: Vec<u8>,
source: Option<&Arc<StoredAdnlNodeKey>>
) -> OutgoingBroadcastInfo
Distributes provided message to the neighbours subset.
See broadcast_target_count in OverlayShardOptions
NOTE: If data len is greater than
sourcepub async fn wait_for_broadcast(&self) -> IncomingBroadcastInfo
pub async fn wait_for_broadcast(&self) -> IncomingBroadcastInfo
Waits until the next received broadcast.
NOTE: It is important to keep polling this method because otherwise received broadcasts queue will consume all the memory.
sourcepub fn take_new_peers(&self) -> ReceivedPeersMap
pub fn take_new_peers(&self) -> ReceivedPeersMap
Take received peers map
sourcepub fn sign_local_node(&self) -> NodeOwned
pub fn sign_local_node(&self) -> NodeOwned
Returns raw signed overlay node
sourcepub async fn get_random_peers(
&self,
adnl: &AdnlNode,
peer_id: &AdnlNodeIdShort,
existing_peers: &FxDashSet<AdnlNodeIdShort>,
timeout: Option<u64>
) -> Result<Option<Vec<AdnlNodeIdShort>>>
pub async fn get_random_peers(
&self,
adnl: &AdnlNode,
peer_id: &AdnlNodeIdShort,
existing_peers: &FxDashSet<AdnlNodeIdShort>,
timeout: Option<u64>
) -> Result<Option<Vec<AdnlNodeIdShort>>>
Get random peers from the specified peer. Returns Ok(None) in case of timeout
Auto Trait Implementations
impl !RefUnwindSafe for OverlayShard
impl Send for OverlayShard
impl Sync for OverlayShard
impl Unpin for OverlayShard
impl !UnwindSafe for OverlayShard
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