Struct everscale_network::dht::Node

source ·
pub struct Node { /* private fields */ }
Expand description

Kademlia-like DHT node

Implementations§

source§

impl Node

source

pub fn new( adnl: Arc<Node>, key_tag: usize, options: NodeOptions ) -> Result<Arc<Self>>

Create new DHT node on top of ADNL node

source

pub fn options(&self) -> &NodeOptions

Configuration

source

pub fn metrics(&self) -> NodeMetrics

Instant metrics

source

pub fn adnl(&self) -> &Arc<Node>

Underlying ADNL node

source

pub fn key(&self) -> &Arc<Key>

source

pub fn iter_known_peers(&self) -> impl Iterator<Item = &NodeIdShort>

source

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

source

pub fn is_bad_peer(&self, peer: &NodeIdShort) -> bool

Checks whether the specified peer was marked as bad

source

pub async fn ping(&self, peer_id: &NodeIdShort) -> Result<bool>

Sends ping query to the given peer

source

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

source

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

source

pub async fn find_more_dht_nodes(&self) -> Result<usize>

Asks each known DHT node for other nodes, extending current nodes set

source

pub async fn find_overlay_nodes( self: &Arc<Self>, overlay_id: &IdShort ) -> Result<Vec<(SocketAddrV4, 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.

source

pub async fn find_address( self: &Arc<Self>, peer_id: &NodeIdShort ) -> Result<(SocketAddrV4, NodeIdFull)>

Searches for the first stored IP address for the given peer id

source

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

source

pub async fn store_overlay_node( self: &Arc<Self>, overlay_id_full: &IdFull, node: Node<'_> ) -> Result<bool>

Stores given overlay node into multiple DHT nodes

Returns and error if stored value is incorrect

source

pub async fn store_address( self: &Arc<Self>, key: &Key, addr: SocketAddrV4 ) -> Result<bool>

Stores given socket address 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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

source§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U, I> LiftInto<U, I> for Twhere U: LiftFrom<T, I>,

source§

fn lift_into(self) -> U

Performs the indexed conversion.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more