state

package
v0.13.1-patch.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound          = errors.New("account not found")
	ErrAccountPublicKeyNotFound = errors.New("account public key not found")
)

Functions

func RegisterSize added in v0.13.0

func RegisterSize(address flow.Address, isController bool, key string, value flow.RegisterValue) int

Types

type Accounts

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

func NewAccounts

func NewAccounts(ledger Ledger) *Accounts

func (*Accounts) AppendPublicKey

func (a *Accounts) AppendPublicKey(address flow.Address, publicKey flow.AccountPublicKey) error

func (*Accounts) Create

func (a *Accounts) Create(publicKeys []flow.AccountPublicKey, newAddress flow.Address) error

Create account sets all required registers on an address.

func (*Accounts) DeleteContract added in v0.12.0

func (a *Accounts) DeleteContract(contractName string, address flow.Address) error

func (*Accounts) Exists

func (a *Accounts) Exists(address flow.Address) (bool, error)

func (*Accounts) Get

func (a *Accounts) Get(address flow.Address) (*flow.Account, error)

func (*Accounts) GetContract added in v0.12.0

func (a *Accounts) GetContract(contractName string, address flow.Address) ([]byte, error)

func (*Accounts) GetContractNames added in v0.12.0

func (a *Accounts) GetContractNames(address flow.Address) ([]string, error)

GetContractNames gets a sorted list of names of contracts deployed on an address

func (*Accounts) GetPublicKey

func (a *Accounts) GetPublicKey(address flow.Address, keyIndex uint64) (flow.AccountPublicKey, error)

func (*Accounts) GetPublicKeyCount

func (a *Accounts) GetPublicKeyCount(address flow.Address) (uint64, error)

func (*Accounts) GetPublicKeys

func (a *Accounts) GetPublicKeys(address flow.Address) (publicKeys []flow.AccountPublicKey, err error)

func (*Accounts) GetStorageUsed added in v0.13.0

func (a *Accounts) GetStorageUsed(address flow.Address) (uint64, error)

GetStorageUsed returns the amount of storage used in bytes by this account

func (*Accounts) GetValue added in v0.13.0

func (a *Accounts) GetValue(address flow.Address, key string) (flow.RegisterValue, error)

func (*Accounts) SetAllPublicKeys

func (a *Accounts) SetAllPublicKeys(address flow.Address, publicKeys []flow.AccountPublicKey) error

func (*Accounts) SetContract added in v0.12.0

func (a *Accounts) SetContract(contractName string, address flow.Address, contract []byte) error

func (*Accounts) SetPublicKey

func (a *Accounts) SetPublicKey(
	address flow.Address,
	keyIndex uint64,
	publicKey flow.AccountPublicKey,
) (encodedPublicKey []byte, err error)

func (*Accounts) SetValue added in v0.13.0

func (a *Accounts) SetValue(address flow.Address, key string, value flow.RegisterValue) error

SetValue sets a value in address' storage

func (*Accounts) TouchContract added in v0.12.0

func (a *Accounts) TouchContract(contractName string, address flow.Address)

type Ledger

type Ledger interface {
	Set(owner, controller, key string, value flow.RegisterValue)
	Get(owner, controller, key string) (flow.RegisterValue, error)
	Touch(owner, controller, key string)
	Delete(owner, controller, key string)
	RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)
}

A Ledger is the storage interface used by the virtual machine to read and write register values.

type LedgerBoundAddressGenerator added in v0.12.0

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

LedgerBoundAddressGenerator is a decorator for an address generator. It uses the underlying generator it gets from the chain. The only change is that when next address is called the state is updated as well.

func NewLedgerBoundAddressGenerator added in v0.12.0

func NewLedgerBoundAddressGenerator(ledger Ledger, chain flow.Chain) (*LedgerBoundAddressGenerator, error)

func (*LedgerBoundAddressGenerator) Bytes added in v0.12.0

func (g *LedgerBoundAddressGenerator) Bytes() []byte

func (*LedgerBoundAddressGenerator) CurrentAddress added in v0.12.0

func (g *LedgerBoundAddressGenerator) CurrentAddress() flow.Address

func (*LedgerBoundAddressGenerator) NextAddress added in v0.12.0

func (g *LedgerBoundAddressGenerator) NextAddress() (flow.Address, error)

type MapLedger

type MapLedger struct {
	Registers       map[string]flow.RegisterEntry
	RegisterTouches map[string]bool
}

A MapLedger is a naive ledger storage implementation backed by a simple map.

This implementation is designed for testing purposes.

func NewMapLedger

func NewMapLedger() *MapLedger

func (MapLedger) Delete

func (m MapLedger) Delete(owner, controller, key string)

func (MapLedger) Get

func (m MapLedger) Get(owner, controller, key string) (flow.RegisterValue, error)

func (MapLedger) RegisterUpdates added in v0.13.0

func (m MapLedger) RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)

func (MapLedger) Set

func (m MapLedger) Set(owner, controller, key string, value flow.RegisterValue)

func (MapLedger) Touch

func (m MapLedger) Touch(owner, controller, key string)

type UUIDs

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

func NewUUIDs

func NewUUIDs(ledger Ledger) *UUIDs

func (*UUIDs) GetUUID

func (u *UUIDs) GetUUID() (uint64, error)

func (*UUIDs) SetUUID

func (u *UUIDs) SetUUID(uuid uint64)

Jump to

Keyboard shortcuts

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