Show / Hide Table of Contents

Class Kademlia

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

Inheritance
Object
Kademlia
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 static class Kademlia

Fields

| Improve this Doc View Source

BucketSize

The size of a single bucket.

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

FindConcurrency

The number of concurrency in peer discovery.

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

MaxDepth

Depth of the peer discovery operation.

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

TableSize

The number of buckets in the table.

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

Methods

| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

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>

An IEnumerable<T> whose elements are sorted according to the distance with targetAddr.

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