state

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2017 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NameRegCodec = wire.Codec{
	Encode: NameRegEncoder,
	Decode: NameRegDecoder,
}

Functions

func DecodeNameRegEntry

func DecodeNameRegEntry(entryBytes []byte) *core_types.NameRegEntry

func ExecTx

func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable) (err error)

If the tx is invalid, an error will be returned. Unlike ExecBlock(), state will not be altered.

func HasPermission

func HasPermission(state AccountGetter, acc *acm.Account, perm ptypes.PermFlag) bool

Get permission on an account or fall back to global value

func NameRegDecoder

func NameRegDecoder(r io.Reader, n *int, err *error) interface{}

func NameRegEncoder

func NameRegEncoder(o interface{}, w io.Writer, n *int, err *error)

func NewContractAddress

func NewContractAddress(caller []byte, nonce int) []byte

Convenience function to return address of new contract

Types

type AccountGetter

type AccountGetter interface {
	GetAccount(addr []byte) *acm.Account
}

type BlockCache

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

The blockcache helps prevent unnecessary IAVLTree updates and garbage generation.

func NewBlockCache

func NewBlockCache(backend *State) *BlockCache

func (*BlockCache) GetAccount

func (cache *BlockCache) GetAccount(addr []byte) *acm.Account

func (*BlockCache) GetNameRegEntry

func (cache *BlockCache) GetNameRegEntry(name string) *core_types.NameRegEntry

func (*BlockCache) GetStorage

func (cache *BlockCache) GetStorage(addr Word256, key Word256) (value Word256)

func (*BlockCache) RemoveAccount

func (cache *BlockCache) RemoveAccount(addr []byte)

func (*BlockCache) RemoveNameRegEntry

func (cache *BlockCache) RemoveNameRegEntry(name string)

func (*BlockCache) SetStorage

func (cache *BlockCache) SetStorage(addr Word256, key Word256, value Word256)

NOTE: Set value to zero to removed from the trie.

func (*BlockCache) State

func (cache *BlockCache) State() *State

func (*BlockCache) Sync

func (cache *BlockCache) Sync()

CONTRACT the updates are in deterministic order.

func (*BlockCache) UpdateAccount

func (cache *BlockCache) UpdateAccount(acc *acm.Account)

func (*BlockCache) UpdateNameRegEntry

func (cache *BlockCache) UpdateNameRegEntry(entry *core_types.NameRegEntry)

type InvalidTxError

type InvalidTxError struct {
	Tx     txs.Tx
	Reason error
}

func (InvalidTxError) Error

func (txErr InvalidTxError) Error() string

type State

type State struct {
	DB              dbm.DB
	ChainID         string
	LastBlockHeight int
	LastBlockHash   []byte
	LastBlockParts  types.PartSetHeader
	LastBlockTime   time.Time
	// contains filtered or unexported fields
}

NOTE: not goroutine-safe.

func LoadState

func LoadState(db dbm.DB) *State

func MakeGenesisState

func MakeGenesisState(db dbm.DB, genDoc *genesis.GenesisDoc) *State

func MakeGenesisStateFromFile

func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) (*genesis.GenesisDoc, *State)

func (*State) Copy

func (s *State) Copy() *State

CONTRACT: Copy() is a cheap way to take a snapshot, as if State were copied by value.

func (*State) GetAccount

func (s *State) GetAccount(address []byte) *acm.Account

Returns nil if account does not exist with given address. Implements Statelike

func (*State) GetAccounts

func (s *State) GetAccounts() merkle.Tree

The returned Account is a copy, so mutating it has no side effects.

func (*State) GetGasLimit

func (s *State) GetGasLimit() int64

func (*State) GetGenesisDoc

func (s *State) GetGenesisDoc() (*genesis.GenesisDoc, error)

func (*State) GetNameRegEntry

func (s *State) GetNameRegEntry(name string) *core_types.NameRegEntry

func (*State) GetNames

func (s *State) GetNames() merkle.Tree

func (*State) Hash

func (s *State) Hash() []byte

Returns a hash that represents the state data, excluding Last*

func (*State) LoadStorage

func (s *State) LoadStorage(hash []byte) (storage merkle.Tree)

func (*State) RemoveAccount

func (s *State) RemoveAccount(address []byte) bool

Implements Statelike

func (*State) RemoveNameRegEntry

func (s *State) RemoveNameRegEntry(name string) bool

func (*State) Save

func (s *State) Save()

func (*State) SetAccounts

func (s *State) SetAccounts(accounts merkle.Tree)

Set the accounts tree

func (*State) SetDB

func (s *State) SetDB(db dbm.DB)

func (*State) SetFireable

func (s *State) SetFireable(evc events.Fireable)

Implements events.Eventable. Typically uses events.EventCache

func (*State) SetNameReg

func (s *State) SetNameReg(nameReg merkle.Tree)

Set the name reg tree

func (*State) UpdateAccount

func (s *State) UpdateAccount(account *acm.Account) bool

The account is copied before setting, so mutating it afterwards has no side effects. Implements Statelike

func (*State) UpdateNameRegEntry

func (s *State) UpdateNameRegEntry(entry *core_types.NameRegEntry) bool

type TxCache

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

func NewTxCache

func NewTxCache(backend *BlockCache) *TxCache

func (*TxCache) CreateAccount

func (cache *TxCache) CreateAccount(creator *vm.Account) *vm.Account

Creates a 20 byte address and bumps the creator's nonce.

func (*TxCache) GetAccount

func (cache *TxCache) GetAccount(addr Word256) *vm.Account

func (*TxCache) GetStorage

func (cache *TxCache) GetStorage(addr Word256, key Word256) Word256

func (*TxCache) RemoveAccount

func (cache *TxCache) RemoveAccount(acc *vm.Account)

func (*TxCache) SetStorage

func (cache *TxCache) SetStorage(addr Word256, key Word256, value Word256)

NOTE: Set value to zero to removed from the trie.

func (*TxCache) Sync

func (cache *TxCache) Sync()

These updates do not have to be in deterministic order, the backend is responsible for ordering updates.

func (*TxCache) UpdateAccount

func (cache *TxCache) UpdateAccount(acc *vm.Account)

type VMAccountState

type VMAccountState interface {
	GetAccount(addr Word256) *vm.Account
	UpdateAccount(acc *vm.Account)
	RemoveAccount(acc *vm.Account)
	CreateAccount(creator *vm.Account) *vm.Account
}

Jump to

Keyboard shortcuts

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