Show / Hide Table of Contents

Class RoutingTable

A wrapper around k-bucket, to provide easy store and retrival for peers.

Inheritance
Object
RoutingTable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: PeerTalk.Routing
Assembly: PeerTalk.dll
Syntax
public class RoutingTable

Constructors

| Improve this Doc View Source

RoutingTable(Peer)

Creates a new instance of the RoutingTable for the specified Peer.

Declaration
public RoutingTable(Peer localPeer)
Parameters
Type Name Description
Peer localPeer

Methods

| Improve this Doc View Source

Add(Peer)

Add some information about the peer.

Declaration
public void Add(Peer peer)
Parameters
Type Name Description
Peer peer
| Improve this Doc View Source

Contains(Peer)

Determines in the peer exists in the routing table.

Declaration
public bool Contains(Peer peer)
Parameters
Type Name Description
Peer peer
Returns
Type Description
Boolean
| Improve this Doc View Source

Key(MultiHash)

Converts the peer ID to a routing table key.

Declaration
public static byte[] Key(MultiHash id)
Parameters
Type Name Description
MultiHash id

A multihash

Returns
Type Description
Byte[]

The routing table key.

Remarks

The peer ID is actually a multihash, it always starts with the same characters (ie, Qm for rsa). This causes the distribution of hashes to be non-equally distributed across all possible hash buckets. So the re-hash into a non-multihash is to evenly distribute the potential keys and hash buckets.

See Also
https://github.com/libp2p/js-libp2p-kad-dht/issues/56#issuecomment-441378802
| Improve this Doc View Source

NearestPeers(MultiHash)

Find the closest peers to the peer ID.

Declaration
public IEnumerable<Peer> NearestPeers(MultiHash id)
Parameters
Type Name Description
MultiHash id
Returns
Type Description
IEnumerable<Peer>
| Improve this Doc View Source

Remove(Peer)

Remove the information about the peer.

Declaration
public void Remove(Peer peer)
Parameters
Type Name Description
Peer peer
  • Improve this Doc
  • View Source
Back to top Generated by DocFX