retrievalmarketconnector

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0, MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const MaxInt = int(^uint(0) >> 1)

MaxInt is the max value of an Int

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainReaderAPI

type ChainReaderAPI interface {
	// GetBalance gets the balance in AttoFIL for a given address
	Head() block.TipSetKey
	GetTipSet(key block.TipSetKey) (block.TipSet, error)
	GetActorAt(ctx context.Context, tipKey block.TipSetKey, addr address.Address) (*actor.Actor, error)
}

ChainReaderAPI is the subset of the Wallet interface needed by the retrieval client node

type PaychMgrAPI

type PaychMgrAPI interface {
	AllocateLane(paychAddr address.Address) (uint64, error)
	ChannelExists(paychAddr address.Address) (bool, error)
	GetMinerWorkerAddress(ctx context.Context, miner address.Address, tok shared.TipSetToken) (address.Address, error)
	GetPaymentChannelInfo(paychAddr address.Address) (*paymentchannel.ChannelInfo, error)
	GetPaymentChannelByAccounts(payer, payee address.Address) (*paymentchannel.ChannelInfo, error)
	CreatePaymentChannel(payer, payee address.Address, amt abi.TokenAmount) (address.Address, cid.Cid, error)
	AddFundsToChannel(paychAddr address.Address, amt abi.TokenAmount) (cid.Cid, error)
	AddVoucherToChannel(paychAddr address.Address, voucher *paychActor.SignedVoucher) error
	AddVoucher(paychAddr address.Address, voucher *paychActor.SignedVoucher, proof []byte, expected big.Int, tok shared.TipSetToken) (abi.TokenAmount, error)
	WaitForCreatePaychMessage(ctx context.Context, mcid cid.Cid) (address.Address, error)
	WaitForAddFundsMessage(ctx context.Context, mcid cid.Cid) error
}

PaychMgrAPI is an API used for communicating with payment channel actor and store.

type RetrievalClientConnector

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

RetrievalClientConnector is the glue between go-filecoin and go-fil-markets' retrieval market interface

func NewRetrievalClientConnector

func NewRetrievalClientConnector(
	bs blockstore.Blockstore,
	cs ChainReaderAPI,
	signer RetrievalSigner,
	paychMgr PaychMgrAPI,
) *RetrievalClientConnector

NewRetrievalClientConnector creates a new RetrievalClientConnector

func (*RetrievalClientConnector) AllocateLane

func (r *RetrievalClientConnector) AllocateLane(paymentChannel address.Address) (lane uint64, err error)

AllocateLane creates a new lane for this paymentChannel with 0 FIL in the lane Assumes AllocateLane is called after GetOrCreatePaymentChannel

func (*RetrievalClientConnector) CreatePaymentVoucher

func (r *RetrievalClientConnector) CreatePaymentVoucher(ctx context.Context, paychAddr address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paychActor.SignedVoucher, error)

CreatePaymentVoucher creates a payment voucher for the retrieval client.

func (*RetrievalClientConnector) GetChainHead

func (*RetrievalClientConnector) GetOrCreatePaymentChannel

func (r *RetrievalClientConnector) GetOrCreatePaymentChannel(ctx context.Context, clientAddress address.Address, minerAddress address.Address, clientFundsAvailable abi.TokenAmount, tok shared.TipSetToken) (address.Address, cid.Cid, error)

GetOrCreatePaymentChannel gets or creates a payment channel and posts to chain

func (*RetrievalClientConnector) WaitForPaymentChannelAddFunds

func (r *RetrievalClientConnector) WaitForPaymentChannelAddFunds(messageCID cid.Cid) error

func (*RetrievalClientConnector) WaitForPaymentChannelCreation

func (r *RetrievalClientConnector) WaitForPaymentChannelCreation(messageCID cid.Cid) (address.Address, error)

type RetrievalMarketClientFakeAPI

type RetrievalMarketClientFakeAPI struct {
	AllocateLaneErr error

	PayChBalanceErr error

	CreatePaymentChannelErr error
	WorkerAddr              address.Address
	WorkerAddrErr           error
	Nonce                   uint64
	NonceErr                error

	Sig    crypto.Signature
	SigErr error

	MsgSendCid cid.Cid
	MsgSendErr error

	SendNewVoucherErr error
	ExpectedVouchers  map[address.Address]*paymentchannel.VoucherInfo
	ActualVouchers    map[address.Address]bool

	ExpectedSectorIDs map[uint64]string
	ActualSectorIDs   map[uint64]bool
	UnsealErr         error
	// contains filtered or unexported fields
}

