Class RoutingTable
A wrapper around k-bucket, to provide easy store and retrival for peers.
Inherited Members
Namespace: PeerTalk.Routing
Assembly: PeerTalk.dll
Syntax
public class RoutingTable
Constructors
| Improve this Doc View SourceRoutingTable(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 SourceAdd(Peer)
Add some information about the peer.
Declaration
public void Add(Peer peer)
Parameters
Type | Name | Description |
---|---|---|
Peer | peer |
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 |
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
| Improve this Doc View SourceNearestPeers(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> |
Remove(Peer)
Remove the information about the peer.
Declaration
public void Remove(Peer peer)
Parameters
Type | Name | Description |
---|---|---|
Peer | peer |