types

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProductTypePDP uint8 = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	ProofSetAPI
	PieceAPI
	ProviderAPI
}

type AllocatedPiece

type AllocatedPiece struct {
	Allocated bool
	Piece     multihash.Multihash
	UploadID  uuid.UUID
}

func (AllocatedPiece) MarshalLogObject

func (a AllocatedPiece) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for AllocatedPiece

type CalculateCommPResponse added in v0.0.18

type CalculateCommPResponse struct {
	PieceCID   cid.Cid
	RawSize    int64
	PaddedSize int64
}

type Error

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

Error represents a service error with a kind

func NewError

func NewError(kind Kind, msg string) *Error

NewError creates a new error with the given kind and message

func NewErrorf

func NewErrorf(kind Kind, msg string, args ...interface{}) *Error

func WrapError

func WrapError(kind Kind, msg string, err error) *Error

WrapError wraps an existing error with a kind and message

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

func (*Error) Kind

func (e *Error) Kind() Kind

Kind returns the error kind

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error

type GetProviderStatusResults added in v0.0.17

type GetProviderStatusResults struct {
	// ID of provider (0 if not registered)
	ID uint64
	// address of the provider
	Address common.Address
	// address the provider will receive payment on
	Payee common.Address
	// True if the provider is registered in the registry
	IsRegistered bool
	// True if the provider is active
	IsActive bool
	// Optional name chosen by provider
	Name string
	// Optional description chosen by provider
	Description string
	// Registration status: "not_registered", "pending", or "registered"
	RegistrationStatus string
	// True if contract operator approved provider to operate
	IsApproved bool
}

type Kind

type Kind int

Kind represents the category of error

const (
	KindOther Kind = iota
	KindNotFound
	KindInvalidInput
	KindUnauthorized
	KindInternal
	KindConflict
)

type ParkPieceRequest added in v0.0.18

type ParkPieceRequest struct {
	Blob       multihash.Multihash
	PieceCID   cid.Cid
	RawSize    int64
	PaddedSize int64
}

type Piece

type Piece struct {
	// Name of the hash function used
	// sha2-256-trunc254-padded - CommP
	// sha2-256 - Blob sha256
	Name string

	// hex encoded hash
	Hash multihash.Multihash

	// Size of the piece in bytes
	Size int64
}

func (Piece) MarshalLogObject

func (p Piece) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for Piece

type PieceAPI

type PieceAPI interface {
	PieceReaderAPI
	PieceResolverAPI
	PieceWriterAPI
	PieceCommPAPI

	// ParkPiece persists a record of a commp cid to the database
	ParkPiece(ctx context.Context, params ParkPieceRequest) error

	// WritePieceURL returns the URL an allocated blob may be uploaded to.
	WritePieceURL(blob uuid.UUID) (url.URL, error)
	// ReadPieceURL returns the URL a blob may be retrieved from.
	ReadPieceURL(blob cid.Cid) (url.URL, error)
}

type PieceAllocation

type PieceAllocation struct {
	Piece  Piece
	Notify *url.URL
}

func (PieceAllocation) MarshalLogObject

func (p PieceAllocation) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for PieceAllocation

type PieceCommPAPI added in v0.0.18

type PieceCommPAPI interface {
	// CalculateCommP accepts a blob multihash and returns a result containing its commp CID, raw and padded size.
	CalculateCommP(ctx context.Context, blob multihash.Multihash) (CalculateCommPResponse, error)
}

type PieceReader

type PieceReader struct {
	// Size is the total size of the piece
	Size int64
	Data io.ReadCloser
}

func (PieceReader) MarshalLogObject

func (p PieceReader) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for PieceReader

type PieceReaderAPI added in v0.0.18

type PieceReaderAPI interface {
	// Read returns a `PieceReader` for the provided `data` multihash. An error is returned if the value doesn't exist,
	// of if reading from the store fails. `ReadPieceOption`s may be provided for range queries and resolution before read.
	// Read expects `data` to be the multihash the data was uploaded with. If callers provide a commP multihash to Read
	// they must also provide a resolver method for the operation to succeed, this will almost always be the ResoleToBlob
	// resolver.
	Read(ctx context.Context, data multihash.Multihash, options ...ReadPieceOption) (*PieceReader, error)
	// Has returns true if the provided `data` multihash is present in the store, false otherwise
	Has(ctx context.Context, blob multihash.Multihash) (bool, error)
}

type PieceResolverAPI added in v0.0.18

type PieceResolverAPI interface {
	// Resolve accepts any multihash and attempts to resolve it to its corresponding hash.
	// For example, if the provided hash is a commp multihash the blob hash will be returned.
	// if the provided hash is not a commp multihash the commp hash will be returned.
	// false if returned if data doesn't exist.
	Resolve(ctx context.Context, data multihash.Multihash) (multihash.Multihash, bool, error)
	// ResolveToPiece accepts a non-commp multihash and returns the commp multihash it corresponds to.
	// If the multihash doesn't exist false is returned without an error.
	ResolveToPiece(ctx context.Context, blob multihash.Multihash) (multihash.Multihash, bool, error)
	// ResolveToBlob accepts a commp multihash and returns the blob multihash it corresponds to.
	// If the commp multihash doesn't exist false is returned without an error.
	ResolveToBlob(ctx context.Context, piece multihash.Multihash) (multihash.Multihash, bool, error)
}

type PieceUpload

type PieceUpload struct {
	ID   uuid.UUID
	Data io.Reader
}

func (PieceUpload) MarshalLogObject

func (p PieceUpload) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for PieceUpload

