state

package
v0.14.0-patch.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyExists         = "exists"
	KeyCode           = "code"
	KeyContractNames  = "contract_names"
	KeyPublicKeyCount = "public_key_count"
	KeyStorageUsed    = "storage_used"
)
View Source
const (
	DefaultMaxKeySize         = 16_000      // ~16KB
	DefaultMaxValueSize       = 64_000_000  // ~64MB
	DefaultMaxInteractionSize = 256_000_000 // ~256MB
)

TODO we started with high numbers here and we might tune (reduce) them when we have more data

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

func WithMaxInteractionSizeAllowed added in v0.14.0

func WithMaxInteractionSizeAllowed(limit uint64) func(st *State) *State

WithMaxInteractionSizeAllowed sets limit on total byte interaction with ledger

func WithMaxKeySizeAllowed added in v0.14.0

func WithMaxKeySizeAllowed(limit uint64) func(st *State) *State

WithMaxKeySizeAllowed sets limit on max key size

func WithMaxValueSizeAllowed added in v0.14.0

func WithMaxValueSizeAllowed(limit uint64) func(st *State) *State

WithMaxValueSizeAllowed sets limit on max value size

Types

type Accounts

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

func NewAccounts

func NewAccounts(state *State) *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) error
	Get(owner, controller, key string) (flow.RegisterValue, error)
	Touch(owner, controller, key string) error
	Delete(owner, controller, key string) error
}

Rename this to Storage remove reference to flow.RegisterValue and use byte[] A Ledger is the storage interface used by the virtual machine to read and write register values.

type LedgerFailure added in v0.14.0

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

func (*LedgerFailure) Error added in v0.14.0

func (e *LedgerFailure) Error() string

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) error

func (MapLedger) Get

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

func (MapLedger) Set

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

func (MapLedger) Touch

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

type State added in v0.14.0

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

func NewState added in v0.14.0

func NewState(ledger Ledger, opts ...StateOption) *State

NewState constructs a new state

func (*State) Commit added in v0.14.0

func (s *State) Commit() error

func (*State) Delete added in v0.14.0

func (s *State) Delete(owner, controller, key string) error

func (*State) Get added in v0.14.0

func (s *State) Get(owner, controller, key string) (flow.RegisterValue, error)

func (*State) InteractionUsed added in v0.14.0

func (s *State) InteractionUsed() uint64

func (*State) Ledger added in v0.14.0

func (s *State) Ledger() Ledger

func (*State) Rollback added in v0.14.0

func (s *State) Rollback() error

func (*State) Set added in v0.14.0

func (s *State) Set(owner, controller, key string, value flow.RegisterValue) error

func (*State) Touch added in v0.14.0

func (s *State) Touch(owner, controller, key string) error

func (*State) UpdatedAddresses added in v0.14.0

func (s *State) UpdatedAddresses() []flow.Address

type StateBoundAddressGenerator added in v0.14.0

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

StateBoundAddressGenerator 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 NewStateBoundAddressGenerator added in v0.14.0

func NewStateBoundAddressGenerator(state *State, chain flow.Chain) (*StateBoundAddressGenerator, error)

func (*StateBoundAddressGenerator) Bytes added in v0.14.0

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

func (*StateBoundAddressGenerator) CurrentAddress added in v0.14.0

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

func (*StateBoundAddressGenerator) NextAddress added in v0.14.0

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

type StateInteractionLimitExceededError added in v0.14.0

type StateInteractionLimitExceededError struct {
	Used  uint64
	Limit uint64
}

A StateInteractionLimitExceededError

func (*StateInteractionLimitExceededError) Error added in v0.14.0

type StateKeySizeLimitError added in v0.14.0

type StateKeySizeLimitError struct {
	Owner      string
	Controller string
	Key        string
	Size       uint64
	Limit      uint64
}

A StateKeySizeLimitError indicates that the provided key has exceeded the size limit allowed by the storage

func (*StateKeySizeLimitError) Error added in v0.14.0

func (e *StateKeySizeLimitError) Error() string

type StateOption added in v0.14.0

type StateOption func(st *State) *State

type StateValueSizeLimitError added in v0.14.0

type StateValueSizeLimitError struct {
	Value flow.RegisterValue
	Size  uint64
	Limit uint64
}

A StateValueSizeLimitError indicates that the provided value has exceeded the size limit allowed by the storage

func (*StateValueSizeLimitError) Error added in v0.14.0

func (e *StateValueSizeLimitError) Error() string

type UUIDs

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

func NewUUIDs

func NewUUIDs(state *State) *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