Documentation ¶
Index ¶
- Constants
- func ContractKey(contractName string) string
- func IsFVMStateKey(owner, controller, key string) bool
- func IsValidAccountKeyHashAlgo(algo hash.HashingAlgorithm) bool
- func IsValidAccountKeySignAlgo(algo crypto.SigningAlgorithm) bool
- func RegisterSize(address flow.Address, isController bool, key string, value flow.RegisterValue) int
- func WithMaxInteractionSizeAllowed(limit uint64) func(st *State) *State
- func WithMaxKeySizeAllowed(limit uint64) func(st *State) *State
- func WithMaxValueSizeAllowed(limit uint64) func(st *State) *State
- type Accounts
- func (a *Accounts) AppendPublicKey(address flow.Address, publicKey flow.AccountPublicKey) error
- func (a *Accounts) CheckAccountNotFrozen(address flow.Address) error
- func (a *Accounts) Create(publicKeys []flow.AccountPublicKey, newAddress flow.Address) error
- func (a *Accounts) DeleteContract(contractName string, address flow.Address) error
- func (a *Accounts) Exists(address flow.Address) (bool, error)
- func (a *Accounts) Get(address flow.Address) (*flow.Account, error)
- func (a *Accounts) GetAccountFrozen(address flow.Address) (bool, error)
- func (a *Accounts) GetContract(contractName string, address flow.Address) ([]byte, error)
- func (a *Accounts) GetContractNames(address flow.Address) ([]string, error)
- func (a *Accounts) GetPublicKey(address flow.Address, keyIndex uint64) (flow.AccountPublicKey, error)
- func (a *Accounts) GetPublicKeyCount(address flow.Address) (uint64, error)
- func (a *Accounts) GetPublicKeys(address flow.Address) (publicKeys []flow.AccountPublicKey, err error)
- func (a *Accounts) GetStorageUsed(address flow.Address) (uint64, error)
- func (a *Accounts) GetValue(address flow.Address, key string) (flow.RegisterValue, error)
- func (a *Accounts) SetAccountFrozen(address flow.Address, frozen bool) error
- func (a *Accounts) SetAllPublicKeys(address flow.Address, publicKeys []flow.AccountPublicKey) error
- func (a *Accounts) SetContract(contractName string, address flow.Address, contract []byte) error
- func (a *Accounts) SetPublicKey(address flow.Address, keyIndex uint64, publicKey flow.AccountPublicKey) (encodedPublicKey []byte, err error)
- func (a *Accounts) SetValue(address flow.Address, key string, value flow.RegisterValue) error
- func (a *Accounts) TouchContract(contractName string, address flow.Address)
- type Ledger
- type State
- func (s *State) Delete(owner, controller, key string) error
- func (s *State) Get(owner, controller, key string) (flow.RegisterValue, error)
- func (s *State) InteractionUsed() uint64
- func (s *State) MergeState(other *State) error
- func (s *State) NewChild() *State
- func (s *State) Set(owner, controller, key string, value flow.RegisterValue) error
- func (s *State) Touch(owner, controller, key string) error
- func (s *State) UpdatedAddresses() []flow.Address
- func (s *State) View() View
- type StateBoundAddressGenerator
- type StateHolder
- type StateOption
- type UUIDGenerator
- type View
Constants ¶
const ( KeyExists = "exists" KeyCode = "code" KeyContractNames = "contract_names" KeyPublicKeyCount = "public_key_count" KeyStorageUsed = "storage_used" KeyAccountFrozen = "frozen" AccountFrozenValue = 1 AccountNotFrozenValue = 0 )
const ( DefaultMaxKeySize = 16_000 // ~16KB DefaultMaxValueSize = 256_000_000 // ~256MB DefaultMaxInteractionSize = 2_000_000_000 // ~2GB )
TODO we started with high numbers here and we might tune (reduce) them when we have more data
Variables ¶
This section is empty.
Functions ¶
func ContractKey ¶ added in v0.15.0
func IsFVMStateKey ¶ added in v0.16.2
IsFVMStateKey returns true if the key is controlled by the fvm env and return false otherwise (key controlled by the cadence env)
func IsValidAccountKeyHashAlgo ¶ added in v0.15.0
func IsValidAccountKeyHashAlgo(algo hash.HashingAlgorithm) bool
func IsValidAccountKeySignAlgo ¶ added in v0.15.0
func IsValidAccountKeySignAlgo(algo crypto.SigningAlgorithm) bool
func RegisterSize ¶ added in v0.13.0
func WithMaxInteractionSizeAllowed ¶ added in v0.14.0
WithMaxInteractionSizeAllowed sets limit on total byte interaction with ledger
func WithMaxKeySizeAllowed ¶ added in v0.14.0
WithMaxKeySizeAllowed sets limit on max key size
func WithMaxValueSizeAllowed ¶ added in v0.14.0
WithMaxValueSizeAllowed sets limit on max value size
Types ¶
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
func NewAccounts ¶
func NewAccounts(stateHolder *StateHolder) *Accounts
func (*Accounts) AppendPublicKey ¶
func (*Accounts) CheckAccountNotFrozen ¶ added in v0.15.1
handy function to error out if account is frozen
func (*Accounts) DeleteContract ¶ added in v0.12.0
func (*Accounts) GetAccountFrozen ¶ added in v0.15.1
func (*Accounts) GetContract ¶ added in v0.12.0
func (*Accounts) GetContractNames ¶ added in v0.12.0
GetContractNames gets a sorted list of names of contracts deployed on an address
func (*Accounts) GetPublicKey ¶
func (*Accounts) GetPublicKeyCount ¶
func (*Accounts) GetPublicKeys ¶
func (*Accounts) GetStorageUsed ¶ added in v0.13.0
GetStorageUsed returns the amount of storage used in bytes by this account
func (*Accounts) SetAccountFrozen ¶ added in v0.15.1
func (*Accounts) SetAllPublicKeys ¶
func (*Accounts) SetContract ¶ added in v0.12.0
func (*Accounts) SetPublicKey ¶
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 State ¶ added in v0.14.0
type State struct { ReadCounter uint64 WriteCounter uint64 TotalBytesRead uint64 TotalBytesWritten uint64 // contains filtered or unexported fields }
State represents the execution state it holds draft of updates and captures all register touches
func NewState ¶ added in v0.14.0
func NewState(view View, opts ...StateOption) *State
NewState constructs a new state
func (*State) Get ¶ added in v0.14.0
func (s *State) Get(owner, controller, key string) (flow.RegisterValue, error)
Get returns a register value given owner, controller and key
func (*State) InteractionUsed ¶ added in v0.14.0
InteractionUsed returns the amount of ledger interaction (total ledger byte read + total ledger byte written)
func (*State) MergeState ¶ added in v0.15.0
MergeState applies the changes from a the given view to this view.
func (*State) Set ¶ added in v0.14.0
func (s *State) Set(owner, controller, key string, value flow.RegisterValue) error
Set updates state delta with a register update
func (*State) Touch ¶ added in v0.14.0
We don't need this later, it should be invisible to the cadence
func (*State) UpdatedAddresses ¶ added in v0.14.0
UpdatedAddresses returns a list of addresses that were updated (at least 1 register update)
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(stateHolder *StateHolder, chain flow.Chain) *StateBoundAddressGenerator
func (*StateBoundAddressGenerator) Bytes ¶ added in v0.14.0
func (g *StateBoundAddressGenerator) Bytes() []byte
TODO return error instead of a panic this requires changes outside of fvm since the type is defined on flow model and emulator and others might be dependent on that
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 StateHolder ¶ added in v0.15.0
type StateHolder struct {
// contains filtered or unexported fields
}
StateHolder provides active states and facilitates common state management operations in order to make services such as accounts not worry about the state it is recommended that such services wraps an state manager instead of an state itself.
func NewStateHolder ¶ added in v0.15.0
func NewStateHolder(startState *State) *StateHolder
NewStateHolder constructs a new state manager
func (*StateHolder) NewChild ¶ added in v0.15.0
func (s *StateHolder) NewChild() *State
NewChild constructs a new child of active state and set it as active state and return it this is basically a utility function for common operations
func (*StateHolder) SetActiveState ¶ added in v0.15.0
func (s *StateHolder) SetActiveState(st *State)
SetActiveState sets active state
func (*StateHolder) State ¶ added in v0.15.0
func (s *StateHolder) State() *State
State returns the active state
type StateOption ¶ added in v0.14.0
type UUIDGenerator ¶ added in v0.15.0
type UUIDGenerator struct {
// contains filtered or unexported fields
}
func NewUUIDGenerator ¶ added in v0.15.0
func NewUUIDGenerator(stateHolder *StateHolder) *UUIDGenerator
func (*UUIDGenerator) GenerateUUID ¶ added in v0.15.0
func (u *UUIDGenerator) GenerateUUID() (uint64, error)
GenerateUUID generates a new uuid and persist the data changes into state
func (*UUIDGenerator) GetUUID ¶ added in v0.15.0
func (u *UUIDGenerator) GetUUID() (uint64, error)
GetUUID reads uint64 byte value for uuid from the state
func (*UUIDGenerator) SetUUID ¶ added in v0.15.0
func (u *UUIDGenerator) SetUUID(uuid uint64) error
SetUUID sets a new uint64 byte value
type View ¶ added in v0.15.0
type View interface { NewChild() View MergeView(child View) error DropDelta() // drops all the delta changes RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue) AllRegisters() []flow.RegisterID Ledger }