Show / Hide Table of Contents

Class Kademlia

Commonly used constants and static functions for Kademlia distributed hash table.

Inheritance
Object
Kademlia
Namespace: Libplanet.Net.Protocols
Assembly: Libplanet.Net.dll
Syntax
public static class Kademlia : object

Fields

| Improve this Doc View Source

BucketSize

The size of a single bucket.

Declaration
public const int BucketSize = null
Field Value
Type Description
Int32
| Improve this Doc View Source

FindConcurrency

The number of concurrency in peer discovery.

Declaration
public const int FindConcurrency = null
Field Value
Type Description
Int32
| Improve this Doc View Source

MaxDepth

Depth of the peer discovery operation.

Declaration
public const int MaxDepth = null
Field Value
Type Description
Int32
| Improve this Doc View Source

TableSize

The number of buckets in the table.

Declaration
public const int TableSize = null
Field Value
Type Description
Int32

Methods

| Improve this Doc View Source

CalculateDifference(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 left and right.

| Improve this Doc View Source

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 of BoundPeers to sort.

Address target

The Address to calculate the distance of each element in peers.

Returns
Type Description
IEnumerable<BoundPeer>

An whose elements are sorted according to the distance with target.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2022 Planetarium