Show / Hide Table of Contents

Class RoutingTable

Kademlia distributed hash table.

Inheritance
Object
RoutingTable
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.dll
Syntax
public class RoutingTable

Constructors

| Improve this Doc View Source

RoutingTable(Address, Int32, Int32)

Creates a Kademlia distributed hash table instance.

Declaration
public RoutingTable(Address address, int tableSize = 160, int bucketSize = 16)
Parameters
Type Name Description
Address address

Address of this peer.

Int32 tableSize

The number of buckets in the table.

Int32 bucketSize

The size of a single bucket.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when tableSize or bucketSize is less then or equal to 0.

Properties

| Improve this Doc View Source

BucketSize

The size of a single bucket.

Declaration
public int BucketSize { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

Count

The number of peers in the table.

Declaration
public int Count { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

Peers

An IReadOnlyList<T> of peers in the table.

Declaration
public IReadOnlyList<BoundPeer> Peers { get; }
Property Value
Type Description
IReadOnlyList<BoundPeer>
| Improve this Doc View Source

PeerStates

An IReadOnlyList<T> of PeerState of peers in the table.

Declaration
public IReadOnlyList<PeerState> PeerStates { get; }
Property Value
Type Description
IReadOnlyList<PeerState>
| Improve this Doc View Source

TableSize

The number of buckets in the table.

Declaration
public int TableSize { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

AddPeer(BoundPeer)

Adds the peer to the table.

Declaration
public void AddPeer(BoundPeer peer)
Parameters
Type Name Description
BoundPeer peer

The BoundPeer to add.

Exceptions
Type Condition
ArgumentNullException

Thrown when peer is null.

ArgumentException

Thrown when peer's Address is equal to the Address of self.

| Improve this Doc View Source

Check(BoundPeer, DateTimeOffset, DateTimeOffset)

Marks peer checked and refreshes last checked time of the peer.

Declaration
public void Check(BoundPeer peer, DateTimeOffset start, DateTimeOffset end)
Parameters
Type Name Description
BoundPeer peer

The Peer to check.

DateTimeOffset start

DateTimeOffset at the beginning of the check.

DateTimeOffset end

DateTimeOffset at the end of the check.

Exceptions
Type Condition
ArgumentNullException

Thrown when peer is null.

| Improve this Doc View Source

Clear()

Removes all peers in the table. This method does not affect static peers.

Declaration
public void Clear()
| Improve this Doc View Source

Contains(BoundPeer)

Determines whether the RoutingTable contains the specified key.

Declaration
public bool Contains(BoundPeer peer)
Parameters
Type Name Description
BoundPeer peer

Key to locate in the RoutingTable.

Returns
Type Description
Boolean

true if the RoutingTable contains an element with the specified key; otherwise, false.

| Improve this Doc View Source

GetPeer(Address)

Finds a BoundPeer whose Address matches with the given addr if it exits.

Declaration
public BoundPeer GetPeer(Address addr)
Parameters
Type Name Description
Address addr

The Address to search.

Returns
Type Description
BoundPeer

A BoundPeer whose Address matches the given addr.

| Improve this Doc View Source

Neighbors(Address, Int32, Boolean)

Returns at most 2 * k (2 * k + 1 if includeTarget is true) nearest peers to given parameter peer from routing table. Return value is sorted with respect to target. SortByDistance(IEnumerable<BoundPeer>, Address)

Declaration
public IReadOnlyList<BoundPeer> Neighbors(Address target, int k, bool includeTarget)
Parameters
Type Name Description
Address target

Address to look up.

Int32 k

Number of peers to return.

Boolean includeTarget

A boolean value indicates to include a peer with Address of target in return value or not.

Returns
Type Description
IReadOnlyList<BoundPeer>

An enumerable of BoundPeer.

| Improve this Doc View Source

Neighbors(Peer, Int32, Boolean)

Returns k nearest peers to given parameter peer from routing table. Return value is already sorted with respect to target.

Declaration
public IReadOnlyList<BoundPeer> Neighbors(Peer target, int k, bool includeTarget)
Parameters
Type Name Description
Peer target

Peer to look up.

Int32 k

Number of peers to return.

Boolean includeTarget

A boolean value indicates to include a peer with Address of target in return value or not.

Returns
Type Description
IReadOnlyList<BoundPeer>

An enumerable of BoundPeer.

| Improve this Doc View Source

RemovePeer(BoundPeer)

Declaration
public bool RemovePeer(BoundPeer peer)
Parameters
Type Name Description
BoundPeer peer
Returns
Type Description
Boolean
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium