Versions in this module Expand all Collapse all v0 v0.1.0 Dec 19, 2023 Changes in this version + const DefaultPrefix + var DefaultBootstrapPeers []multiaddr.Multiaddr + var DefaultProtocols = []protocol.ID + var ErrNoPeersQueried = errors.New("failed to query any peers") + var ErrReadTimeout = net.ErrReadTimeout + var LookupEventBufferSize = 16 + var ProtocolDHT protocol.ID = "/dep2p/kad/1.0.0" + func GetDefaultBootstrapPeerAddrInfos() []peer.AddrInfo + func NewRTPeerDiversityFilter(h host.Host, maxPerCpl, maxForTable int) *rtPeerIPGroupFilter + func PrivateQueryFilter(_ interface{}, ai peer.AddrInfo) bool + func PrivateRoutingTableFilter(dht interface{}, p peer.ID) bool + func PublicQueryFilter(_ interface{}, ai peer.AddrInfo) bool + func PublicRoutingTableFilter(dht interface{}, p peer.ID) bool + func PublishLookupEvent(ctx context.Context, ev *LookupEvent) + func Quorum(n int) routing.Option + func RegisterForLookupEvents(ctx context.Context) (context.Context, <-chan *LookupEvent) + type DeP2PDHT struct + Validator record.Validator + func New(ctx context.Context, h host.Host, options ...Option) (*DeP2PDHT, error) + func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *DeP2PDHT + func NewDHTClient(ctx context.Context, h host.Host, dstore ds.Batching) *DeP2PDHT + func (dht *DeP2PDHT) Bootstrap(ctx context.Context) (err error) + func (dht *DeP2PDHT) Close() error + func (dht *DeP2PDHT) Context() context.Context + func (dht *DeP2PDHT) FindLocal(ctx context.Context, id peer.ID) peer.AddrInfo + func (dht *DeP2PDHT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo, err error) + func (dht *DeP2PDHT) FindProviders(ctx context.Context, c cid.Cid) ([]peer.AddrInfo, error) + func (dht *DeP2PDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) (ch <-chan peer.AddrInfo) + func (dht *DeP2PDHT) ForceRefresh() <-chan error + func (dht *DeP2PDHT) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error) + func (dht *DeP2PDHT) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error) + func (dht *DeP2PDHT) GetRoutingTableDiversityStats() []peerdiversity.CplDiversityStats + func (dht *DeP2PDHT) GetValue(ctx context.Context, key string, opts ...routing.Option) (result []byte, err error) + func (dht *DeP2PDHT) Host() host.Host + func (dht *DeP2PDHT) Mode() ModeOpt + func (dht *DeP2PDHT) NetworkSize() (int32, error) + func (dht *DeP2PDHT) PeerID() peer.ID + func (dht *DeP2PDHT) PeerKey() []byte + func (dht *DeP2PDHT) Ping(ctx context.Context, p peer.ID) error + func (dht *DeP2PDHT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err error) + func (dht *DeP2PDHT) ProviderStore() providers.ProviderStore + func (dht *DeP2PDHT) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) (err error) + func (dht *DeP2PDHT) RefreshRoutingTable() <-chan error + func (dht *DeP2PDHT) RoutingTable() *kb.RoutingTable + func (dht *DeP2PDHT) SearchValue(ctx context.Context, key string, opts ...routing.Option) (ch <-chan []byte, err error) + type KeyKadID struct + Kad kbucket.ID + Key string + func NewKeyKadID(k string) *KeyKadID + type LookupEvent struct + ID uuid.UUID + Key *KeyKadID + Node *PeerKadID + Request *LookupUpdateEvent + Response *LookupUpdateEvent + Terminate *LookupTerminateEvent + func NewLookupEvent(node peer.ID, id uuid.UUID, key string, request *LookupUpdateEvent, ...) *LookupEvent + type LookupTerminateEvent struct + Reason LookupTerminationReason + func NewLookupTerminateEvent(reason LookupTerminationReason) *LookupTerminateEvent + type LookupTerminationReason int + const LookupCancelled + const LookupCompleted + const LookupStarvation + const LookupStopped + func (r LookupTerminationReason) MarshalJSON() ([]byte, error) + func (r LookupTerminationReason) String() string + type LookupUpdateEvent struct + Cause *PeerKadID + Heard []*PeerKadID + Queried []*PeerKadID + Source *PeerKadID + Unreachable []*PeerKadID + Waiting []*PeerKadID + func NewLookupUpdateEvent(cause peer.ID, source peer.ID, heard []peer.ID, waiting []peer.ID, ...) *LookupUpdateEvent + type ModeOpt = dhtcfg.ModeOpt + const ModeAuto + const ModeAutoServer + const ModeClient + const ModeServer + type Option = dhtcfg.Option + func AddressFilter(f func([]ma.Multiaddr) []ma.Multiaddr) Option + func BootstrapPeers(bootstrappers ...peer.AddrInfo) Option + func BootstrapPeersFunc(getBootstrapPeers func() []peer.AddrInfo) Option + func BucketSize(bucketSize int) Option + func Concurrency(alpha int) Option + func Datastore(ds ds.Batching) Option + func DisableAutoRefresh() Option + func DisableProviders() Option + func DisableValues() Option + func EnableOptimisticProvide() Option + func LookupCheckConcurrency(n int) Option + func MaxRecordAge(maxAge time.Duration) Option + func Mode(m ModeOpt) Option + func NamespacedValidator(ns string, v record.Validator) Option + func OptimisticProvideJobsPoolSize(size int) Option + func ProtocolExtension(ext protocol.ID) Option + func ProtocolPrefix(prefix protocol.ID) Option + func ProviderStore(ps providers.ProviderStore) Option + func QueryFilter(filter QueryFilterFunc) Option + func Resiliency(beta int) Option + func RoutingTableFilter(filter RouteTableFilterFunc) Option + func RoutingTableLatencyTolerance(latency time.Duration) Option + func RoutingTablePeerDiversityFilter(pg peerdiversity.PeerIPGroupFilter) Option + func RoutingTableRefreshPeriod(period time.Duration) Option + func RoutingTableRefreshQueryTimeout(timeout time.Duration) Option + func V1ProtocolOverride(proto protocol.ID) Option + func Validator(v record.Validator) Option + type PeerKadID struct + Kad kbucket.ID + Peer peer.ID + func NewPeerKadID(p peer.ID) *PeerKadID + func NewPeerKadIDSlice(p []peer.ID) []*PeerKadID + func OptPeerKadID(p peer.ID) *PeerKadID + type QueryFilterFunc = dhtcfg.QueryFilterFunc + type RouteTableFilterFunc = dhtcfg.RouteTableFilterFunc