Class Kademlia
Commonly used constants and static functions for Kademlia distributed hash table.
Namespace: Libplanet.Net.Protocols
Assembly: Libplanet.Net.dll
Syntax
public static class Kademlia : object
Fields
| Improve this Doc View SourceBucketSize
The size of a single bucket.
Declaration
public const int BucketSize = null
Field Value
Type | Description |
---|---|
Int32 |
FindConcurrency
The number of concurrency in peer discovery.
Declaration
public const int FindConcurrency = null
Field Value
Type | Description |
---|---|
Int32 |
MaxDepth
Depth of the peer discovery operation.
Declaration
public const int MaxDepth = null
Field Value
Type | Description |
---|---|
Int32 |
TableSize
The number of buckets in the table.
Declaration
public const int TableSize = null
Field Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceCalculateDifference(Address, Address)
Calculates the difference between two Addresses.
Declaration
public static Address CalculateDifference(Address left, Address right)
Parameters
Type | Name | Description |
---|---|---|
Address | left | The first Address. |
Address | right | The second Address. |
Returns
Type | Description |
---|---|
Address | The difference between the two Addresses given. |
CalculateDistance(Address, Address)
Calculates the distance between two Addresses.
Declaration
public static int CalculateDistance(Address left, Address right)
Parameters
Type | Name | Description |
---|---|---|
Address | left | The first Address. |
Address | right | The second Address. |
Returns
Type | Description |
---|---|
Int32 | The distance between the two Addresses given. |
CommonPrefixLength(Address, Address)
Calculates the length of the common prefix between two Addresses by finding the index of the first non-zero bit of the xor between the two.
Declaration
public static int CommonPrefixLength(Address left, Address right)
Parameters
Type | Name | Description |
---|---|---|
Address | left | The first element to calculate the common prefix length. |
Address | right | The second element to calculate the common prefix length. |
Returns
Type | Description |
---|---|
Int32 | The length of the common prefix between |
SortByDistance(IEnumerable<BoundPeer>, Address)
Sorts a list of BoundPeers with respect to
the distance from target
in ascending order.
Declaration
public static IEnumerable<BoundPeer> SortByDistance(IEnumerable<BoundPeer> peers, Address target)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<BoundPeer> | peers | The |
Address | target | The Address to calculate the distance of
each element in |
Returns
Type | Description |
---|---|
IEnumerable<BoundPeer> |
|