Documentation
¶
Index ¶
- type FullRT
- func (dht *FullRT) Bootstrap(ctx context.Context) (err error)
- func (dht *FullRT) CheckPeers(ctx context.Context, peers ...peer.ID) (int, int)
- func (dht *FullRT) Close() error
- func (dht *FullRT) FindLocal(id peer.ID) peer.AddrInfo
- func (dht *FullRT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo, err error)
- func (dht *FullRT) FindProviders(ctx context.Context, c cid.Cid) ([]peer.AddrInfo, error)
- func (dht *FullRT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) (ch <-chan peer.AddrInfo)
- func (dht *FullRT) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error)
- func (dht *FullRT) GetValue(ctx context.Context, key string, opts ...routing.Option) (result []byte, err error)
- func (dht *FullRT) Host() host.Host
- func (dht *FullRT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err error)
- func (dht *FullRT) ProvideMany(ctx context.Context, keys []multihash.Multihash) (err error)
- func (dht *FullRT) PutMany(ctx context.Context, keys []string, values [][]byte) error
- func (dht *FullRT) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) (err error)
- func (dht *FullRT) Ready() bool
- func (dht *FullRT) SearchValue(ctx context.Context, key string, opts ...routing.Option) (ch <-chan []byte, err error)
- func (dht *FullRT) Stat() map[string]peer.ID
- func (dht *FullRT) TriggerRefresh(ctx context.Context) error
- type Option
- func DHTOption(opts ...kaddht.Option) Option
- func WithBulkSendParallelism(b int) Option
- func WithCrawlInterval(i time.Duration) Option
- func WithCrawler(c crawler.Crawler) Option
- func WithIPDiversityFilterLimit(ipDiversityFilterLimit int) Option
- func WithProviderManagerOptions(pmOpts ...providers.Option) Option
- func WithSuccessWaitFraction(f float64) Option
- func WithTimeoutPerOperation(t time.Duration) Option
- type RecvdVal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FullRT ¶
type FullRT struct {
Validator record.Validator
ProviderManager *providers.ProviderManager
// contains filtered or unexported fields
}
FullRT is an experimental DHT client that is under development. Expect breaking changes to occur in this client until it stabilizes.
Running FullRT by itself (i.e. without a companion IpfsDHT) will run into some issues. The most critical is that running a FullRT node will not currently keep you connected to the k closest peers which means that your peer's addresses may not be discoverable in the DHT. Additionally, FullRT is only a DHT client and not a server which means it does not contribute capacity to the network. If you want to run a server you should also run an IpfsDHT instance in server mode.
FullRT has a Ready function that indicates the routing table has been refreshed recently. It is currently within the discretion of the application as to how much they care about whether the routing table is ready. One approach taken to "readiness" is to not insist on it for ad-hoc operations but to insist on it for larger bulk operations.
func NewFullRT ¶
NewFullRT creates a DHT client that tracks the full network. It takes a protocol prefix for the given network, For example, the protocol /ipfs/kad/1.0.0 has the prefix /ipfs.
FullRT is an experimental DHT client that is under development. Expect breaking changes to occur in this client until it stabilizes.
Not all of the standard DHT options are supported in this DHT.
DHT options passed in should be suitable for your network (e.g. protocol prefix, validators, bucket size, and bootstrap peers).
func (*FullRT) CheckPeers ¶
CheckPeers return (success, total)
func (*FullRT) FindLocal ¶
FindLocal looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in.
func (*FullRT) FindProviders ¶
FindProviders searches until the context expires.
func (*FullRT) FindProvidersAsync ¶
func (dht *FullRT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) (ch <-chan peer.AddrInfo)
FindProvidersAsync is the same thing as FindProviders, but returns a channel. Peers will be returned on the channel as soon as they are found, even before the search query completes. If count is zero then the query will run until it completes. Note: not reading from the returned channel may block the query from progressing.
func (*FullRT) GetClosestPeers ¶
GetClosestPeers tries to return the `dht.bucketSize` closest known peers to the given key.
If the IP diversity filter limit is set, the returned peers will contain at most `dht.ipDiversityFilterLimit` peers sharing the same IP group. Hence, the peers may not be the absolute closest peers to the given key, but they will be more diverse in terms of IP addresses.
func (*FullRT) GetValue ¶
func (dht *FullRT) GetValue(ctx context.Context, key string, opts ...routing.Option) (result []byte, err error)
GetValue searches for the value corresponding to given Key.
func (*FullRT) Provide ¶
Provide makes this node announce that it can provide a value for the given key
func (*FullRT) ProvideMany ¶
func (*FullRT) PutValue ¶
func (dht *FullRT) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) (err error)
PutValue adds value corresponding to given Key. This is the top level "Store" operation of the DHT
func (*FullRT) Ready ¶
Ready indicates that the routing table has been refreshed recently. It is recommended to be used for operations where it is important for the operation to be particularly accurate (e.g. bulk publishing where you do not want to republish for as long as you can).
type Option ¶
type Option func(opt *config) error
func WithBulkSendParallelism ¶
WithBulkSendParallelism sets the maximum degree of parallelism at which messages are sent to other peers. It must be at least 1. Defaults to 20 if unspecified.
func WithCrawlInterval ¶
WithCrawlInterval sets the interval at which the DHT is crawled to refresh peer store. Defaults to 1 hour if unspecified.
func WithCrawler ¶
WithCrawler sets the crawler.Crawler to use in order to crawl the DHT network. Defaults to crawler.DefaultCrawler with parallelism of 200.
func WithIPDiversityFilterLimit ¶
WithIPDiversityFilterLimit sets the maximum number of peers with addresses in the same IP group returned by GetClosestPeers.
func WithProviderManagerOptions ¶
WithProviderManagerOptions sets the options to use when instantiating providers.ProviderManager.
func WithSuccessWaitFraction ¶
WithSuccessWaitFraction sets the fraction of peers to wait for before considering an operation a success defined as a number between (0, 1]. Defaults to 30% if unspecified.
func WithTimeoutPerOperation ¶
WithTimeoutPerOperation sets the timeout per operation, where operations include putting providers and querying the DHT. Defaults to 5 seconds if unspecified.