offerproto

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryOfferProtocol = "/fcr-calibr/cidnet/offer/query"
	ProtocolVersion    = "/0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OfferProtocol

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

OfferProtocol manages offer protocol. It handles piece offer creation.

func NewOfferProtocol

func NewOfferProtocol(
	h host.Host,
	dht *dual.DHT,
	addrProto *addrproto.AddrProtocol,
	signer crypto.Signer,
	peerMgr peermgr.PeerManager,
	offerMgr offermgr.OfferManager,
	pieceMgr piecemgr.PieceManager,
	cservMgr cservmgr.PieceServingManager,
	mps mpstore.MinerProofStore,
	opts Opts,
) *OfferProtocol

NewOfferProtocol creates a new offer protocol.

@input - host, dht, addr protocol, signer, peer manager, offer manager, piece manager,

piece serving manager, miner proof store, options.

@output - offer protocol.

func (*OfferProtocol) FindOffersAsync

func (p *OfferProtocol) FindOffersAsync(ctx context.Context, currencyID byte, id cid.Cid, max int) <-chan fcroffer.PieceOffer

FindOffersAsync tries to find offers for given cid and given currency.

@input - context, currency id, piece cid, max offers required.

@output - offer chan out.

func (*OfferProtocol) Publish

func (p *OfferProtocol) Publish(ctx context.Context) error

Publish offers to the network immediately.

@input - context.

@output - error.

func (*OfferProtocol) QueryOffer

func (proto *OfferProtocol) QueryOffer(ctx context.Context, currencyID byte, toAddr string, root cid.Cid) (fcroffer.PieceOffer, error)

QueryOffer queries for a piece offer for a given cid, currency id and peer id.

@input - context, piece cid, currency id, peer id.

@output - piece offer, error.

func (*OfferProtocol) Shutdown

func (p *OfferProtocol) Shutdown()

Shutdown safely shuts down the component.

type Opts

type Opts struct {
	// The timeout for every network io operation.
	IOTimeout time.Duration

	// The timeout for every internal operation.
	OpTimeout time.Duration

	// The offer expiry time.
	OfferExpiry time.Duration

	// The renew window.
	OfferInactivity time.Duration

	// The publish frequency.
	PublishFreq time.Duration
}

Opts is the options for offer protocol.

Jump to

Keyboard shortcuts

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