Struct 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 Freeze for Node

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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 T
where U: From<T>,

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 T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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