Documentation
¶
Index ¶
- Constants
- Variables
- func SizeStr(bi BigInt) string
- type API
- type APIEndpoint
- type Actor
- type ActorState
- type BeaconEntry
- type BigInt
- type BlockHeader
- func (blk *BlockHeader) Cid() cid.Cid
- func (blk *BlockHeader) LastTicket() *Ticket
- func (t *BlockHeader) MarshalCBOR(w io.Writer) error
- func (blk *BlockHeader) Serialize() ([]byte, error)
- func (blk *BlockHeader) ToStorageBlock() (block.Block, error)
- func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error
- type DealCollateralBounds
- type ElectionProof
- type ExecutionTrace
- type ExpTipSet
- type FIL
- type GasTrace
- type InvocResult
- type Loc
- type LotusAPI
- func (a *LotusAPI) ChainGetMessage(ctx context.Context, c cid.Cid) (*Message, error)
- func (a *LotusAPI) ChainHead(ctx context.Context) (*TipSet, error)
- func (a *LotusAPI) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error)
- func (a *LotusAPI) Close()
- func (a *LotusAPI) GasEstimateMessageGas(ctx context.Context, m *Message, mss *MessageSendSpec, tsk TipSetKey) (*Message, error)
- func (a *LotusAPI) MpoolPush(ctx context.Context, sm *SignedMessage) (cid.Cid, error)
- func (a *LotusAPI) StateAccountKey(ctx context.Context, addr address.Address, tsk TipSetKey) (address.Address, error)
- func (a *LotusAPI) StateCall(ctx context.Context, msg *Message, tsk TipSetKey) (*InvocResult, error)
- func (a *LotusAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk TipSetKey) (DealCollateralBounds, error)
- func (a *LotusAPI) StateGetActor(ctx context.Context, addr address.Address, tsk TipSetKey) (*Actor, error)
- func (a *LotusAPI) StateLookupID(ctx context.Context, addr address.Address, tsk TipSetKey) (address.Address, error)
- func (a *LotusAPI) StateMarketBalance(ctx context.Context, addr address.Address, tsk TipSetKey) (MarketBalance, error)
- func (a *LotusAPI) StateMinerInfo(ctx context.Context, addr address.Address, tsk TipSetKey) (MinerInfo, error)
- func (a *LotusAPI) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk TipSetKey) (*dline.Info, error)
- func (a *LotusAPI) StateNetworkVersion(ctx context.Context, tsk TipSetKey) (network.Version, error)
- func (a *LotusAPI) StateReadState(ctx context.Context, addr address.Address, tsk TipSetKey) (*ActorState, error)
- func (a *LotusAPI) StateSearchMsg(ctx context.Context, c cid.Cid) (*MsgLookup, error)
- func (a *LotusAPI) StateWaitMsg(ctx context.Context, c cid.Cid, conf uint64) (*MsgLookup, error)
- type MarketBalance
- type Message
- func (m *Message) Caller() address.Address
- func (m *Message) Cid() cid.Cid
- func (t *Message) MarshalCBOR(w io.Writer) error
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) Receiver() address.Address
- func (m *Message) Serialize() ([]byte, error)
- func (m *Message) ToStorageBlock() (block.Block, error)
- func (t *Message) UnmarshalCBOR(r io.Reader) error
- func (m *Message) ValueReceived() abi.TokenAmount
- type MessageReceipt
- type MessageSendSpec
- type MinerInfo
- type MockLotusAPI
- func (m *MockLotusAPI) ChainGetMessage(ctx context.Context, c cid.Cid) (*Message, error)
- func (m *MockLotusAPI) ChainHead(context.Context) (*TipSet, error)
- func (m *MockLotusAPI) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error)
- func (m *MockLotusAPI) Close()
- func (m *MockLotusAPI) GasEstimateMessageGas(ctx context.Context, msg *Message, spec *MessageSendSpec, tsk TipSetKey) (*Message, error)
- func (m *MockLotusAPI) MpoolPush(ctx context.Context, smsg *SignedMessage) (cid.Cid, error)
- func (m *MockLotusAPI) SetAccountKey(addr address.Address, key address.Address)
- func (m *MockLotusAPI) SetActor(act *Actor)
- func (m *MockLotusAPI) SetActorState(state *ActorState)
- func (m *MockLotusAPI) SetInvocResult(i *InvocResult)
- func (m *MockLotusAPI) SetMsgLookup(lkp *MsgLookup)
- func (m *MockLotusAPI) SetObject(obj []byte)
- func (m *MockLotusAPI) SetObjectReader(r func(cid.Cid) []byte)
- func (m *MockLotusAPI) StateAccountKey(ctx context.Context, addr address.Address, tsk TipSetKey) (address.Address, error)
- func (m *MockLotusAPI) StateCall(ctx context.Context, msg *Message, tsk TipSetKey) (*InvocResult, error)
- func (m *MockLotusAPI) StateDealProviderCollateralBounds(ctx context.Context, s abi.PaddedPieceSize, b bool, tsk TipSetKey) (DealCollateralBounds, error)
- func (m *MockLotusAPI) StateGetActor(ctx context.Context, addr address.Address, tsk TipSetKey) (*Actor, error)
- func (m *MockLotusAPI) StateLookupID(ctx context.Context, addr address.Address, tsk TipSetKey) (address.Address, error)
- func (m *MockLotusAPI) StateMarketBalance(ctx context.Context, addr address.Address, tsk TipSetKey) (MarketBalance, error)
- func (m *MockLotusAPI) StateMinerInfo(ctx context.Context, addr address.Address, tsk TipSetKey) (MinerInfo, error)
- func (m *MockLotusAPI) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk TipSetKey) (*dline.Info, error)
- func (m *MockLotusAPI) StateNetworkVersion(ctx context.Context, tsk TipSetKey) (network.Version, error)
- func (m *MockLotusAPI) StateReadState(ctx context.Context, addr address.Address, tsk TipSetKey) (*ActorState, error)
- func (m *MockLotusAPI) StateSearchMsg(ctx context.Context, c cid.Cid) (*MsgLookup, error)
- func (m *MockLotusAPI) StateWaitMsg(ctx context.Context, c cid.Cid, conf uint64) (*MsgLookup, error)
- type MsgGasCost
- type MsgLookup
- type RawMessage
- type RawSignedMessage
- type SignedMessage
- func (sm *SignedMessage) Cid() cid.Cid
- func (t *SignedMessage) MarshalCBOR(w io.Writer) error
- func (sm *SignedMessage) MarshalJSON() ([]byte, error)
- func (sm *SignedMessage) Serialize() ([]byte, error)
- func (sm *SignedMessage) ToStorageBlock() (block.Block, error)
- func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error
- type Ticket
- type TipSet
- type TipSetKey
Constants ¶
const FilecoinPrecision = uint64(1_000_000_000_000_000_000)
Variables ¶
var EmptyInt = BigInt{}
var EmptyTSK = TipSetKey{}
Functions ¶
Types ¶
type API ¶
type API interface { ChainHead(context.Context) (*TipSet, error) GasEstimateMessageGas(context.Context, *Message, *MessageSendSpec, TipSetKey) (*Message, error) StateGetActor(context.Context, address.Address, TipSetKey) (*Actor, error) MpoolPush(context.Context, *SignedMessage) (cid.Cid, error) StateWaitMsg(context.Context, cid.Cid, uint64) (*MsgLookup, error) StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error) StateAccountKey(context.Context, address.Address, TipSetKey) (address.Address, error) StateLookupID(context.Context, address.Address, TipSetKey) (address.Address, error) StateReadState(context.Context, address.Address, TipSetKey) (*ActorState, error) StateNetworkVersion(context.Context, TipSetKey) (network.Version, error) StateMarketBalance(context.Context, address.Address, TipSetKey) (MarketBalance, error) StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, TipSetKey) (DealCollateralBounds, error) StateMinerInfo(context.Context, address.Address, TipSetKey) (MinerInfo, error) StateMinerProvingDeadline(context.Context, address.Address, TipSetKey) (*dline.Info, error) StateCall(context.Context, *Message, TipSetKey) (*InvocResult, error) ChainReadObj(context.Context, cid.Cid) ([]byte, error) ChainGetMessage(context.Context, cid.Cid) (*Message, error) Close() }
API declares minimum required methods for interacting with the Filecoin Blockchain We can support different filecoin implementations such as lotus or venus
type APIEndpoint ¶
APIEndpoint address and auth token to access a remote api
type ActorState ¶
type ActorState struct { Balance BigInt State interface{} }
type BeaconEntry ¶
func (*BeaconEntry) MarshalCBOR ¶
func (t *BeaconEntry) MarshalCBOR(w io.Writer) error
func (*BeaconEntry) UnmarshalCBOR ¶
func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) error
type BlockHeader ¶
type BlockHeader struct { Miner address.Address // 0 Ticket *Ticket // 1 ElectionProof *ElectionProof // 2 BeaconEntries []BeaconEntry // 3 WinPoStProof []proof.PoStProof // 4 Parents []cid.Cid // 5 ParentWeight BigInt // 6 Height abi.ChainEpoch // 7 ParentStateRoot cid.Cid // 8 ParentMessageReceipts cid.Cid // 8 Messages cid.Cid // 10 BLSAggregate *crypto.Signature // 11 Timestamp uint64 // 12 BlockSig *crypto.Signature // 13 ForkSignaling uint64 // 14 // ParentBaseFee is the base fee after executing parent tipset ParentBaseFee abi.TokenAmount // 15 // contains filtered or unexported fields }
func (*BlockHeader) Cid ¶
func (blk *BlockHeader) Cid() cid.Cid
func (*BlockHeader) LastTicket ¶
func (blk *BlockHeader) LastTicket() *Ticket
func (*BlockHeader) MarshalCBOR ¶
func (t *BlockHeader) MarshalCBOR(w io.Writer) error
func (*BlockHeader) Serialize ¶
func (blk *BlockHeader) Serialize() ([]byte, error)
func (*BlockHeader) ToStorageBlock ¶
func (blk *BlockHeader) ToStorageBlock() (block.Block, error)
func (*BlockHeader) UnmarshalCBOR ¶
func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error
type DealCollateralBounds ¶
type DealCollateralBounds struct { Min abi.TokenAmount Max abi.TokenAmount }
DealCollateralBounds is the Min and Max collateral a storage provider can issue
type ElectionProof ¶
func (*ElectionProof) MarshalCBOR ¶
func (t *ElectionProof) MarshalCBOR(w io.Writer) error
func (*ElectionProof) UnmarshalCBOR ¶
func (t *ElectionProof) UnmarshalCBOR(r io.Reader) error
type ExecutionTrace ¶
type ExecutionTrace struct { Msg *Message MsgRct *MessageReceipt Error string Duration time.Duration GasCharges []*GasTrace Subcalls []ExecutionTrace }
ExecutionTrace is a tree of all the call results executed during a state transition
type ExpTipSet ¶
type ExpTipSet struct { Cids []cid.Cid Blocks []*BlockHeader Height abi.ChainEpoch }
type GasTrace ¶
type GasTrace struct { Name string Location []Loc `json:"loc"` TotalGas int64 `json:"tg"` ComputeGas int64 `json:"cg"` StorageGas int64 `json:"sg"` TotalVirtualGas int64 `json:"vtg"` VirtualComputeGas int64 `json:"vcg"` VirtualStorageGas int64 `json:"vsg"` TimeTaken time.Duration `json:"tt"` Extra interface{} `json:"ex,omitempty"` Callers []uintptr `json:"-"` }
GasTrace is more detailed explanation of gas computation
type InvocResult ¶
type InvocResult struct { MsgCid cid.Cid Msg *Message MsgRct *MessageReceipt GasCost MsgGasCost ExecutionTrace ExecutionTrace Error string Duration time.Duration }
InvocResult is returned when calling a state change on the Filecoin blockchain
type LotusAPI ¶
type LotusAPI struct { Methods struct { ChainHead func(context.Context) (*TipSet, error) GasEstimateMessageGas func(context.Context, *Message, *MessageSendSpec, TipSetKey) (*Message, error) StateGetActor func(context.Context, address.Address, TipSetKey) (*Actor, error) MpoolPush func(context.Context, *SignedMessage) (cid.Cid, error) StateWaitMsg func(context.Context, cid.Cid, uint64) (*MsgLookup, error) StateSearchMsg func(context.Context, cid.Cid) (*MsgLookup, error) StateAccountKey func(context.Context, address.Address, TipSetKey) (address.Address, error) StateLookupID func(context.Context, address.Address, TipSetKey) (address.Address, error) StateReadState func(context.Context, address.Address, TipSetKey) (*ActorState, error) StateNetworkVersion func(context.Context, TipSetKey) (network.Version, error) StateMarketBalance func(context.Context, address.Address, TipSetKey) (MarketBalance, error) StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, TipSetKey) (DealCollateralBounds, error) StateMinerInfo func(context.Context, address.Address, TipSetKey) (MinerInfo, error) StateMinerProvingDeadline func(context.Context, address.Address, TipSetKey) (*dline.Info, error) StateCall func(context.Context, *Message, TipSetKey) (*InvocResult, error) ChainReadObj func(context.Context, cid.Cid) ([]byte, error) ChainGetMessage func(context.Context, cid.Cid) (*Message, error) } // contains filtered or unexported fields }
LotusAPI tells the rpc client how to handle the different methods
func (*LotusAPI) ChainGetMessage ¶
func (*LotusAPI) ChainReadObj ¶
func (*LotusAPI) GasEstimateMessageGas ¶
func (*LotusAPI) MpoolPush ¶
func (a *LotusAPI) MpoolPush(ctx context.Context, sm *SignedMessage) (cid.Cid, error)
func (*LotusAPI) StateAccountKey ¶
func (*LotusAPI) StateDealProviderCollateralBounds ¶
func (a *LotusAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk TipSetKey) (DealCollateralBounds, error)
func (*LotusAPI) StateGetActor ¶
func (*LotusAPI) StateLookupID ¶
func (*LotusAPI) StateMarketBalance ¶
func (*LotusAPI) StateMinerInfo ¶
func (*LotusAPI) StateMinerProvingDeadline ¶
func (*LotusAPI) StateNetworkVersion ¶
func (*LotusAPI) StateReadState ¶
func (*LotusAPI) StateSearchMsg ¶
type MarketBalance ¶
MarketBalance formats the Escrow and Locked balances of an address in the Storage Market
type Message ¶
type Message struct { Version uint64 To address.Address From address.Address Nonce uint64 Value abi.TokenAmount GasLimit int64 GasFeeCap abi.TokenAmount GasPremium abi.TokenAmount Method abi.MethodNum Params []byte }
func (*Message) MarshalJSON ¶
func (*Message) ValueReceived ¶
func (m *Message) ValueReceived() abi.TokenAmount
type MessageReceipt ¶
type MessageSendSpec ¶
type MessageSendSpec struct {
MaxFee abi.TokenAmount
}
type MinerInfo ¶
type MinerInfo struct { Owner address.Address // Must be an ID-address. Worker address.Address // Must be an ID-address. NewWorker address.Address // Must be an ID-address. ControlAddresses []address.Address // Must be an ID-addresses. WorkerChangeEpoch abi.ChainEpoch PeerId *peer.ID Multiaddrs []abi.Multiaddrs WindowPoStProofType abi.RegisteredPoStProof SectorSize abi.SectorSize WindowPoStPartitionSectors uint64 ConsensusFaultElapsed abi.ChainEpoch }
MinerInfo formats information about a Filecoin storage miner we ask a lotus api for
type MockLotusAPI ¶
type MockLotusAPI struct {
// contains filtered or unexported fields
}
MockLotusAPI is for testing purposes only
func NewMockLotusAPI ¶
func NewMockLotusAPI() *MockLotusAPI
func (*MockLotusAPI) ChainGetMessage ¶
func (m *MockLotusAPI) ChainGetMessage(ctx context.Context, c cid.Cid) (*Message, error)
func (*MockLotusAPI) ChainReadObj ¶
func (m *MockLotusAPI) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error)
func (*MockLotusAPI) Close ¶
func (m *MockLotusAPI) Close()
func (*MockLotusAPI) GasEstimateMessageGas ¶
func (m *MockLotusAPI) GasEstimateMessageGas(ctx context.Context, msg *Message, spec *MessageSendSpec, tsk TipSetKey) (*Message, error)
func (*MockLotusAPI) MpoolPush ¶
func (m *MockLotusAPI) MpoolPush(ctx context.Context, smsg *SignedMessage) (cid.Cid, error)
func (*MockLotusAPI) SetAccountKey ¶
func (m *MockLotusAPI) SetAccountKey(addr address.Address, key address.Address)
func (*MockLotusAPI) SetActor ¶
func (m *MockLotusAPI) SetActor(act *Actor)
func (*MockLotusAPI) SetActorState ¶
func (m *MockLotusAPI) SetActorState(state *ActorState)
func (*MockLotusAPI) SetInvocResult ¶
func (m *MockLotusAPI) SetInvocResult(i *InvocResult)
func (*MockLotusAPI) SetMsgLookup ¶
func (m *MockLotusAPI) SetMsgLookup(lkp *MsgLookup)
SetMsgLookup to release the StateWaitMsg request
func (*MockLotusAPI) SetObject ¶
func (m *MockLotusAPI) SetObject(obj []byte)
func (*MockLotusAPI) SetObjectReader ¶
func (m *MockLotusAPI) SetObjectReader(r func(cid.Cid) []byte)
func (*MockLotusAPI) StateAccountKey ¶
func (m *MockLotusAPI) StateAccountKey(ctx context.Context, addr address.Address, tsk TipSetKey) (address.Address, error)
func (*MockLotusAPI) StateCall ¶
func (m *MockLotusAPI) StateCall(ctx context.Context, msg *Message, tsk TipSetKey) (*InvocResult, error)
func (*MockLotusAPI) StateDealProviderCollateralBounds ¶
func (m *MockLotusAPI) StateDealProviderCollateralBounds(ctx context.Context, s abi.PaddedPieceSize, b bool, tsk TipSetKey) (DealCollateralBounds, error)
func (*MockLotusAPI) StateGetActor ¶
func (*MockLotusAPI) StateLookupID ¶
func (m *MockLotusAPI) StateLookupID(ctx context.Context, addr address.Address, tsk TipSetKey) (address.Address, error)
func (*MockLotusAPI) StateMarketBalance ¶
func (m *MockLotusAPI) StateMarketBalance(ctx context.Context, addr address.Address, tsk TipSetKey) (MarketBalance, error)
func (*MockLotusAPI) StateMinerInfo ¶
func (*MockLotusAPI) StateMinerProvingDeadline ¶
func (*MockLotusAPI) StateNetworkVersion ¶
func (*MockLotusAPI) StateReadState ¶
func (m *MockLotusAPI) StateReadState(ctx context.Context, addr address.Address, tsk TipSetKey) (*ActorState, error)
func (*MockLotusAPI) StateSearchMsg ¶
func (m *MockLotusAPI) StateSearchMsg(ctx context.Context, c cid.Cid) (*MsgLookup, error)
func (*MockLotusAPI) StateWaitMsg ¶
type MsgGasCost ¶
type MsgGasCost struct { Message cid.Cid // Can be different than requested, in case it was replaced, but only gas values changed GasUsed abi.TokenAmount BaseFeeBurn abi.TokenAmount OverEstimationBurn abi.TokenAmount MinerPenalty abi.TokenAmount MinerTip abi.TokenAmount Refund abi.TokenAmount TotalCost abi.TokenAmount }
MsgGasCost is a breakdown of all the fees paid when running a transaction on chain
type MsgLookup ¶
type MsgLookup struct { Message cid.Cid // Can be different than requested, in case it was replaced, but only gas values changed Receipt MessageReceipt ReturnDec interface{} TipSet TipSetKey Height abi.ChainEpoch }
type RawMessage ¶
type RawMessage Message
type RawSignedMessage ¶
type RawSignedMessage SignedMessage
type SignedMessage ¶
func (*SignedMessage) Cid ¶
func (sm *SignedMessage) Cid() cid.Cid
func (*SignedMessage) MarshalCBOR ¶
func (t *SignedMessage) MarshalCBOR(w io.Writer) error
func (*SignedMessage) MarshalJSON ¶
func (sm *SignedMessage) MarshalJSON() ([]byte, error)
func (*SignedMessage) Serialize ¶
func (sm *SignedMessage) Serialize() ([]byte, error)
func (*SignedMessage) ToStorageBlock ¶
func (sm *SignedMessage) ToStorageBlock() (block.Block, error)
func (*SignedMessage) UnmarshalCBOR ¶
func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error
type TipSet ¶
type TipSet struct {
// contains filtered or unexported fields
}
func NewTipSet ¶
func NewTipSet(blks []*BlockHeader) (*TipSet, error)
NewTipSet Checks:
- A tipset is composed of at least one block. (Because of our variable number of blocks per tipset, determined by randomness, we do not impose an upper limit.)
- All blocks have the same height.
- All blocks have the same parents (same number of them and matching CIDs).
func (*TipSet) Height ¶
func (ts *TipSet) Height() abi.ChainEpoch
func (*TipSet) MarshalJSON ¶
func (*TipSet) UnmarshalJSON ¶
type TipSetKey ¶
type TipSetKey struct {
// contains filtered or unexported fields
}
A TipSetKey is an immutable collection of CIDs forming a unique key for a tipset. The CIDs are assumed to be distinct and in canonical order. Two keys with the same CIDs in a different order are not considered equal. TipSetKey is a lightweight value type, and may be compared for equality with ==.
func NewTipSetKey ¶
func NewTipSetKey(cids ...cid.Cid) TipSetKey
NewTipSetKey builds a new key from a slice of CIDs. The CIDs are assumed to be ordered correctly.
func TipSetKeyFromBytes ¶
TipSetKeyFromBytes wraps an encoded key, validating correct decoding.
func (TipSetKey) Cids ¶
func (k TipSetKey) Cids() []cid.Cid
Cids returns a slice of the CIDs comprising this key.