type PieceWriterAPI added in v0.0.18

type PieceWriterAPI interface {
	AllocatePiece(ctx context.Context, allocation PieceAllocation) (*AllocatedPiece, error)
	UploadPiece(ctx context.Context, upload PieceUpload) error
}

type ProofSet

type ProofSet struct {
	ID                     uint64
	Initialized            bool
	NextChallengeEpoch     int64
	PreviousChallengeEpoch int64
	ProvingPeriod          int64
	ChallengeWindow        int64
	Roots                  []RootEntry
}

func (ProofSet) MarshalLogObject

func (p ProofSet) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for ProofSet

type ProofSetAPI

type ProofSetAPI interface {
	CreateProofSet(ctx context.Context) (common.Hash, error)
	GetProofSetStatus(ctx context.Context, txHash common.Hash) (*ProofSetStatus, error)
	GetProofSet(ctx context.Context, proofSetID uint64) (*ProofSet, error)
	AddRoots(ctx context.Context, proofSetID uint64, roots []RootAdd) (common.Hash, error)
	RemoveRoot(ctx context.Context, proofSetID uint64, rootID uint64) (common.Hash, error)
}

type ProofSetContractState added in v0.0.15

type ProofSetContractState struct {
	// owners of the proof set
	Owners []common.Address
	// The start of the NEXT OPEN proving period's challenge window
	NextChallengeWindowStart uint64
	// the epoch of the next challenge
	NextChallengeEpoch uint64
	// Max number of epochs between two consecutive proofs
	MaxProvingPeriod uint64
	// challengeWindow Number of epochs for the challenge window
	ChallengeWindow uint64
	//index of the most recently added leaf that is challengeable in the current proving period
	ChallengeRange uint64
	// piece ids of the pieces scheduled for removal at the start of the next proving period
	ScheduledRemovals []uint64
	// estimated cost of submitting a proof
	ProofFee uint64
	// estimated cost of submitting a proof with buffer applied
	ProofFeeBuffered uint64
}

type ProofSetIDProvider added in v0.0.18

type ProofSetIDProvider interface {
	ProofSetID(ctx context.Context) (uint64, error)
}

type ProofSetState added in v0.0.15

type ProofSetState struct {
	ID uint64
	// if the proof set has been initialized with a root, and is expecting proofs to be submitted.
	Initialized bool
	// When the next challenge for a proof will be issued
	NextChallengeEpoch int64
	// When the last challenge for a proof was issued
	PreviousChallengeEpoch int64
	// The proving period of this proof set
	ProvingPeriod int64
	// The challenge window of this proof set
	ChallengeWindow int64
	// The current epoch of the chain
	CurrentEpoch int64
	// true if a challenge has been issued: CurrentEpoch >= NextChallengeEpoch
	ChallengedIssued bool
	// true if in challenge window: CurrentEpoch < NextChallengeEpoch + ChallengeWindow
	InChallengeWindow bool
	// true if we missed the challenge: CurrentEpoch > NextChallengeEpoch + ChallengeWindow
	IsInFaultState bool
	// true if we submitted a proof for the current ChallengeWindow
	HasProven bool
	// true if the node is currently generating a proof
	IsProving bool

	// The state of the proof set present in the contract
	ContractState ProofSetContractState
}

type ProofSetStatus

type ProofSetStatus struct {
	TxHash   common.Hash
	TxStatus string
	Created  bool
	ID       uint64
}

func (ProofSetStatus) MarshalLogObject

func (p ProofSetStatus) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for ProofSetStatus

type ProviderAPI added in v0.0.17

type ProviderAPI interface {
	RegisterProvider(ctx context.Context, params RegisterProviderParams) (RegisterProviderResults, error)
	GetProviderStatus(ctx context.Context) (GetProviderStatusResults, error)
}

type Range added in v0.0.14

type Range struct {
	// Start is the byte to start extracting from (inclusive).
	Start uint64
	// End is the byte to stop extracting at (inclusive).
	End *uint64
}

type ReadPieceConfig added in v0.0.14

type ReadPieceConfig struct {
	ByteRange Range
}

func (*ReadPieceConfig) ProcessOptions added in v0.0.14

func (c *ReadPieceConfig) ProcessOptions(opts []ReadPieceOption)

type ReadPieceOption added in v0.0.14

type ReadPieceOption func(c *ReadPieceConfig)

func WithRange added in v0.0.14

func WithRange(start uint64, end *uint64) ReadPieceOption

type RegisterProviderParams added in v0.0.17

type RegisterProviderParams struct {
	Name        string
	Description string
}

type RegisterProviderResults added in v0.0.17

type RegisterProviderResults struct {
	// transaction hash of message sent by provider to register, when set all
	// other fields are empty
	TransactionHash common.Hash
	// address of the provider
	Address common.Address
	// address the provider will receive payment on
	Payee common.Address
	// ID of provider
	ID uint64
	// True if the provider is registered (don't imply they have been approved
	// the service contract.
	IsActive bool
	// Optional name chosen by provider
	Name string
	// Optional description chosen by provider
	Description string
}

type RootAdd

type RootAdd struct {
	Root     cid.Cid
	SubRoots []cid.Cid
}

func (RootAdd) MarshalLogObject

func (r RootAdd) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for RootAdd

type RootEntry

type RootEntry struct {
	RootID        uint64
	RootCID       cid.Cid
	SubrootCID    cid.Cid
	SubrootOffset int64
}

func (RootEntry) MarshalLogObject

func (r RootEntry) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler for RootEntry

Jump to

Keyboard shortcuts

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