Documentation ¶
Overview ¶
Package requestvalidation implements a request validator for the data transfer module to validate data transfer requests for storage deals
Index ¶
- Constants
- Variables
- func ValidatePull(deals PullDeals, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, ...) error
- func ValidatePush(deals PushDeals, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, ...) error
- type PullDeals
- type PushDeals
- type StorageDataTransferVoucher
- type UnifiedRequestValidator
- func (v *UnifiedRequestValidator) SetPullDeals(pullDeals PullDeals)
- func (v *UnifiedRequestValidator) SetPushDeals(pushDeals PushDeals)
- func (v *UnifiedRequestValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, ...) (datatransfer.ValidationResult, error)
- func (v *UnifiedRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, ...) (datatransfer.ValidationResult, error)
- func (v *UnifiedRequestValidator) ValidateRestart(chid datatransfer.ChannelID, channelState datatransfer.ChannelState) (datatransfer.ValidationResult, error)
Constants ¶
const StorageDataTransferVoucherType = datatransfer.TypeIdentifier("StorageDataTransferVoucher")
StorageDataTransferVoucherType is the unique string identifier for a StorageDataTransferVoucher
Variables ¶
var ( // ErrWrongVoucherType means the voucher was not the correct type can validate against ErrWrongVoucherType = errors.New("cannot validate voucher type") // ErrNoPushAccepted just means clients do not accept pushes for storage deals ErrNoPushAccepted = errors.New("client should not receive data for a storage deal") // ErrNoPullAccepted just means providers do not accept pulls for storage deals ErrNoPullAccepted = errors.New("provider should not send data for a storage deal") // ErrNoDeal means no active deal was found for this vouchers proposal cid ErrNoDeal = errors.New("no deal found for this proposal") // ErrWrongPeer means that the other peer for this data transfer request does not match // the other peer for the deal ErrWrongPeer = errors.New("data Transfer peer id and Deal peer id do not match") // ErrWrongPiece means that the pieceref for this data transfer request does not match // the one specified in the deal ErrWrongPiece = errors.New("base CID for deal does not match CID for piece") // ErrInacceptableDealState means the deal for this transfer is not in a deal state // where transfer can be performed ErrInacceptableDealState = errors.New("deal is not in a state where deals are accepted") // DataTransferStates are the states in which it would make sense to actually start a data transfer // We accept deals even in the StorageDealTransferring state too as we could also also receive a data transfer restart request DataTransferStates = []storagemarket.StorageDealStatus{storagemarket.StorageDealValidating, storagemarket.StorageDealWaitingForData, storagemarket.StorageDealUnknown, storagemarket.StorageDealTransferring, storagemarket.StorageDealProviderTransferAwaitRestart} )
var BindnodeRegistry = bindnoderegistry.NewRegistry()
Functions ¶
func ValidatePull ¶
func ValidatePull( deals PullDeals, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, Selector datamodel.Node) error
ValidatePull validates a pull request received from the peer that will receive data Will succeed only if: - voucher has correct type - voucher references an active deal - referenced deal matches the given base CID - referenced deal is in an acceptable state
func ValidatePush ¶
func ValidatePush( deals PushDeals, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, Selector datamodel.Node) error
ValidatePush validates a push request received from the peer that will send data Will succeed only if: - voucher has correct type - voucher references an active deal - referenced deal matches the given base CID - referenced deal is in an acceptable state
Types ¶
type PullDeals ¶
type PullDeals interface {
Get(cid.Cid) (storagemarket.ClientDeal, error)
}
PullDeals gets deal states for Pull validations
type PushDeals ¶
type PushDeals interface {
Get(cid.Cid) (storagemarket.MinerDeal, error)
}
PushDeals gets deal states for Push validations
type StorageDataTransferVoucher ¶
type StorageDataTransferVoucher struct {
Proposal cid.Cid
}
StorageDataTransferVoucher is the voucher type for data transfers used by the storage market
func (*StorageDataTransferVoucher) MarshalCBOR ¶
func (t *StorageDataTransferVoucher) MarshalCBOR(w io.Writer) error
func (*StorageDataTransferVoucher) UnmarshalCBOR ¶
func (t *StorageDataTransferVoucher) UnmarshalCBOR(r io.Reader) (err error)
type UnifiedRequestValidator ¶
type UnifiedRequestValidator struct {
// contains filtered or unexported fields
}
UnifiedRequestValidator is a data transfer request validator that validates StorageDataTransferVoucher from the given state store It can be made to only accept push requests (Provider) or pull requests (Client) by passing nil for the statestore value for pushes or pulls
func NewUnifiedRequestValidator ¶
func NewUnifiedRequestValidator(pushDeals PushDeals, pullDeals PullDeals) *UnifiedRequestValidator
NewUnifiedRequestValidator returns a new instance of UnifiedRequestValidator
func (*UnifiedRequestValidator) SetPullDeals ¶
func (v *UnifiedRequestValidator) SetPullDeals(pullDeals PullDeals)
SetPullDeals sets the store to look up pull deals with
func (*UnifiedRequestValidator) SetPushDeals ¶
func (v *UnifiedRequestValidator) SetPushDeals(pushDeals PushDeals)
SetPushDeals sets the store to look up push deals with
func (*UnifiedRequestValidator) ValidatePull ¶
func (v *UnifiedRequestValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error)
ValidatePull implements the ValidatePull method of a data transfer request validator. If no pullStore exists, it rejects the request Otherwise, it calls the ValidatePull function to validate the deal
func (*UnifiedRequestValidator) ValidatePush ¶
func (v *UnifiedRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error)
ValidatePush implements the ValidatePush method of a data transfer request validator. If no pushStore exists, it rejects the request Otherwise, it calls the ValidatePush function to validate the deal
func (*UnifiedRequestValidator) ValidateRestart ¶
func (v *UnifiedRequestValidator) ValidateRestart(chid datatransfer.ChannelID, channelState datatransfer.ChannelState) (datatransfer.ValidationResult, error)