common

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0, MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const AcceptServiceActorABI = `` /* 130-byte string literal not displayed */
View Source
const CancelClientWithdrawalABI = `` /* 139-byte string literal not displayed */
View Source
const CancelServiceWithdrawalABI = `` /* 140-byte string literal not displayed */
View Source
const CompleteClientWithdrawalABI = `` /* 141-byte string literal not displayed */
View Source
const CompleteServiceWithdrawalABI = `` /* 142-byte string literal not displayed */
View Source
const CreateClientVoucherABI = `` /* 410-byte string literal not displayed */
View Source
const CreateProviderVoucherABI = `` /* 414-byte string literal not displayed */
View Source
const DepositABI = `[
	{
	  "inputs": [],
	  "name": "deposit",
	  "outputs": [],
	  "stateMutability": "payable",
	  "type": "function"
	}
]`
View Source
const GetClientStateABI = `` /* 587-byte string literal not displayed */
View Source
const GetProviderStateABI = `` /* 358-byte string literal not displayed */
View Source
const GetServiceStateABI = `` /* 691-byte string literal not displayed */
View Source
const InitiateClientWithdrawalABI = `` /* 212-byte string literal not displayed */
View Source
const InitiateServiceWithdrawalABI = `` /* 213-byte string literal not displayed */
View Source
const ProposeServiceActorABI = `` /* 211-byte string literal not displayed */
View Source
const RedeemClientVoucherABI = `` /* 417-byte string literal not displayed */
View Source
const RedeemProviderVoucherABI = `` /* 421-byte string literal not displayed */
View Source
const RouterMainnet = "0xFf34254F6d017503B5f1E444339042AB6A3E4323"

RouterMainnet is the Ethereum form of the router address. This is just an example.

View Source
const ServiceDepositABI = `` /* 128-byte string literal not displayed */
View Source
const ValidateClientVoucherABI = `` /* 480-byte string literal not displayed */
View Source
const ValidateProviderVoucherABI = `` /* 484-byte string literal not displayed */
View Source
const WithdrawWindow = 4 * time.Hour

Variables

View Source
var MaxPrice = types.FromFil(1)
View Source
var PriceResolution = types.NewInt(1_000_000_000) // 1nFIL

Functions

func Router

func Router() address.Address

Router returns the Filecoin address of the router.

func ToFilBig

func ToFilBig(x *big.Int) fbig.Int

ToFilBig converts a standard library *big.Int to a filecoin-project big.Int

func WithMaxFee

func WithMaxFee(maxFee abi.TokenAmount) evmMsgOpt

Types

type BlockHeader

type BlockHeader struct {
	Version uint64

	Parent BlockLink
	Height uint64
	L1Base types.TipSetKey

	OpType OpType

	PaymentCumulative abi.TokenAmount
	PaymentNonce      uint64
	PaymentSignature  []byte

	Provider *address.Address
	Client   *address.Address

	Metadata string

	Validator address.Address
	Signature *crypto.Signature
}

func (*BlockHeader) Cid

func (blk *BlockHeader) Cid() cid.Cid

func (*BlockHeader) MarshalCBOR

func (t *BlockHeader) MarshalCBOR(w io.Writer) error

func (*BlockHeader) Serialize

func (blk *BlockHeader) Serialize() ([]byte, error)

func (*BlockHeader) SigningBytes

func (blk *BlockHeader) SigningBytes() ([]byte, error)

func (*BlockHeader) ToStorageBlock

func (blk *BlockHeader) ToStorageBlock() (block.Block, error)

func (*BlockHeader) UnmarshalCBOR

func (t *BlockHeader) UnmarshalCBOR(r io.Reader) (err error)
type BlockLink = *genadt.CborLink[*BlockHeader]

type ClientState

type ClientState struct {
	Balance           fbig.Int
	VoucherRedeemed   fbig.Int
	LastNonce         uint64
	WithdrawAmount    fbig.Int
	WithdrawTimestamp fbig.Int
}

type ClientVoucher

type ClientVoucher struct {
	ClientID         uint64
	CumulativeAmount *big.Int
	Nonce            uint64
	Signature        []byte
}

ClientVoucher ...

type OpType

type OpType uint64
const (
	OpTypeUnknown OpType = iota
	OpTypeProofOrder
	OpTypeMatch
	OpTypeProofReward
	OpTypeDeassign
	OpTypePow
	OpTypePowComplete
)

type ProofData

type ProofData struct {
	SectorID *abi.SectorID

	// proof request enum
	PoRep *proof.Commit1OutRaw

	Snap *proof.Snap
}

func (*ProofData) CheckOutput

func (p *ProofData) CheckOutput(pb []byte) error

func (*ProofData) DeciCost

func (p *ProofData) DeciCost() int

func (*ProofData) Type

func (p *ProofData) Type() string

func (*ProofData) Validate

func (p *ProofData) Validate() error

type ProofRequest

type ProofRequest struct {
	Data cid.Cid `json:"data"`

	PaymentClientID         int64           `json:"payment_client_id"`
	PaymentNonce            int64           `json:"payment_nonce"`
	PaymentCumulativeAmount abi.TokenAmount `json:"payment_cumulative_amount"`
	PaymentSignature        []byte          `json:"payment_signature"`
}

type ProofResponse

type ProofResponse struct {
	ID    string `json:"id"`
	Proof []byte `json:"proof"`
	Error string `json:"error"`
}

type ProofReward

