Versions in this module Expand all Collapse all v1 v1.8.4 Mar 17, 2024 v1.8.3 Mar 13, 2024 v1.8.2 Mar 8, 2024 v1.7.12 Feb 23, 2024 Changes in this version + const ADD_CONTACT + const FIND_CONTACTS + const FIND_CONTACTS_STATUS_ERROR + const FIND_CONTACTS_STATUS_SUCCESS + const GET + const GET_STATUS_ERROR + const GET_STATUS_SUCCESS + const IDLength + const MAX_COUNT + const MSG_FIND_CONTACTS_REQ + const MSG_FIND_CONTACTS_RESP + const MSG_GET_REQ + const MSG_GET_RESP + const MSG_PING_REQ + const MSG_PING_RESP + const MSG_PUT_REQ + const MSG_PUT_RESP + const MaxPendingRequests + const PING_STATUS_ERROR + const PING_STATUS_SUCCESS + const PUT + const PUT_STATUS_ERROR + const PUT_STATUS_SUCCESS + const RegistrationReplicationFactor + const STOP + func ValidateKV(kv *KV) (bool, error) + type Contact struct + ID KademliaID + Node p2p.Node + func CreateContact(node p2p.Node, prvKey string) (Contact, error) + func (contact *Contact) CalcDistance(target KademliaID) + func (contact *Contact) Less(otherContact Contact) bool + func (contact *Contact) String() string + type ContactCandidates struct + func (candidates *ContactCandidates) Append(contacts []Contact) + func (candidates *ContactCandidates) GetContacts(count int) []Contact + func (candidates *ContactCandidates) Len() int + func (candidates *ContactCandidates) Less(i, j int) bool + func (candidates *ContactCandidates) Sort() + func (candidates *ContactCandidates) Swap(i, j int) + type DHT interface + FindContact func(kademliaID string, ctx context.Context) (Contact, error) + FindContacts func(kademliaID string, count int, ctx context.Context) ([]Contact, error) + Get func(id string, key string, replicationFactor int, ctx context.Context) ([]KV, error) + GetContact func() Contact + LookupNode func(id string, name string, ctx context.Context) (*p2p.Node, error) + Put func(id string, prvKey string, key string, value string, replicationFactor int, ...) error + RegisterNetwork func(bootstrapNode p2p.Node, kademliaID string, ctx context.Context) error + RegisterNetworkWithAddr func(bootstrapNodeAddr string, kademliaID string, ctx context.Context) error + RegisterNode func(id string, prvKey string, node *p2p.Node, ctx context.Context) error + Shutdown func() + func CreateDHT(port int, name string) (DHT, error) + type FindContactsReq struct + Count int + Header RPCHeader + KademliaID string + func ConvertJSONToFindContactsReq(jsonStr string) (*FindContactsReq, error) + func (req *FindContactsReq) ToJSON() (string, error) + type FindContactsResp struct + Contacts []Contact + Error string + Header RPCHeader + Status int + func ConvertJSONToFindContactsResp(jsonStr string) (*FindContactsResp, error) + func (resp *FindContactsResp) ToJSON() (string, error) + type GetReq struct + Header RPCHeader + Key string + func ConvertJSONToGetReq(jsonStr string) (*GetReq, error) + func (req *GetReq) ToJSON() (string, error) + type GetResp struct + Error string + Header RPCHeader + KVS []KV + Status int + func ConvertJSONToGetResp(jsonStr string) (*GetResp, error) + func (resp *GetResp) ToJSON() (string, error) + type KV struct + ID string + Key string + Sig string + Value string + func (kv *KV) String() string + type Kademlia struct + Contact Contact + func CreateKademlia(messenger p2p.Messenger, contact Contact) (*Kademlia, error) + func (k *Kademlia) FindContact(kademliaID string, ctx context.Context) (Contact, error) + func (k *Kademlia) FindContacts(kademliaID string, count int, ctx context.Context) ([]Contact, error) + func (k *Kademlia) Get(id string, key string, replicationFactor int, ctx context.Context) ([]KV, error) + func (k *Kademlia) GetContact() Contact + func (k *Kademlia) LookupNode(id string, name string, ctx context.Context) (*p2p.Node, error) + func (k *Kademlia) Put(id string, prvKey string, key string, value string, replicationFactor int, ...) error + func (k *Kademlia) RegisterNetwork(bootstrapNode p2p.Node, kademliaID string, ctx context.Context) error + func (k *Kademlia) RegisterNetworkWithAddr(bootstrapNodeAddr string, kademliaID string, ctx context.Context) error + func (k *Kademlia) RegisterNode(id string, prvKey string, node *p2p.Node, ctx context.Context) error + func (k *Kademlia) Shutdown() + type KademliaID [IDLength]byte + func CreateKademliaID(data string) KademliaID + func NewRandomKademliaID() KademliaID + func (kademliaID *KademliaID) String() string + func (kademliaID KademliaID) CalcDistance(target KademliaID) KademliaID + func (kademliaID KademliaID) Equals(otherKademliaID KademliaID) bool + func (kademliaID KademliaID) Less(otherKademliaID KademliaID) bool + type PingReq struct + Header RPCHeader + func ConvertJSONToPingReq(jsonStr string) (*PingReq, error) + func (req *PingReq) ToJSON() (string, error) + type PingResp struct + Error string + Header RPCHeader + Status int + func ConvertJSONToPingResp(jsonStr string) (*PingResp, error) + func (req *PingResp) ToJSON() (string, error) + type PutReq struct + Header RPCHeader + KV KV + func ConvertJSONToPutReq(jsonStr string) (*PutReq, error) + func (req *PutReq) ToJSON() (string, error) + type PutResp struct + Error string + Header RPCHeader + Status int + func ConvertJSONToPutResp(jsonStr string) (*PutResp, error) + func (resp *PutResp) ToJSON() (string, error) + type RPCHeader struct + Sender Contact