fullrt

package
v0.0.0-...-0765461 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 40 Imported by: 0

Documentation

Index

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.

func NewFullRT

func NewFullRT(h host.Host, protocolPrefix protocol.ID, options ...Option) (*FullRT, error)

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.

func (*FullRT) Bootstrap

func (dht *FullRT) Bootstrap(ctx context.Context) error

func (*FullRT) CheckPeers

func (dht *FullRT) CheckPeers(ctx context.Context, peers ...peer.ID) (int, int)

CheckPeers return (success, total)

func (*FullRT) Close

func (dht *FullRT) Close() error

func (*FullRT) FindLocal

func (dht *FullRT) FindLocal(id peer.ID) peer.AddrInfo

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) FindPeer

func (dht *FullRT) FindPeer(ctx context.Context, id peer.ID) (_ peer.AddrInfo, err error)

FindPeer searches for a peer with given ID.

func (*FullRT) FindProviders

func (dht *FullRT) FindProviders(ctx context.Context, c cid.Cid) ([]peer.AddrInfo, error)

FindProviders searches until the context expires.

func (*FullRT) FindProvidersAsync

func (dht *FullRT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-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

func (dht *FullRT) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error)

func (*FullRT) GetValue

func (dht *FullRT) GetValue(ctx context.Context, key string, opts ...routing.Option) (_ []byte, err error)

GetValue searches for the value corresponding to given Key.

func (*FullRT) Host

func (dht *FullRT) Host() host.Host

func (*FullRT) Provide

func (dht *FullRT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err error)

Provide makes this node announce that it can provide a value for the given key

func (*FullRT) ProvideMany

func (dht *FullRT) ProvideMany(ctx context.Context, keys []multihash.Multihash) error

func (*FullRT) PutMany

func (dht *FullRT) PutMany(ctx context.Context, keys []string, values [][]byte) error

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

func (dht *FullRT) Ready() bool

func (*FullRT) SearchValue

func (dht *FullRT) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)

SearchValue searches for the value corresponding to given Key and streams the results.

func (*FullRT) Stat

func (dht *FullRT) Stat() map[string]peer.ID

func (*FullRT) TriggerRefresh

func (dht *FullRT) TriggerRefresh(ctx context.Context) error

type Option

type Option func(opt *config) error

func DHTOption

func DHTOption(opts ...kaddht.Option) Option

func WithBulkSendParallelism

func WithBulkSendParallelism(b int) Option

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

func WithCrawlInterval(i time.Duration) Option

WithCrawlInterval sets the interval at which the DHT is crawled to refresh peer store. Defaults to 1 hour if unspecified.

func WithCrawler

func WithCrawler(c crawler.Crawler) Option

WithCrawler sets the crawler.Crawler to use in order to crawl the DHT network. Defaults to crawler.DefaultCrawler with parallelism of 200.

func WithProviderManagerOptions

func WithProviderManagerOptions(pmOpts ...providers.Option) Option

WithProviderManagerOptions sets the options to use when instantiating providers.ProviderManager.

func WithSuccessWaitFraction

func WithSuccessWaitFraction(f float64) Option

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

func WithTimeoutPerOperation(t time.Duration) Option

WithTimeoutPerOperation sets the timeout per operation, where operations include putting providers and querying the DHT. Defaults to 5 seconds if unspecified.

type RecvdVal

type RecvdVal struct {
	Val  []byte
	From peer.ID
}

RecvdVal stores a value and the peer from which we got the value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL