Class Kademlia
Commonly used constants and static functions for Kademlia distributed hash table.
Namespace: Libplanet.Net.Protocols
Assembly: Libplanet.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 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
| Type | Description |
|---|---|
| Address | Distance between two addresses in Address. |
CommonPrefixLength(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<BoundPeer> | peers | A sequence of values to order. |
| Address | targetAddr | Address to calculate distance of element. |
Returns
| Type | Description |
|---|---|
| IEnumerable<BoundPeer> |
|