types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0, MIT Imports: 34 Imported by: 547

Documentation

Index

Constants

View Source
const (
	KTSecp256k1 = "secp256k1"
	KTBLS       = "bls"
)
View Source
const (
	IKTUnknown = -1

	IKTSecp256k1 = iota
	IKTBLS
)
View Source
const BigIntMaxSerializedLen = 128 // is this big enough? or too big?
View Source
const SignatureMaxLength = 200

Variables

View Source
var (
	ErrKeyInfoNotFound = fmt.Errorf("key info not found")
	ErrKeyExists       = fmt.Errorf("key already exists")
)
View Source
var EmptyInt = BigInt{}
View Source
var ErrActorNotFound = fmt.Errorf("actor not found")
View Source
var ErrBitFieldTooMany = errors.New("to many items in RLE")
View Source
var TotalFilecoinInt = FromFil(build.TotalFilecoin)

Functions

func BigCmp

func BigCmp(a, b BigInt) int

func CidArrsEqual

func CidArrsEqual(a, b []cid.Cid) bool

func ElectionPostChallengeCount

func ElectionPostChallengeCount(sectors uint64, faults uint64) uint64

func IsTicketWinner

func IsTicketWinner(partialTicket []byte, ssizeI uint64, snum uint64, totpow BigInt) bool

func WrapStorage

func WrapStorage(s Storage) amt.Blocks

Types

type Actor

type Actor struct {
	Code    cid.Cid
	Head    cid.Cid
	Nonce   uint64
	Balance BigInt
}

func (*Actor) MarshalCBOR

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

func (*Actor) UnmarshalCBOR

func (t *Actor) UnmarshalCBOR(r io.Reader) error

type BigInt

type BigInt struct {
	*big.Int
}

func BigAdd

func BigAdd(a, b BigInt) BigInt

func BigDiv

func BigDiv(a, b BigInt) BigInt

func BigFromBytes

func BigFromBytes(b []byte) BigInt

func BigFromString

func BigFromString(s string) (BigInt, error)

func BigMod

func BigMod(a, b BigInt) BigInt

func BigMul

func BigMul(a, b BigInt) BigInt

func BigSub

func BigSub(a, b BigInt) BigInt

func FromFil

func FromFil(i uint64) BigInt

func NewInt

func NewInt(i uint64) BigInt

func (BigInt) Equals

func (bi BigInt) Equals(o BigInt) bool

Equals returns true if bi == o

func (BigInt) GreaterThan

func (bi BigInt) GreaterThan(o BigInt) bool

GreaterThan returns true if bi > o

func (*BigInt) IsZero

func (bi *BigInt) IsZero() bool

func (BigInt) LessThan

func (bi BigInt) LessThan(o BigInt) bool

LessThan returns true if bi < o

func (*BigInt) MarshalCBOR

func (bi *BigInt) MarshalCBOR(w io.Writer) error

func (*BigInt) MarshalJSON

func (bi *BigInt) MarshalJSON() ([]byte, error)

func (BigInt) Nil

func (bi BigInt) Nil() bool

func (*BigInt) Scan

func (bi *BigInt) Scan(value interface{}) error

func (BigInt) SizeStr added in v0.1.5

func (bi BigInt) SizeStr() string

func (*BigInt) UnmarshalCBOR

func (bi *BigInt) UnmarshalCBOR(br io.Reader) error

func (*BigInt) UnmarshalJSON

func (bi *BigInt) UnmarshalJSON(b []byte) error

type BitField

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

func BitFieldFromSet

func BitFieldFromSet(setBits []uint64) BitField

func MergeBitFields

func MergeBitFields(a, b BitField) (BitField, error)

func NewBitField

func NewBitField() BitField

func NewBitFieldFromBytes added in v0.2.1

func NewBitFieldFromBytes(rle []byte) (BitField, error)

func (BitField) All

func (bf BitField) All(max uint64) ([]uint64, error)

All returns all set bits

func (BitField) AllMap

func (bf BitField) AllMap(max uint64) (map[uint64]bool, error)

func (BitField) Count

func (bf BitField) Count() (uint64, error)

func (BitField) MarshalCBOR

func (bf BitField) MarshalCBOR(w io.Writer) error

func (BitField) Set

func (bf BitField) Set(bit uint64)

Set ...s bit in the BitField

func (*BitField) UnmarshalCBOR

func (bf *BitField) UnmarshalCBOR(r io.Reader) error

type BlockHeader

