Class Kademlia
Commonly used constants and static functions for Kademlia distributed hash table.
Inherited Members
Namespace: Libplanet.Net.Protocols
Assembly: Libplanet.dll
Syntax
public static class Kademlia
Fields
| Improve this Doc View SourceBucketSize
The size of a single bucket.
Declaration
public const int BucketSize = 16
Field Value
Type | Description |
---|---|
Int32 |
FindConcurrency
The number of concurrency in peer discovery.
Declaration
public const int FindConcurrency = 3
Field Value
Type | Description |
---|---|
Int32 |
MaxDepth
Depth of the peer discovery operation.
Declaration
public const int MaxDepth = 3
Field Value
Type | Description |
---|---|
Int32 |
TableSize
The number of buckets in the table.
Declaration
public const int TableSize = 160
Field Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceCalculateDistance(Address, Address)
Calculates xor distance between two address.
Declaration
public static Address CalculateDistance(Address left, Address right)
Parameters
Type | Name | Description |
---|---|---|
Address | left | First element to calculate distance. |
Address | right | Second element to calculate distance. |
Returns
| Improve this Doc View SourceCommonPrefixLength(Address, Address)
Calculates length of common prefix length by finding the index of first bit of xor value.
Declaration
public static int CommonPrefixLength(Address left, Address right)
Parameters
Type | Name | Description |
---|---|---|
Address | left | First element to calculate common prefix length. |
Address | right | Second element to calculate common prefix length. |
Returns
Type | Description |
---|---|
Int32 | Length of the common prefix length. |
SortByDistance(IEnumerable<BoundPeer>, Address)
Sorts the element of the sequence from in ascending order of
the distance with targetAddr
.
Declaration
public static IEnumerable<BoundPeer> SortByDistance(IEnumerable<BoundPeer> peers, Address targetAddr)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Bound |
peers | A sequence of values to order. |
Address | targetAddr | Address to calculate distance of element. |
Returns
Type | Description |
---|---|
IEnumerable<Bound |
|