Struct everscale_network::dht::Node
source · [−]pub struct Node { /* private fields */ }
Expand description
Kademlia-like DHT node
Implementations
sourceimpl Node
impl Node
sourcepub fn new(
adnl: Arc<Node>,
key_tag: usize,
options: NodeOptions
) -> Result<Arc<Self>>
pub fn new(
adnl: Arc<Node>,
key_tag: usize,
options: NodeOptions
) -> Result<Arc<Self>>
Create new DHT node on top of ADNL node
sourcepub fn options(&self) -> &NodeOptions
pub fn options(&self) -> &NodeOptions
Configuration
sourcepub fn metrics(&self) -> NodeMetrics
pub fn metrics(&self) -> NodeMetrics
Instant metrics
pub fn key(&self) -> &Arc<Key>
pub fn iter_known_peers(&self) -> impl Iterator<Item = &NodeIdShort>
sourcepub fn add_dht_peer(&self, peer: NodeOwned) -> Result<Option<NodeIdShort>>
pub fn add_dht_peer(&self, peer: NodeOwned) -> Result<Option<NodeIdShort>>
Adds new peer to DHT or explicitly marks existing as good. Returns new peer short id
sourcepub fn is_bad_peer(&self, peer: &NodeIdShort) -> bool
pub fn is_bad_peer(&self, peer: &NodeIdShort) -> bool
Checks whether the specified peer was marked as bad
sourcepub async fn ping(&self, peer_id: &NodeIdShort) -> Result<bool>
pub async fn ping(&self, peer_id: &NodeIdShort) -> Result<bool>
Sends ping query to the given peer
sourcepub fn entry<'a, T>(self: &'a Arc<Self>, id: &'a T, name: &'a str) -> Entry<'a> where
T: Borrow<[u8; 32]>,
pub fn entry<'a, T>(self: &'a Arc<Self>, id: &'a T, name: &'a str) -> Entry<'a> where
T: Borrow<[u8; 32]>,
Returns an entry interface for manipulating DHT values
sourcepub async fn query_dht_nodes(
&self,
peer_id: &NodeIdShort,
k: u32,
store_self: bool
) -> Result<Vec<NodeOwned>>
pub async fn query_dht_nodes(
&self,
peer_id: &NodeIdShort,
k: u32,
store_self: bool
) -> Result<Vec<NodeOwned>>
Queries given peer for at most k
DHT nodes with
the same affinity as local_id <-> peer_id
sourcepub async fn find_overlay_nodes(
self: &Arc<Self>,
overlay_id: &IdShort
) -> Result<Vec<(PackedSocketAddr, NodeOwned)>>
pub async fn find_overlay_nodes(
self: &Arc<Self>,
overlay_id: &IdShort
) -> Result<Vec<(PackedSocketAddr, NodeOwned)>>
Searches overlay nodes and their ip addresses.
NOTE: For the sake of speed it uses only a subset of nodes, so results may vary between calls.
sourcepub async fn find_address(
self: &Arc<Self>,
peer_id: &NodeIdShort
) -> Result<(PackedSocketAddr, NodeIdFull)>
pub async fn find_address(
self: &Arc<Self>,
peer_id: &NodeIdShort
) -> Result<(PackedSocketAddr, NodeIdFull)>
Searches for the first stored IP address for the given peer id
sourcepub fn store_value(self: &Arc<Self>, value: Value<'_>) -> Result<StoreValue>
pub fn store_value(self: &Arc<Self>, value: Value<'_>) -> Result<StoreValue>
Returns a future which stores value into multiple DHT nodes.
See Node::entry
for more convenient API
sourcepub async fn store_overlay_node(
self: &Arc<Self>,
overlay_full_id: &IdFull,
node: Node<'_>
) -> Result<bool>
pub async fn store_overlay_node(
self: &Arc<Self>,
overlay_full_id: &IdFull,
node: Node<'_>
) -> Result<bool>
Stores given overlay node into multiple DHT nodes
Returns and error if stored value is incorrect
sourcepub async fn store_ip_address(
self: &Arc<Self>,
key: &Key,
ip: PackedSocketAddr
) -> Result<bool>
pub async fn store_ip_address(
self: &Arc<Self>,
key: &Key,
ip: PackedSocketAddr
) -> Result<bool>
Stores given ip into multiple DHT nodes
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