type BlockHeader struct {
	Miner address.Address

	Ticket *Ticket

	EPostProof EPostProof

	Parents []cid.Cid

	ParentWeight BigInt

	Height uint64

	ParentStateRoot cid.Cid

	ParentMessageReceipts cid.Cid

	Messages cid.Cid

	BLSAggregate Signature

	Timestamp uint64

	BlockSig *Signature

	ForkSignaling uint64
}

func DecodeBlock

func DecodeBlock(b []byte) (*BlockHeader, error)

func (*BlockHeader) CheckBlockSignature

func (blk *BlockHeader) CheckBlockSignature(ctx context.Context, worker address.Address) error

func (*BlockHeader) Cid

func (b *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) SigningBytes

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

func (*BlockHeader) ToStorageBlock

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

func (*BlockHeader) UnmarshalCBOR

func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error

type BlockMsg

type BlockMsg struct {
	Header        *BlockHeader
	BlsMessages   []cid.Cid
	SecpkMessages []cid.Cid
}

func DecodeBlockMsg

func DecodeBlockMsg(b []byte) (*BlockMsg, error)

func (*BlockMsg) Cid

func (bm *BlockMsg) Cid() cid.Cid

func (*BlockMsg) MarshalCBOR

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

func (*BlockMsg) Serialize

func (bm *BlockMsg) Serialize() ([]byte, error)

func (*BlockMsg) UnmarshalCBOR

func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error

type EPostProof

type EPostProof struct {
	Proof      []byte
	PostRand   []byte
	Candidates []EPostTicket
}

func (*EPostProof) MarshalCBOR

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

func (*EPostProof) UnmarshalCBOR

func (t *EPostProof) UnmarshalCBOR(r io.Reader) error

type EPostTicket

type EPostTicket struct {
	Partial        []byte
	SectorID       uint64
	ChallengeIndex uint64
}

func (*EPostTicket) MarshalCBOR

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

func (*EPostTicket) UnmarshalCBOR

func (t *EPostTicket) UnmarshalCBOR(r io.Reader) error

type ExpTipSet

type ExpTipSet struct {
	Cids   []cid.Cid
	Blocks []*BlockHeader
	Height uint64
}

why didnt i just export the fields? Because the struct has methods with the same names already

func (*ExpTipSet) MarshalCBOR

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

func (*ExpTipSet) UnmarshalCBOR

func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error

type FIL

type FIL BigInt

func ParseFIL

func ParseFIL(s string) (FIL, error)

func (FIL) Format

func (f FIL) Format(s fmt.State, ch rune)

func (FIL) String

func (f FIL) String() string

type FullBlock

type FullBlock struct {
	Header        *BlockHeader
	BlsMessages   []*Message
	SecpkMessages []*SignedMessage
}

func (*FullBlock) Cid

func (fb *FullBlock) Cid() cid.Cid

type InvokeRet

type InvokeRet struct {
	Result     []byte
	ReturnCode byte
}

type KeyInfo

type KeyInfo struct {
	Type       string
	PrivateKey []byte
}

KeyInfo is used for storing keys in KeyStore

type KeyStore

type KeyStore interface {
	// List lists all the keys stored in the KeyStore
	List() ([]string, error)
	// Get gets a key out of keystore and returns KeyInfo corresponding to named key
	Get(string) (KeyInfo, error)
	// Put saves a key info under given name
	Put(string, KeyInfo) error
	// Delete removes a key from keystore
	Delete(string) error
}

KeyStore is used for storing secret keys

type LogCids

type LogCids []cid.Cid

func (LogCids) MarshalLogArray

func (cids LogCids) MarshalLogArray(ae zapcore.ArrayEncoder) error

type Merge

type Merge struct {
	Lane  uint64
	Nonce uint64
}

func (*Merge) MarshalCBOR

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

func (*Merge) UnmarshalCBOR

func (t *Merge) UnmarshalCBOR(r io.Reader) error

type Message

type Message struct {
	To   address.Address
	From address.Address

	Nonce uint64

	Value BigInt

	GasPrice BigInt
	GasLimit BigInt

	Method uint64
	Params []byte
}

func DecodeMessage

func DecodeMessage(b []byte) (*Message, error)

func (*Message) Cid

func (m *Message) Cid() cid.Cid

func (*Message) Equals

func (m *Message) Equals(o *Message) bool

func (*Message) MarshalCBOR

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

func (*Message) RequiredFunds

func (m *Message) RequiredFunds() BigInt

func (*Message) Serialize

func (m *Message) Serialize() ([]byte, error)

func (*Message) ToStorageBlock

func (m *Message) ToStorageBlock() (block.Block, error)

