client

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0, MIT Imports: 27 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultViews = []*view.View{
		durationView,
		requestsView,
	}
)

Functions

func ParseNodeAddresses added in v0.2.0

func ParseNodeAddresses(n *proto.Peer) peer.AddrInfo

ParseNodeAddresses parses peer node addresses from the protocol structure Peer.

func ToProtoPeer added in v0.4.0

func ToProtoPeer(ai peer.AddrInfo) *proto.Peer

ToProtoPeer creates a protocol Peer structure from address info.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.2.0

func NewClient(c proto.DelegatedRouting_Client, p *Provider, identity crypto.PrivKey) (*Client, error)

NewClient creates a client. The Provider and identity parameters are option. If they are nil, the `Provide` method will not function.

func (*Client) FindProviders

func (fp *Client) FindProviders(ctx context.Context, key cid.Cid) ([]peer.AddrInfo, error)

func (*Client) FindProvidersAsync

func (fp *Client) FindProvidersAsync(ctx context.Context, key cid.Cid) (<-chan FindProvidersAsyncResult, error)

FindProvidersAsync processes the stream of raw protocol async results into a stream of parsed results. Specifically, FindProvidersAsync converts protocol-level provider descriptions into peer address infos.

func (*Client) GetIPNS added in v0.2.0

func (fp *Client) GetIPNS(ctx context.Context, id []byte) ([]byte, error)

func (*Client) GetIPNSAsync added in v0.2.0

func (fp *Client) GetIPNSAsync(ctx context.Context, id []byte) (<-chan GetIPNSAsyncResult, error)

func (*Client) GetValue added in v0.2.1

func (c *Client) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)

GetValue searches for the value corresponding to given Key.

func (*Client) Provide added in v0.4.0

func (fp *Client) Provide(ctx context.Context, keys []cid.Cid, ttl time.Duration) (time.Duration, error)

func (*Client) ProvideAsync added in v0.4.0

func (fp *Client) ProvideAsync(ctx context.Context, keys []cid.Cid, ttl time.Duration) (<-chan time.Duration, error)

func (*Client) ProvideSignedRecord added in v0.4.0

func (fp *Client) ProvideSignedRecord(ctx context.Context, req *ProvideRequest) (<-chan ProvideAsyncResult, error)

ProvideAsync makes a provide request to a delegated router

func (*Client) PutIPNS added in v0.2.0

func (fp *Client) PutIPNS(ctx context.Context, id []byte, record []byte) error

func (*Client) PutIPNSAsync added in v0.2.0

func (fp *Client) PutIPNSAsync(ctx context.Context, id []byte, record []byte) (<-chan PutIPNSAsyncResult, error)

func (*Client) PutValue added in v0.2.1

func (c *Client) PutValue(ctx context.Context, key string, val []byte, opts ...routing.Option) error

PutValue adds value corresponding to given Key.

func (*Client) SearchValue added in v0.2.1

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

SearchValue searches for better and better values from this value store corresponding to the given Key. By default implementations must stop the search after a good value is found. A 'good' value is a value that would be returned from GetValue.

Useful when you want a result *now* but still want to hear about better/newer results.

Implementations of this methods won't return ErrNotFound. When a value couldn't be found, the channel will get closed without passing any results

type ContentRoutingClient added in v0.2.0

type ContentRoutingClient struct {
	// contains filtered or unexported fields
}

func NewContentRoutingClient added in v0.2.0

func NewContentRoutingClient(c DelegatedRoutingClient) *ContentRoutingClient

func (*ContentRoutingClient) FindProvidersAsync added in v0.2.0

func (c *ContentRoutingClient) FindProvidersAsync(ctx context.Context, key cid.Cid, numResults int) <-chan peer.AddrInfo

func (*ContentRoutingClient) Provide added in v0.2.0

func (c *ContentRoutingClient) Provide(ctx context.Context, key cid.Cid, announce bool) error

func (*ContentRoutingClient) ProvideMany added in v0.5.0

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

func (*ContentRoutingClient) Ready added in v0.5.0

func (c *ContentRoutingClient) Ready() bool

Ready is part of the existing `ProvideMany` interface, but can be used more generally to determine if the routing client has a working connection.

type DelegatedRoutingClient added in v0.2.0

type DelegatedRoutingClient interface {
	FindProviders(ctx context.Context, key cid.Cid) ([]peer.AddrInfo, error)
	FindProvidersAsync(ctx context.Context, key cid.Cid) (<-chan FindProvidersAsyncResult, error)
	GetIPNS(ctx context.Context, id []byte) ([]byte, error)
	GetIPNSAsync(ctx context.Context, id []byte) (<-chan GetIPNSAsyncResult, error)
	PutIPNS(ctx context.Context, id []byte, record []byte) error
	PutIPNSAsync(ctx context.Context, id []byte, record []byte) (<-chan PutIPNSAsyncResult, error)
	Provide(ctx context.Context, key []cid.Cid, ttl time.Duration) (time.Duration, error)
	ProvideAsync(ctx context.Context, key []cid.Cid, ttl time.Duration) (<-chan time.Duration, error)
}

type FindProvidersAsyncResult

type FindProvidersAsyncResult struct {
	AddrInfo []peer.AddrInfo
	Err      error
}

type GetIPNSAsyncResult added in v0.2.0

type GetIPNSAsyncResult struct {
	Record []byte
	Err    error
}

type GraphSyncFILv1 added in v0.4.0

type GraphSyncFILv1 struct {
	PieceCID      cid.Cid
	VerifiedDeal  bool
	FastRetrieval bool
}

GraphSyncFILv1 is the current filecoin storage provider protocol.

type ProvideAsyncResult added in v0.4.0

type ProvideAsyncResult struct {
	AdvisoryTTL time.Duration
	Err         error
}

type ProvideRequest added in v0.4.0

type ProvideRequest struct {
	Key []cid.Cid
	*Provider
	Timestamp   int64
	AdvisoryTTL time.Duration
	Signature   []byte
}

ProvideRequest is a message indicating a provider can provide a Key for a given TTL

func ParseProvideRequest added in v0.4.0

func ParseProvideRequest(req *proto.ProvideRequest) (*ProvideRequest, error)

func (*ProvideRequest) IsSigned added in v0.4.0

func (pr *ProvideRequest) IsSigned() bool

IsSigned indicates if the ProvideRequest has been signed

func (*ProvideRequest) Sign added in v0.4.0

func (pr *ProvideRequest) Sign(key crypto.PrivKey) error

Sign a provide request

func (*ProvideRequest) Verify added in v0.4.0

func (pr *ProvideRequest) Verify() error

type Provider added in v0.4.0

type Provider struct {
	Peer          peer.AddrInfo
	ProviderProto []TransferProtocol
}

Provider represents the source publishing one or more CIDs

func (*Provider) ToProto added in v0.4.0

func (p *Provider) ToProto() *proto.Provider

ToProto convers a provider into the wire proto form

type PutIPNSAsyncResult added in v0.2.0

type PutIPNSAsyncResult struct {
	Err error
}

type TransferProtocol added in v0.4.0

type TransferProtocol struct {
	Codec   multicodec.Code
	Payload []byte
}

TransferProtocol represents a data transfer protocol

func (*TransferProtocol) ToProto added in v0.4.0

func (tp *TransferProtocol) ToProto() proto.TransferProtocol

ToProto converts a TransferProtocol to the wire representation

Jump to

Keyboard shortcuts

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