internal

package
v1.8.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MessageVersion = 0

Variables

View Source
var AttoFil = NewInt(1)
View Source
var EmptyInt = BigInt{}
View Source
var ErrActorNotFound = errors.New("actor not found")
View Source
var FemtoFil = BigMul(AttoFil, NewInt(1000))
View Source
var NanoFil = BigMul(PicoFil, NewInt(1000))
View Source
var PicoFil = BigMul(FemtoFil, NewInt(1000))
View Source
var TotalFilecoinInt = FromFil(params.FilBase)
View Source
var ZeroAddress = func() address.Address {
	addr := "f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a"

	ret, err := address.NewFromString(addr)
	if err != nil {
		panic(err)
	}

	return ret
}()
View Source
var ZeroFIL = fbig.NewInt(0)

Functions

func BigCmp

func BigCmp(a, b BigInt) int

func BigDivFloat

func BigDivFloat(num, den BigInt) float64

Types

type Actor

type Actor struct {
	// Code is a CID of the VM code for this actor's implementation (or a constant for actors implemented in Go code).
	// Code may be nil for an uninitialized actor (which exists because it has received a balance).
	Code cid.Cid
	// Head is the CID of the root of the actor's state tree.
	Head cid.Cid
	// Nonce is the number expected on the next message from this actor.
	// Messages are processed in strict, contiguous order.
	Nonce uint64
	// Balance is the amount of attoFIL in the actor's account.
	Balance abi.TokenAmount
}

Actor is the central abstraction of entities in the system.

Both individual accounts, as well as contracts (user & system level) are represented as actors. An actor has the following core functionality implemented on a system level: - track a Filecoin balance, using the `Balance` field - execute code stored in the `Code` field - read & write memory - replay protection, using the `Nonce` field

Value sent to a non-existent address will be tracked as an empty actor that has a Balance but nil Code and Memory. You must nil check Code cids before comparing them.

More specific capabilities for individual accounts or contract specific must be implemented inside the code.

Not safe for concurrent access.

func NewActor

func NewActor(code cid.Cid, balance abi.TokenAmount, head cid.Cid) *Actor

NewActor constructs a new actor.

func (*Actor) Empty

func (t *Actor) Empty() bool

Empty tests whether the actor's code is defined.

func (*Actor) IncrementSeqNum

func (t *Actor) IncrementSeqNum()

IncrementSeqNum increments the seq number.

func (*Actor) MarshalCBOR

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

func (*Actor) UnmarshalCBOR

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

type BigInt

type BigInt = big2.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

type ChainMsg

type ChainMsg interface {
	Cid() cid.Cid
	VMMessage() *Message
	ToStorageBlock() (blocks.Block, error)
	// FIXME: This is the *message* length, this name is misleading.
	ChainLength() int
	cbor.Marshaler
	cbor.Unmarshaler
}

type FIL

type FIL BigInt

func MustParseFIL

func MustParseFIL(s string) FIL

func ParseFIL

func ParseFIL(s string) (FIL, error)

func (FIL) Format

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

func (FIL) MarshalJSON

func (f FIL) MarshalJSON() ([]byte, error)

func (FIL) MarshalText

func (f FIL) MarshalText() (text []byte, err error)

func (FIL) Nano

func (f FIL) Nano() string

func (FIL) Short

func (f FIL) Short() string

func (FIL) String

func (f FIL) String() string

func (FIL) Unitless

func (f FIL) Unitless() string

func (*FIL) UnmarshalJSON

func (f *FIL) UnmarshalJSON(by []byte) error

func (FIL) UnmarshalText

func (f FIL) UnmarshalText(text []byte) error

type Message

type Message struct {
	Version uint64

	To   address.Address
	From address.Address
	// When receiving a message from a user account the nonce in
	// the message must match the expected nonce in the from actor.
	// This prevents replay attacks.
	Nonce uint64

	Value abi.TokenAmount

	GasLimit   int64
	GasFeeCap  abi.TokenAmount
	GasPremium abi.TokenAmount

	Method abi.MethodNum
	Params []byte
}

func DecodeMessage

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

func (*Message) ChainLength

func (m *Message) ChainLength() int

func (*Message) Cid

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

func (*Message) EqualCall

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

func (*Message) Equals

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

func (*Message) MarshalCBOR

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

func (*Message) MarshalJSON

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

func (*Message) RequiredFunds

func (m *Message) RequiredFunds() abi.TokenAmount

func (*Message) Serialize

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

func (*Message) SerializeWithCid

func (m *Message) SerializeWithCid() (cid.Cid, []byte, error)

func (*Message) String

func (m *Message) String() string

func (*Message) ToStorageBlock

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

func (*Message) UnmarshalCBOR

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

func (*Message) VMMessage

func (m *Message) VMMessage() *Message

func (*Message) ValidForBlockInclusion

func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version) error

type RawMessage

type RawMessage Message

Jump to

Keyboard shortcuts

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