RetrievalMarketClientFakeAPI is a test API that satisfies all needed interface methods for a RetrievalMarketClient

func NewRetrievalMarketClientFakeAPI

func NewRetrievalMarketClientFakeAPI(t *testing.T) *RetrievalMarketClientFakeAPI

NewRetrievalMarketClientFakeAPI creates an instance of a test API that satisfies all needed interface methods for a RetrievalMarketClient.

func (*RetrievalMarketClientFakeAPI) ChannelExists

func (rmFake *RetrievalMarketClientFakeAPI) ChannelExists(_ address.Address) (bool, error)

func (*RetrievalMarketClientFakeAPI) NextNonce

func (rmFake *RetrievalMarketClientFakeAPI) NextNonce(_ context.Context, _ address.Address) (uint64, error)

-------------- API METHODS NextNonce mocks getting an actor's next nonce

func (*RetrievalMarketClientFakeAPI) SignBytes

func (rmFake *RetrievalMarketClientFakeAPI) SignBytes(_ context.Context, _ []byte, _ address.Address) (crypto.Signature, error)

SignBytes mocks signing data

func (*RetrievalMarketClientFakeAPI) StubSignature

func (rmFake *RetrievalMarketClientFakeAPI) StubSignature(sigError error)

StubMessageResponse sets up a message, message receipt and return value for a create payment channel message

func (*RetrievalMarketClientFakeAPI) UnsealSector

func (rmFake *RetrievalMarketClientFakeAPI) UnsealSector(_ context.Context, sectorID uint64) (io.ReadCloser, error)

UnsealSector mocks unsealing. Assign a filename to ExpectedSectorIDs[sectorID] to test

type RetrievalProviderConnector

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

RetrievalProviderConnector is the glue between go-filecoin and retrieval market provider API

func NewRetrievalProviderConnector

func NewRetrievalProviderConnector(net rmnet.RetrievalMarketNetwork, us UnsealerAPI,
	bs blockstore.Blockstore, paychMgr PaychMgrAPI, chainReader ChainReaderAPI) *RetrievalProviderConnector

NewRetrievalProviderConnector creates a new RetrievalProviderConnector

func (*RetrievalProviderConnector) GetChainHead

func (*RetrievalProviderConnector) GetMinerWorkerAddress

func (r *RetrievalProviderConnector) GetMinerWorkerAddress(ctx context.Context, miner address.Address, tok shared.TipSetToken) (address.Address, error)

GetMinerWorkerAddress produces the worker address for the provided storage miner address from the tipset for the provided token.

func (*RetrievalProviderConnector) SavePaymentVoucher

func (r *RetrievalProviderConnector) SavePaymentVoucher(_ context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expected abi.TokenAmount, tok shared.TipSetToken) (actual abi.TokenAmount, err error)

SavePaymentVoucher stores the provided payment voucher. Returns the difference between voucher amount and largest previous voucher amount, and error if this amount is less than `expected` amount

func (*RetrievalProviderConnector) UnsealSector

func (r *RetrievalProviderConnector) UnsealSector(ctx context.Context, sectorID uint64,
	offset uint64, length uint64) (io.ReadCloser, error)

UnsealSector unseals the sector given by sectorId and offset with length `length` It rejects offsets > int size and length > int64 size; the interface wants uint64s. This would return a bufio overflow error anyway, but the check is provided as a debugging convenience for the consumer of this function.

type RetrievalSigner

type RetrievalSigner interface {
	SignBytes(ctx context.Context, data []byte, addr address.Address) (crypto.Signature, error)
}

RetrievalSigner is an interface with the ability to sign data

type UnsealerAPI

type UnsealerAPI interface {
	UnsealSector(ctx context.Context, sectorID uint64) (io.ReadCloser, error)
}

UnsealerAPI is the API required for unsealing a sectorgi

Jump to

Keyboard shortcuts

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