Show / Hide Table of Contents

Class KademliaProtocol

A Kademlia based peer discovery protocol.

Inheritance
Object
KademliaProtocol
Implements
IProtocol
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Net.Protocols
Assembly: Libplanet.Net.dll
Syntax
public class KademliaProtocol : IProtocol

Constructors

| Improve this Doc View Source

KademliaProtocol(RoutingTable, ITransport, Address, Int32, Nullable<TimeSpan>)

Creates a KademliaProtocol instance.

Declaration
public KademliaProtocol(RoutingTable table, ITransport transport, Address address, int findConcurrency = 3, TimeSpan? requestTimeout = null)
Parameters
Type Name Description
RoutingTable table

The RoutingTable where BoundPeers are stored.

ITransport transport

ITransport to process messages.

Address address

The Address of the BoundPeer to be the reference point.

Int32 findConcurrency

The number of concurrency in peer discovery.

Nullable<TimeSpan> requestTimeout

A timeout of waiting for the reply of messages. If it's omitted or null is given, will automatically be set to 5 seconds.

Methods

| Improve this Doc View Source

AddPeersAsync(IEnumerable<BoundPeer>, Nullable<TimeSpan>, CancellationToken)

Tries to add given peers to routing table by sending PingMsg.

Declaration
public async Task AddPeersAsync(IEnumerable<BoundPeer> peers, TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
Type Name Description
IEnumerable<BoundPeer> peers

The peers to add.

Nullable<TimeSpan> timeout

A timeout of waiting for the reply of PingMsg message sent to peers. If null is given, task never halts by itself even the target peer gives no any response.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

| Improve this Doc View Source

BootstrapAsync(IEnumerable<BoundPeer>, Nullable<TimeSpan>, Int32, CancellationToken)

Conducts peer discovery for given bootstrapPeers.

Declaration
public async Task BootstrapAsync(IEnumerable<BoundPeer> bootstrapPeers, TimeSpan? dialTimeout, int depth, CancellationToken cancellationToken)
Parameters
Type Name Description
IEnumerable<BoundPeer> bootstrapPeers

A IEnumerable<T> of BoundPeers to bootstrap.

Nullable<TimeSpan> dialTimeout

The timeout used when waiting a reply for either PingMsg or FindNeighborsMsg. If null is given, the task never halts by itself even no any response was given from the the target seed.

Int32 depth

Recursive operation depth to search peers from network.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

| Improve this Doc View Source

CheckAllPeersAsync(Nullable<TimeSpan>, CancellationToken)

Refreshes all peers in routing table.

Declaration
public async Task CheckAllPeersAsync(TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
Type Name Description
Nullable<TimeSpan> timeout

A timeout of waiting for the reply of messages. If null is given, the task never halts by itself even no any response was given from the the target peer.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

| Improve this Doc View Source

CheckReplacementCacheAsync(CancellationToken)

Checks the Libplanet.Net.Protocols.KBucket in the RoutingTable and if there is an empty Libplanet.Net.Protocols.KBucket, fill it with BoundPeers in the Libplanet.Net.Protocols.KBucket.ReplacementCache.

Declaration
public async Task CheckReplacementCacheAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

| Improve this Doc View Source

FindSpecificPeerAsync(Address, Int32, Nullable<TimeSpan>, CancellationToken)

Use FindNeighborsMsg messages to to find a BoundPeer with Address of target.

Declaration
public async Task<BoundPeer> FindSpecificPeerAsync(Address target, int depth, TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
Type Name Description
Address target

The Address to find.

Int32 depth

Target depth of recursive operation.

Nullable<TimeSpan> timeout

TimeSpan for waiting reply of FindNeighborsMsg.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task<BoundPeer>

A BoundPeer with target as its Address if found. Otherwise, null.

| Improve this Doc View Source

RebuildConnectionAsync(Int32, CancellationToken)

Reconstructs network connection between peers on network.

Declaration
public async Task RebuildConnectionAsync(int depth, CancellationToken cancellationToken)
Parameters
Type Name Description
Int32 depth

Recursive operation depth to search peers from network.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

| Improve this Doc View Source

RefreshTableAsync(TimeSpan, CancellationToken)

Checks whether BoundPeers in RoutingTable is online by sending PingMsg.

Declaration
public async Task RefreshTableAsync(TimeSpan maxAge, CancellationToken cancellationToken)
Parameters
Type Name Description
TimeSpan maxAge

Maximum age of peer to validate.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

Implements

IProtocol
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium