provider

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPaymentInterval = uint64(1 << 20)

DefaultPaymentInterval is the baseline interval, set to 1Mb if the miner does not explicitly set it otherwise

View Source
var DefaultPaymentIntervalIncrease = uint64(1 << 20)

DefaultPaymentIntervalIncrease is the amount interval increases on each payment, set to to 1Mb if the miner does not explicitly set it otherwise

View Source
var DefaultPricePerByte = abi.NewTokenAmount(2)

DefaultPricePerByte is the charge per byte retrieved if the miner does not specifically set it

View Source
var ErrConnectFailed = errors.New("cannot connect to any provided multiaddrs")

ErrConnectFailed is returned when a provider is unable to connect using any of the client's multiaddrs

View Source
var ErrNoAddrsProvided = errors.New("no client multiaddrs provided")

ErrNoAddrsProvided is returned when a client message is received that has no client multiaddrs.

Functions

This section is empty.

Types

type Network

type Network interface {
	Start() error
	Stop() error
	Messages() <-chan []byte
	MultiAddrs() []string
	Connect(p peer.AddrInfo) error
	Send(context.Context, core.ProtocolID, peer.ID, []byte) error
	PeerID() peer.ID
}

Network defines the libp2p network interface used by the Provider

type Provider

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

Provider ...

func NewProvider

func NewProvider(net Network, s RetrievalProviderStore, cache RequestCache) *Provider

NewProvider returns a new Provider

func (*Provider) SetPaymentInterval

func (p *Provider) SetPaymentInterval(interval, increase uint64)

SetPaymentInterval sets the provider's paymentInterval and paymentIntervalIncrease

func (*Provider) SetPricePerByte

func (p *Provider) SetPricePerByte(price abi.TokenAmount)

SetPricePerByte sets the provider's pricePerByte

func (*Provider) Start

func (p *Provider) Start() error

Start starts the provider

func (*Provider) Stop

func (p *Provider) Stop() error

Stop stops the provider

func (*Provider) SubscribeToQueries

func (p *Provider) SubscribeToQueries(s ProviderSubscriber) Unsubscribe

SubscribeToQueries registers the given subscriber and calls it upon receiving queries

type ProviderSubscriber

type ProviderSubscriber func(query shared.Query)

type RequestCache

type RequestCache interface {
	// Put adds the cid to the cache or updates it if it already exists
	Put(cid.Cid)

	// Keys returns all the keys in the cache
	Keys() []cid.Cid

	// GetRecord returns the Record for the given cid
	GetRecord(cid.Cid) *cache.Record
}

RequestCache is the interface for the provider's cache of requests

type RetrievalProviderStore

type RetrievalProviderStore interface {
	Has(params shared.Params) (bool, error)
}

type Unsubscribe

type Unsubscribe func()

Jump to

Keyboard shortcuts

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