type ProofReward struct {
	Status string `json:"status"`
	PoW    bool   `json:"pow"`

	Nonce            uint64          `json:"nonce"`
	Amount           abi.TokenAmount `json:"amount"`
	CumulativeAmount abi.TokenAmount `json:"cumulative_amount"`
	Signature        []byte          `json:"signature"`
}

type ProviderVoucher

type ProviderVoucher struct {
	ProviderID       uint64
	CumulativeAmount *big.Int
	Nonce            uint64
	Signature        []byte
}

ProviderVoucher ...

type Service

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

func NewService

func NewService(full api.FullNode) *Service

func NewServiceCustomSend

func NewServiceCustomSend(full api.FullNode, sendMessage func(ctx context.Context, msg *types.Message, mss *api.MessageSendSpec) (cid.Cid, error)) *Service

func (*Service) AcceptServiceActor

func (s *Service) AcceptServiceActor(ctx context.Context, from address.Address) error

func (*Service) ClientCancelWithdrawal

func (s *Service) ClientCancelWithdrawal(ctx context.Context, from address.Address) (cid.Cid, error)

func (*Service) ClientCompleteWithdrawal

func (s *Service) ClientCompleteWithdrawal(ctx context.Context, from address.Address) (cid.Cid, error)

func (*Service) ClientDeposit

func (s *Service) ClientDeposit(
	ctx context.Context,
	from address.Address,
	amount fbig.Int,
) (cid.Cid, error)

ClientDeposit calls `deposit()` with a pay value = the deposit amount in attoFIL and returns the deposit cid

func (*Service) ClientInitiateWithdrawal

func (s *Service) ClientInitiateWithdrawal(ctx context.Context, from address.Address, amount abi.TokenAmount) (cid.Cid, error)

func (*Service) CreateClientVoucher

func (s *Service) CreateClientVoucher(ctx context.Context, clientID uint64, cumulativeAmount *big.Int, nonce uint64) ([]byte, error)

func (*Service) CreateProviderVoucher

func (s *Service) CreateProviderVoucher(ctx context.Context, providerID uint64, cumulativeAmount *big.Int, nonce uint64) ([]byte, error)

func (*Service) GetClientState

func (s *Service) GetClientState(ctx context.Context, clientID uint64) (*ClientState, error)

func (*Service) GetProviderState

func (s *Service) GetProviderState(ctx context.Context, providerID uint64) (fbig.Int, uint64, error)

func (*Service) GetServiceState

func (s *Service) GetServiceState(ctx context.Context) (uint64, fbig.Int, fbig.Int, fbig.Int, uint64, fbig.Int, error)

func (*Service) ProposeServiceActor

func (s *Service) ProposeServiceActor(ctx context.Context, from address.Address, newServiceActor address.Address) error

func (*Service) ServiceCancelWithdrawal

func (s *Service) ServiceCancelWithdrawal(ctx context.Context, from address.Address) error

func (*Service) ServiceCompleteWithdrawal

func (s *Service) ServiceCompleteWithdrawal(ctx context.Context, from address.Address) error

func (*Service) ServiceDeposit

func (s *Service) ServiceDeposit(ctx context.Context, from address.Address, amount fbig.Int) error

func (*Service) ServiceInitiateWithdrawal

func (s *Service) ServiceInitiateWithdrawal(ctx context.Context, from address.Address, amount fbig.Int) error

func (*Service) ServiceRedeemClientVoucher

func (s *Service) ServiceRedeemClientVoucher(
	ctx context.Context,
	from address.Address,
	clientID uint64,
	cumulativeAmount fbig.Int,
	nonce uint64,
	sig []byte,
	opts ...evmMsgOpt,
) (cid.Cid, error)

ServiceRedeemClientVoucher calls `redeemClientVoucher(clientID, cumulativeAmount, nonce, signature)`.

func (*Service) ServiceRedeemProviderVoucher

func (s *Service) ServiceRedeemProviderVoucher(
	ctx context.Context,
	from address.Address,
	providerID uint64,
	cumulativeAmount fbig.Int,
	nonce uint64,
	sig []byte,
) (cid.Cid, error)

ServiceRedeemProviderVoucher calls `redeemProviderVoucher(providerID, cumulativeAmount, nonce, signature)`.

func (*Service) ValidateClientVoucher

func (s *Service) ValidateClientVoucher(ctx context.Context, clientID uint64, cumulativeAmount *big.Int, nonce uint64, signature []byte) (bool, error)

func (*Service) ValidateProviderVoucher

func (s *Service) ValidateProviderVoucher(ctx context.Context, providerID uint64, cumulativeAmount *big.Int, nonce uint64, signature []byte) (bool, error)

func (*Service) VerifyVoucherUpdate

func (s *Service) VerifyVoucherUpdate(best, proposed *ClientVoucher) (*big.Int, error)

type WorkAsk

type WorkAsk struct {
	ID           int64     `json:"id"`
	MinPriceNfil int64     `json:"min_price_nfil"`
	CreatedAt    time.Time `json:"created_at"`

	// ui-only
	MinPriceFil string `json:"min_price_fil"`
}

type WorkRequest

type WorkRequest struct {
	ID int64 `json:"id" db:"id"`

	RequestCid *string `json:"request_cid" db:"request_cid"` // CID of the ProofData
	Done       *bool   `json:"done" db:"done"`

	WorkAskID int64 `json:"work_ask_id" db:"work_ask_id"`
}

type WorkResponse

type WorkResponse struct {
	Requests   []WorkRequest `json:"requests"`
	ActiveAsks []WorkAsk     `json:"active_asks"`
}

Jump to

Keyboard shortcuts

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