Struct everscale_network::overlay::Shard
source · [−]pub struct Shard { /* private fields */ }
Expand description
P2P messages distribution layer
Implementations
sourceimpl Shard
impl Shard
sourcepub fn options(&self) -> &ShardOptions
pub fn options(&self) -> &ShardOptions
Configuration
sourcepub fn metrics(&self) -> ShardMetrics
pub fn metrics(&self) -> ShardMetrics
Instant metrics
sourcepub fn overlay_key(&self) -> &Arc<Key>
pub fn overlay_key(&self) -> &Arc<Key>
Returns local ADNL key for public overlay
sourcepub fn add_public_peer(
&self,
adnl: &Node,
ip_address: PackedSocketAddr,
node: Node<'_>
) -> Result<Option<NodeIdShort>>
pub fn add_public_peer(
&self,
adnl: &Node,
ip_address: PackedSocketAddr,
node: Node<'_>
) -> Result<Option<NodeIdShort>>
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 Shard::add_public_peers
for multiple peers.
sourcepub fn add_public_peers<'a, I>(
&self,
adnl: &Node,
nodes: I
) -> Result<Vec<NodeIdShort>> where
I: IntoIterator<Item = (PackedSocketAddr, Node<'a>)>,
pub fn add_public_peers<'a, I>(
&self,
adnl: &Node,
nodes: I
) -> Result<Vec<NodeIdShort>> where
I: IntoIterator<Item = (PackedSocketAddr, Node<'a>)>,
Verifies and adds new peers to the overlay. Returns a list of successfully added peers.
See Shard::add_public_peer
for single peer.
sourcepub fn delete_public_peer(&self, peer_id: &NodeIdShort) -> bool
pub fn delete_public_peer(&self, peer_id: &NodeIdShort) -> bool
Removes peer from random peers and adds it to ignored peers
sourcepub fn write_cached_peers(&self, amount: usize, dst: &PeersSet)
pub fn write_cached_peers(&self, amount: usize, dst: &PeersSet)
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: &Node,
peer_id: &NodeIdShort,
data: &[u8]
) -> Result<()>
pub fn send_message(
&self,
adnl: &Node,
peer_id: &NodeIdShort,
data: &[u8]
) -> Result<()>
Sends direct ADNL message (proto::adnl::Message::Custom
) to the given peer.
NOTE: Local id (Shard::overlay_key
) will be used as sender
sourcepub async fn adnl_query<Q>(
&self,
adnl: &Node,
peer_id: &NodeIdShort,
query: Q,
timeout: Option<u64>
) -> Result<Option<Vec<u8>>> where
Q: TlWrite,
pub async fn adnl_query<Q>(
&self,
adnl: &Node,
peer_id: &NodeIdShort,
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 (Shard::overlay_key
) will be used as sender
sourcepub async fn rldp_query(
&self,
rldp: &Node,
peer_id: &NodeIdShort,
data: Vec<u8>,
roundtrip: Option<u64>
) -> Result<(Option<Vec<u8>>, u64)>
pub async fn rldp_query(
&self,
rldp: &Node,
peer_id: &NodeIdShort,
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 (Shard::overlay_key
) will be used as sender
sourcepub fn broadcast(
self: &Arc<Self>,
adnl: &Arc<Node>,
data: Vec<u8>,
source: Option<&Arc<Key>>,
target: BroadcastTarget
) -> OutgoingBroadcastInfo
pub fn broadcast(
self: &Arc<Self>,
adnl: &Arc<Node>,
data: Vec<u8>,
source: Option<&Arc<Key>>,
target: BroadcastTarget
) -> OutgoingBroadcastInfo
Distributes provided message to the neighbours subset.
See broadcast_target_count
in ShardOptions
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 exchange_random_peers(
&self,
adnl: &Node,
peer_id: &NodeIdShort,
existing_peers: &FxDashSet<NodeIdShort>,
timeout: Option<u64>
) -> Result<Option<Vec<NodeIdShort>>>
pub async fn exchange_random_peers(
&self,
adnl: &Node,
peer_id: &NodeIdShort,
existing_peers: &FxDashSet<NodeIdShort>,
timeout: Option<u64>
) -> Result<Option<Vec<NodeIdShort>>>
Exchanges random peers with the specified peer. Returns Ok(None)
in case of timeout
Auto Trait Implementations
impl !RefUnwindSafe for Shard
impl Send for Shard
impl Sync for Shard
impl Unpin for Shard
impl !UnwindSafe for Shard
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