requestvalidation

package
v1.26.7 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLegacyRevalidator

func NewLegacyRevalidator(providerRevalidator *ProviderRevalidator) datatransfer.Revalidator

NewLegacyRevalidator adds a revalidator that will capture revalidation requests for the legacy protocol but won't double count data being sent TODO: the data transfer revalidator registration needs to be able to take multiple types to avoid double counting for data being sent.

Types

type ProviderRequestValidator

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

ProviderRequestValidator validates incoming requests for the Retrieval Provider

func NewProviderRequestValidator

func NewProviderRequestValidator(env ValidationEnvironment) *ProviderRequestValidator

NewProviderRequestValidator returns a new instance of the ProviderRequestValidator

func (*ProviderRequestValidator) Subscribe

func (*ProviderRequestValidator) ValidatePull

func (rv *ProviderRequestValidator) ValidatePull(isRestart bool, _ datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.VoucherResult, error)

ValidatePull validates a pull request received from the peer that will receive data

func (*ProviderRequestValidator) ValidatePush

func (rv *ProviderRequestValidator) ValidatePush(isRestart bool, _ datatransfer.ChannelID, sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.VoucherResult, error)

ValidatePush validates a push request received from the peer that will send data

type ProviderRevalidator

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

ProviderRevalidator defines data transfer revalidation logic in the context of a provider for a retrieval deal

func NewProviderRevalidator

func NewProviderRevalidator(env RevalidatorEnvironment) *ProviderRevalidator

NewProviderRevalidator returns a new instance of a ProviderRevalidator

func (*ProviderRevalidator) OnComplete

OnComplete is called to make a final request for revalidation -- often for the purpose of settlement. if VoucherResult is non nil, the request will enter a settlement phase awaiting a final update

func (*ProviderRevalidator) OnPullDataSent

func (pr *ProviderRevalidator) OnPullDataSent(chid datatransfer.ChannelID, additionalBytesSent uint64) (bool, datatransfer.VoucherResult, error)

OnPullDataSent is called on the responder side when more bytes are sent for a given pull request. It should return a VoucherResult + ErrPause to request revalidation or nil to continue uninterrupted, other errors will terminate the request

func (*ProviderRevalidator) OnPushDataReceived

func (pr *ProviderRevalidator) OnPushDataReceived(chid datatransfer.ChannelID, additionalBytesReceived uint64) (bool, datatransfer.VoucherResult, error)

OnPushDataReceived is called on the responder side when more bytes are received for a given push request. It should return a VoucherResult + ErrPause to request revalidation or nil to continue uninterrupted, other errors will terminate the request

func (*ProviderRevalidator) Revalidate

Revalidate revalidates a request with a new voucher

func (*ProviderRevalidator) TrackChannel

func (pr *ProviderRevalidator) TrackChannel(deal rm.ProviderDealState)

TrackChannel indicates a retrieval deal tracked by this provider. It associates a given channel ID with a retrieval deal, so that checks run for data sent on the channel

func (*ProviderRevalidator) UntrackChannel

func (pr *ProviderRevalidator) UntrackChannel(deal rm.ProviderDealState)

UntrackChannel indicates a retrieval deal is finish and no longer is tracked by this provider

type RevalidatorEnvironment

type RevalidatorEnvironment interface {
	Node() rm.RetrievalProviderNode
	SendEvent(dealID rm.ProviderDealIdentifier, evt rm.ProviderEvent, args ...interface{}) error
	Get(dealID rm.ProviderDealIdentifier) (rm.ProviderDealState, error)
}

RevalidatorEnvironment are the dependencies needed to build the logic of revalidation -- essentially, access to the node at statemachines

type ValidationEnvironment

type ValidationEnvironment interface {
	GetAsk(ctx context.Context, payloadCid cid.Cid, pieceCid *cid.Cid, piece piecestore.PieceInfo, isUnsealed bool, client peer.ID) (retrievalmarket.Ask, error)

	GetPiece(c cid.Cid, pieceCID *cid.Cid) (piecestore.PieceInfo, bool, error)
	// CheckDealParams verifies the given deal params are acceptable
	CheckDealParams(ask retrievalmarket.Ask, pricePerByte abi.TokenAmount, paymentInterval uint64, paymentIntervalIncrease uint64, unsealPrice abi.TokenAmount) error
	// RunDealDecisioningLogic runs custom deal decision logic to decide if a deal is accepted, if present
	RunDealDecisioningLogic(ctx context.Context, state retrievalmarket.ProviderDealState) (bool, string, error)
	// StateMachines returns the FSM Group to begin tracking with
	BeginTracking(pds retrievalmarket.ProviderDealState) error
}

ValidationEnvironment contains the dependencies needed to validate deals

Jump to

Keyboard shortcuts

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