Class KademliaProtocol
A Kademlia based peer discovery protocol.
Implements
Inherited Members
Namespace: Libplanet.Net.Protocols
Assembly: Libplanet.dll
Syntax
public class KademliaProtocol : IProtocol
Constructors
| Improve this Doc View SourceKademliaProtocol(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 Peers are stored. |
ITransport | transport | ITransport to process messages. |
Address | address | |
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 |
Methods
| Improve this Doc View SourceAddPeersAsync(IEnumerable<Peer>, Nullable<TimeSpan>, CancellationToken)
Tries to add given peers
to routing table
by sending Libplanet.Net.Messages.Ping.
Declaration
public async Task AddPeersAsync(IEnumerable<Peer> peers, TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Peer> | peers | The peers to add. |
Nullable<TimeSpan> | timeout | A timeout of waiting for the reply of Libplanet.Net.Messages.Ping
message sent to |
CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task | An awaitable task without value. |
BootstrapAsync(IEnumerable<BoundPeer>, Nullable<TimeSpan>, Nullable<TimeSpan>, Int32, CancellationToken)
Conducts peer discovery for given bootstrapPeers
.
Declaration
public async Task BootstrapAsync(IEnumerable<BoundPeer> bootstrapPeers, TimeSpan? pingSeedTimeout, TimeSpan? findNeighborsTimeout, int depth, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<BoundPeer> | bootstrapPeers | A IEnumerable<T> of Peers to bootstrap. |
Nullable<TimeSpan> | pingSeedTimeout | A timeout of waiting for the reply of Libplanet.Net.Messages.Ping
message sent to seed Peer.
If |
Nullable<TimeSpan> | findNeighborsTimeout | A timeout of waiting for the reply of
Libplanet.Net.Messages.FindNeighbors message sent to seed Peer.
If |
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. |
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 |
CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task | An awaitable task without value. |
CheckReplacementCacheAsync(CancellationToken)
Checks the Libplanet.Net.Protocols.KBucket in the RoutingTable and if there is an empty Libplanet.Net.Protocols.KBucket, fill it with Peers 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. |
FindSpecificPeerAsync(Address, Int32, Nullable<TimeSpan>, CancellationToken)
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 Libplanet.Net.Messages.FindNeighbors. |
CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task<BoundPeer> |
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. |
RefreshTableAsync(TimeSpan, CancellationToken)
Checks whether Peers in RoutingTable is online by sending Libplanet.Net.Messages.Ping.
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. |