func (*Message) UnmarshalCBOR

func (t *Message) UnmarshalCBOR(r io.Reader) error

func (*Message) VMMessage

func (m *Message) VMMessage() *Message

type MessageReceipt

type MessageReceipt struct {
	ExitCode uint8
	Return   []byte
	GasUsed  BigInt
}

func (*MessageReceipt) Equals

func (mr *MessageReceipt) Equals(o *MessageReceipt) bool

func (*MessageReceipt) MarshalCBOR

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

func (*MessageReceipt) UnmarshalCBOR

func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error

type ModVerifyParams

type ModVerifyParams struct {
	Actor  address.Address
	Method uint64
	Data   []byte
}

func (*ModVerifyParams) MarshalCBOR

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

func (*ModVerifyParams) UnmarshalCBOR

func (t *ModVerifyParams) UnmarshalCBOR(r io.Reader) error

type MsgMeta

type MsgMeta struct {
	BlsMessages   cid.Cid
	SecpkMessages cid.Cid
}

func (*MsgMeta) Cid

func (mm *MsgMeta) Cid() cid.Cid

func (*MsgMeta) MarshalCBOR

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

func (*MsgMeta) ToStorageBlock

func (mm *MsgMeta) ToStorageBlock() (block.Block, error)

func (*MsgMeta) UnmarshalCBOR

func (t *MsgMeta) UnmarshalCBOR(r io.Reader) error

type Signature

type Signature struct {
	Type string
	Data []byte
}

func SignatureFromBytes

func SignatureFromBytes(x []byte) (Signature, error)

func (*Signature) Equals

func (s *Signature) Equals(o *Signature) bool

func (*Signature) MarshalCBOR

func (s *Signature) MarshalCBOR(w io.Writer) error

func (*Signature) TypeCode

func (s *Signature) TypeCode() int

func (*Signature) UnmarshalCBOR

func (s *Signature) UnmarshalCBOR(br io.Reader) error

func (*Signature) Verify

func (s *Signature) Verify(addr address.Address, msg []byte) error

type SignedMessage

type SignedMessage struct {
	Message   Message
	Signature Signature
}

func DecodeSignedMessage

func DecodeSignedMessage(data []byte) (*SignedMessage, error)

func (*SignedMessage) Cid

func (m *SignedMessage) Cid() cid.Cid

func (*SignedMessage) MarshalCBOR

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

func (*SignedMessage) Serialize

func (sm *SignedMessage) Serialize() ([]byte, error)

func (*SignedMessage) Size

func (sm *SignedMessage) Size() int

func (*SignedMessage) ToStorageBlock

func (m *SignedMessage) ToStorageBlock() (block.Block, error)

func (*SignedMessage) UnmarshalCBOR

func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error

func (*SignedMessage) VMMessage

func (sm *SignedMessage) VMMessage() *Message

type SignedStorageAsk

type SignedStorageAsk struct {
	Ask       *StorageAsk
	Signature *Signature
}

func (*SignedStorageAsk) MarshalCBOR

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

func (*SignedStorageAsk) UnmarshalCBOR

func (t *SignedStorageAsk) UnmarshalCBOR(r io.Reader) error

type SignedVoucher

type SignedVoucher struct {
	TimeLock       uint64
	SecretPreimage []byte
	Extra          *ModVerifyParams
	Lane           uint64
	Nonce          uint64
	Amount         BigInt
	MinCloseHeight uint64

	Merges []Merge

	Signature *Signature
}

func DecodeSignedVoucher

func DecodeSignedVoucher(s string) (*SignedVoucher, error)

func (*SignedVoucher) EncodedString

func (sv *SignedVoucher) EncodedString() (string, error)

func (*SignedVoucher) Equals

func (sv *SignedVoucher) Equals(other *SignedVoucher) bool

func (*SignedVoucher) MarshalCBOR

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

func (*SignedVoucher) SigningBytes

func (sv *SignedVoucher) SigningBytes() ([]byte, error)

func (*SignedVoucher) UnmarshalCBOR

func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error

type StateTree

type StateTree interface {
	SetActor(addr address.Address, act *Actor) error
	GetActor(addr address.Address) (*Actor, error)
}

type Storage

type Storage interface {
	Put(cbg.CBORMarshaler) (cid.Cid, aerrors.ActorError)
	Get(cid.Cid, cbg.CBORUnmarshaler) aerrors.ActorError

	GetHead() cid.Cid

	// Commit sets the new head of the actors state as long as the current
	// state matches 'oldh'
	Commit(oldh cid.Cid, newh cid.Cid) aerrors.ActorError
}

