tree

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0, MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAccount

func AddAccount(t *testing.T, tree *State, store cbor.IpldStore, addr address.Address)

func Diff

func Diff(oldTree, newTree *State) (map[string]types.Actor, error)

func MustCommit

func MustCommit(st State) cid.Cid

MustCommit flushes the state or panics if it can't.

func MustGetActor

func MustGetActor(st State, a address.Address) (*types.Actor, bool)

MustGetActor gets the actor or panics if it can't.

func MustSetActor

func MustSetActor(st State, address address.Address, actor *types.Actor) cid.Cid

MustSetActor sets the actor or panics if it can't.

func UpdateAccount

func UpdateAccount(t *testing.T, tree *State, addr address.Address, fn func(*types.Actor))

Types

type ActorKey

type ActorKey = address.Address

type AdtStore

type AdtStore struct{ cbor.IpldStore }

func (*AdtStore) Context

func (a *AdtStore) Context() context.Context

type Root

type Root = cid.Cid

type State

type State struct {
	Store cbor.IpldStore
	// contains filtered or unexported fields
}

state stores actors state by their ID.

func LoadState

func LoadState(ctx context.Context, cst cbor.IpldStore, c cid.Cid) (*State, error)

func NewFromString

func NewFromString(t *testing.T, s string, store cbor.IpldStore) *State

NewFromString sets a state tree based on an int.

TODO: we could avoid this if write a test cborStore that can map test cids to test states.

func NewState

func NewState(cst cbor.IpldStore, ver StateTreeVersion) (*State, error)

func NewStateWithBuiltinActor

func NewStateWithBuiltinActor(t *testing.T, store cbor.IpldStore, ver StateTreeVersion) (*State, error)

func (*State) At

func (st *State) At(root Root) error

func (*State) ClearSnapshot

func (st *State) ClearSnapshot()

func (*State) DeleteActor

func (st *State) DeleteActor(ctx context.Context, addr ActorKey) error

func (*State) Flush

func (st *State) Flush(ctx context.Context) (cid.Cid, error)

func (*State) ForEach

func (st *State) ForEach(f func(ActorKey, *types.Actor) error) error

func (*State) GetActor

func (st *State) GetActor(ctx context.Context, addr ActorKey) (*types.Actor, bool, error)

ToDo Return nil if it is actor not found[ErrActorNotFound],Because the basis for judgment is: err != nil ==> panic ??? GetActor returns the actor from any type of `addr` provided.

func (*State) GetStore

func (st *State) GetStore() cbor.IpldStore

func (*State) LookupID

func (st *State) LookupID(addr ActorKey) (address.Address, error)

LookupID gets the ID address of this actor's `addr` stored in the `InitActor`.

func (*State) MutateActor

func (st *State) MutateActor(addr ActorKey, f func(*types.Actor) error) error

func (*State) RegisterNewAddress

func (st *State) RegisterNewAddress(addr ActorKey) (address.Address, error)

func (*State) Revert

func (st *State) Revert() error

func (*State) SetActor

func (st *State) SetActor(ctx context.Context, addr ActorKey, act *types.Actor) error

func (*State) Snapshot

func (st *State) Snapshot(ctx context.Context) error

func (*State) Version

func (st *State) Version() StateTreeVersion

Version returns the version of the StateTree data structure in use.

type StateInfo0

type StateInfo0 struct{} //nolint

TODO: version this.

func (*StateInfo0) MarshalCBOR

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

func (*StateInfo0) UnmarshalCBOR

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

type StateRoot

type StateRoot struct {
	// State tree version.
	Version StateTreeVersion
	// Actors tree. The structure depends on the state root version.
	Actors cid.Cid
	// Info. The structure depends on the state root version.
	Info cid.Cid
}

func (*StateRoot) MarshalCBOR

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

func (*StateRoot) UnmarshalCBOR

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

type StateTreeVersion

type StateTreeVersion uint64 //nolint
const (
	// StateTreeVersion0 corresponds to actors < v2.
	StateTreeVersion0 StateTreeVersion = iota
	// StateTreeVersion1 corresponds to actors v2
	StateTreeVersion1
	// StateTreeVersion2 corresponds to actors v3.
	StateTreeVersion2
	// StateTreeVersion3 corresponds to actors v4.
	StateTreeVersion3
	// StateTreeVersion4 corresponds to actors v5, v6.
	StateTreeVersion4
)

func VersionForNetwork added in v1.0.4

func VersionForNetwork(ver network.Version) (StateTreeVersion, error)

VersionForNetwork returns the state tree version for the given network version.

type Tree

type Tree interface {
	GetActor(ctx context.Context, addr ActorKey) (*types.Actor, bool, error)
	SetActor(ctx context.Context, addr ActorKey, act *types.Actor) error
	DeleteActor(ctx context.Context, addr ActorKey) error
	LookupID(addr ActorKey) (address.Address, error)

	Flush(ctx context.Context) (cid.Cid, error)
	Snapshot(ctx context.Context) error
	ClearSnapshot()
	Revert() error
	At(Root) error
	RegisterNewAddress(addr ActorKey) (address.Address, error)

	MutateActor(addr ActorKey, f func(*types.Actor) error) error
	ForEach(f func(ActorKey, *types.Actor) error) error
	GetStore() cbor.IpldStore
}

Review: can we get rid of this?

Jump to

Keyboard shortcuts

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