Documentation ¶
Index ¶
- Variables
- type ContentRouting
- type DistributedHashTable
- type Kademlia
- func (kad *Kademlia) FindPeerAtDistance(context context.Context, target []byte, _ int) ([]address.PeerAddressInfo, error)
- func (kad *Kademlia) FindPeersClosest(ctx context.Context, targetId []byte, k int) ([]address.PeerAddressInfo, error)
- func (kad *Kademlia) FindProvider(context context.Context, key []byte) (chan address.PeerAddressInfo, error)
- func (kad *Kademlia) Get(key []byte) ([]byte, error)
- func (kad *Kademlia) GetKnownPeers() []address.PeerAddressInfo
- func (kad *Kademlia) GetSelf() address.PeerAddressInfo
- func (kad *Kademlia) Provide(context context.Context, key []byte) error
- func (kad *Kademlia) Put(key []byte, value []byte) error
- func (kad *Kademlia) Start(bootNodes []string)
- func (kad *Kademlia) Stop()
- type KeyValueStore
- type PeerRouting
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrAllWireMessagesFailed = errors.New("all wire protocol messages failed")
)
Functions ¶
This section is empty.
Types ¶
type ContentRouting ¶
type ContentRouting interface { // Provide announces that the given dht host // can provide for the current key. // Record TTL is defined by ProviderRecordTTL Provide(context context.Context, key []byte) error // FindProvider finds the provider record // for the given key. // Will be continuing until the records are found // or the context expires. FindProvider(context context.Context, key []byte) (chan address.PeerAddressInfo, error) }
ContentRouting - Basic Functionalities for Content Routing Such as Adding and finding providers for a given key
type DistributedHashTable ¶
type DistributedHashTable interface { PeerRouting ContentRouting KeyValueStore // Start the host with the boot nodes. Start([]string) GetKnownPeers() []address.PeerAddressInfo GetSelf() address.PeerAddressInfo Stop() }
DistributedHashTable DHT interface, which embeds all the functionality of PeerRouting, ContentRouting and a KeyValueStore
func NewKademliaHost ¶
func NewKademliaHost(host string, port int32) DistributedHashTable
type Kademlia ¶
type Kademlia struct { SelfAddrInfo address.PeerAddressInfo // The AddrInfo of the kademlia node SelfAddrSerialized string // The Addr Info in Serialized format. RoutingController *routing.Controller // The PeerRouting Controller responsible for peer routing functions ProviderRecordStore *prstore.ProviderStore // The ContentRouting Controller responsible for content routing functions ValueStore *vstore.ValueStore // The ValueStore Controller responsible for the KV store functions. RoutingTable *routingtable.RoutingTable // The Node table/Routing table/kBucket impl WireMessengerServer *network.Server // The server for responding to wire messages LiveCheckTask *tasks.LiveCheckTask // The Live check worker ProtocolMessenger *network.ProtocolMessenger // The protocol Messenger }
func (*Kademlia) FindPeerAtDistance ¶
func (*Kademlia) FindPeersClosest ¶
func (*Kademlia) FindProvider ¶
func (*Kademlia) GetKnownPeers ¶
func (kad *Kademlia) GetKnownPeers() []address.PeerAddressInfo
func (*Kademlia) GetSelf ¶
func (kad *Kademlia) GetSelf() address.PeerAddressInfo
type KeyValueStore ¶
type KeyValueStore interface { // Put - Adds the pair to KV store // TTL is defined by KeyValueStoreTTL Put(key []byte, value []byte) error // Get the value for a key Get(key []byte) ([]byte, error) }
KeyValueStore - Functionalities for a decentralized Key value store.
type PeerRouting ¶
type PeerRouting interface { // FindPeerAtDistance Finds peer at a specified distance from targetId // if a negative distance is specified, all peers are returned. // usage of context is self explanatory FindPeerAtDistance(context context.Context, target []byte, distance int) ([]address.PeerAddressInfo, error) // FindPeersClosest Find k most closest peers to the target Id. FindPeersClosest(ctx context.Context, targetId []byte, k int) ([]address.PeerAddressInfo, error) }
PeerRouting - Basic Functions for discovering peer nodes.
Click to show internal directories.
Click to hide internal directories.