Documentation ¶
Overview ¶
Package kadt contains the kademlia types for interacting with go-libdht.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddrInfo ¶
AddrInfo is a type that wraps peer.AddrInfo and implements the kad.NodeInfo interface. This means we can use AddrInfo for any operation that interfaces with go-libdht.
A more accurate name would be PeerInfo or NodeInfo. However, for consistency and coherence with peer.AddrInfo we also name it AddrInfo.
func (AddrInfo) ID ¶
ID returns the kad.NodeID of this peer's information struct.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is a type alias for the type of key that's used with this DHT implementation. In the Amino DHT, we are sending around the preimage of the actual key that's used for calculating Kademlia distance. That's why this Key struct also holds the preimage bytes.
func NewKey ¶
NewKey initializes a new key struct based on the given preimage bytes. These bytes are SHA256 hashed and stored as the actual Kademlia key that's used to calculate distances in the XOR keyspace.
func (Key) CommonPrefixLength ¶
func (Key) HexString ¶
HexString returns a string containing the hexadecimal representation of the key.
type PeerID ¶
PeerID is a type alias for peer.ID that implements the kad.NodeID interface. This means we can use PeerID for any operation that interfaces with go-libdht.
type RoutingTable ¶
type RoutingTable interface { kad.RoutingTable[Key, PeerID] // Cpl returns the longest common prefix length the supplied key shares with the table's key. Cpl(kk Key) int // CplSize returns the number of nodes in the table whose longest common prefix with the table's key is of length cpl. CplSize(cpl int) int }
RoutingTable is a mapping between Key and PeerID and provides methods to interact with the mapping and find PeerIDs close to a particular Key.