type StorageAsk

type StorageAsk struct {
	// Price per GiB / Epoch
	Price BigInt

	MinPieceSize uint64
	Miner        address.Address
	Timestamp    uint64
	Expiry       uint64
	SeqNo        uint64
}

func (*StorageAsk) MarshalCBOR

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

func (*StorageAsk) UnmarshalCBOR

func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error

type Ticket

type Ticket struct {
	VRFProof []byte
}

func (*Ticket) Equals

func (t *Ticket) Equals(ot *Ticket) bool

func (*Ticket) Less

func (t *Ticket) Less(o *Ticket) bool

func (*Ticket) MarshalCBOR

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

func (*Ticket) UnmarshalCBOR

func (t *Ticket) UnmarshalCBOR(r io.Reader) error

type TipSet

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

func NewTipSet

func NewTipSet(blks []*BlockHeader) (*TipSet, error)

func (*TipSet) Blocks

func (ts *TipSet) Blocks() []*BlockHeader

func (*TipSet) Cids

func (ts *TipSet) Cids() []cid.Cid

func (*TipSet) Contains

func (ts *TipSet) Contains(oc cid.Cid) bool

func (*TipSet) Equals

func (ts *TipSet) Equals(ots *TipSet) bool

func (*TipSet) Height

func (ts *TipSet) Height() uint64

func (*TipSet) Key

func (ts *TipSet) Key() TipSetKey

func (*TipSet) MarshalCBOR

func (ts *TipSet) MarshalCBOR(w io.Writer) error

func (*TipSet) MarshalJSON

func (ts *TipSet) MarshalJSON() ([]byte, error)

func (*TipSet) MinTicket

func (ts *TipSet) MinTicket() *Ticket

func (*TipSet) MinTicketBlock

func (ts *TipSet) MinTicketBlock() *BlockHeader

func (*TipSet) MinTimestamp

func (ts *TipSet) MinTimestamp() uint64

func (*TipSet) ParentState

func (ts *TipSet) ParentState() cid.Cid

func (*TipSet) ParentWeight

func (ts *TipSet) ParentWeight() BigInt

func (*TipSet) Parents

func (ts *TipSet) Parents() TipSetKey

func (*TipSet) UnmarshalCBOR

func (ts *TipSet) UnmarshalCBOR(r io.Reader) error

func (*TipSet) UnmarshalJSON

func (ts *TipSet) UnmarshalJSON(b []byte) error

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

func TipSetKeyFromBytes(encoded []byte) (TipSetKey, error)

TipSetKeyFromBytes wraps an encoded key, validating correct decoding.

func (TipSetKey) Bytes

func (k TipSetKey) Bytes() []byte

Bytes() returns a binary representation of the key.

func (TipSetKey) Cids

func (k TipSetKey) Cids() []cid.Cid

Cids returns a slice of the CIDs comprising this key.

func (TipSetKey) MarshalJSON

func (k TipSetKey) MarshalJSON() ([]byte, error)

func (TipSetKey) String

func (k TipSetKey) String() string

String() returns a human-readable representation of the key.

func (*TipSetKey) UnmarshalJSON

func (k *TipSetKey) UnmarshalJSON(b []byte) error

type VMContext

type VMContext interface {
	Message() *Message
	Origin() address.Address
	Ipld() *hamt.CborIpldStore
	Send(to address.Address, method uint64, value BigInt, params []byte) ([]byte, aerrors.ActorError)
	BlockHeight() uint64
	GasUsed() BigInt
	Storage() Storage
	StateTree() (StateTree, aerrors.ActorError)
	VerifySignature(sig *Signature, from address.Address, data []byte) aerrors.ActorError
	ChargeGas(uint64) aerrors.ActorError
	GetRandomness(height uint64) ([]byte, aerrors.ActorError)
	GetBalance(address.Address) (BigInt, aerrors.ActorError)
	Sys() *VMSyscalls

	Context() context.Context
}

type VMSyscalls

type VMSyscalls struct {
	ValidatePoRep      func(context.Context, address.Address, uint64, []byte, []byte, []byte, []byte, []byte, uint64) (bool, aerrors.ActorError)
	VerifyFallbackPost func(ctx context.Context,
		sectorSize uint64,
		sectorInfo sectorbuilder.SortedPublicSectorInfo,
		challengeSeed []byte,
		proof []byte,
		candidates []sectorbuilder.EPostCandidate,
		proverID address.Address,
		faults uint64) (bool, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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