state

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockInfo

type BlockInfo struct {
	BlockHash types.BlockID
	StateRoot types.HashID
}

BlockInfo contains BlockHash and StateRoot

func (*BlockInfo) GetStateRoot

func (bi *BlockInfo) GetStateRoot() []byte

GetStateRoot return bytes of bi.StateRoot

type BlockState

type BlockState struct {
	StateDB
	BpReward big.Int // final bp reward, increment when tx executes

	CodeMap    codeCache
	CCProposal *consensus.ConfChangePropose

	GasPrice *big.Int
	// contains filtered or unexported fields
}

BlockState contains BlockInfo and statedb for block

func NewBlockState

func NewBlockState(states *StateDB, options ...BlockStateOptFn) *BlockState

NewBlockState create new blockState contains blockInfo, account states and undo states

func (*BlockState) AddReceipt

func (bs *BlockState) AddReceipt(r *types.Receipt) error

func (*BlockState) Consensus added in v1.3.3

func (bs *BlockState) Consensus() []byte

func (*BlockState) PrevBlockHash added in v1.3.3

func (bs *BlockState) PrevBlockHash() []byte

func (*BlockState) Receipts

func (bs *BlockState) Receipts() *types.Receipts

func (*BlockState) SetConsensus added in v1.3.3

func (bs *BlockState) SetConsensus(ch []byte)

func (*BlockState) SetGasPrice added in v1.3.3

func (bs *BlockState) SetGasPrice(gasPrice *big.Int) *BlockState

func (*BlockState) SetPrevBlockHash added in v1.3.3

func (bs *BlockState) SetPrevBlockHash(prevHash []byte) *BlockState

type BlockStateOptFn added in v1.3.3

type BlockStateOptFn func(s *BlockState)

func SetGasPrice added in v1.3.3

func SetGasPrice(gasPrice *big.Int) BlockStateOptFn

func SetPrevBlockHash added in v1.3.3

func SetPrevBlockHash(h []byte) BlockStateOptFn

type ChainStateDB

type ChainStateDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ChainStateDB manages statedb and additional informations about blocks like a state root hash

func NewChainStateDB

func NewChainStateDB() *ChainStateDB

NewChainStateDB creates instance of ChainStateDB

func (*ChainStateDB) Apply

func (sdb *ChainStateDB) Apply(bstate *BlockState) error

Apply specific blockstate to statedb of main chain

func (*ChainStateDB) Clone

func (sdb *ChainStateDB) Clone() *ChainStateDB

Init initialize database and load statedb of latest block

func (*ChainStateDB) Close

func (sdb *ChainStateDB) Close() error

Close saves latest block information of the chain

func (*ChainStateDB) GetRoot

func (sdb *ChainStateDB) GetRoot() []byte

GetRoot returns state root hash

func (*ChainStateDB) GetStateDB

func (sdb *ChainStateDB) GetStateDB() *StateDB

GetStateDB returns statedb stores account states

func (*ChainStateDB) GetSystemAccountState added in v0.9.4

func (sdb *ChainStateDB) GetSystemAccountState() (*ContractState, error)

GetSystemAccountState returns the state of the aergo system account.

func (*ChainStateDB) Init

func (sdb *ChainStateDB) Init(dbType string, dataDir string, bestBlock *types.Block, test bool) error

Init initialize database and load statedb of latest block

func (*ChainStateDB) IsExistState

func (sdb *ChainStateDB) IsExistState(hash []byte) bool

func (*ChainStateDB) NewBlockState

func (sdb *ChainStateDB) NewBlockState(root []byte, options ...BlockStateOptFn) *BlockState

func (*ChainStateDB) OpenNewStateDB

func (sdb *ChainStateDB) OpenNewStateDB(root []byte) *StateDB

OpenNewStateDB returns new instance of statedb given state root hash

func (*ChainStateDB) SetGenesis

func (sdb *ChainStateDB) SetGenesis(genesis *types.Genesis, bpInit func(*StateDB, *types.Genesis) error) error

func (*ChainStateDB) SetRoot added in v1.3.3

func (sdb *ChainStateDB) SetRoot(targetBlockRoot []byte) error

func (*ChainStateDB) UpdateRoot

func (sdb *ChainStateDB) UpdateRoot(bstate *BlockState) error

type ContractState

type ContractState struct {
	*types.State
	// contains filtered or unexported fields
}

func (*ContractState) DeleteData added in v0.8.2

func (st *ContractState) DeleteData(key []byte) error

DeleteData remove key and value pair from the storage.

func (*ContractState) GetBalance

func (st *ContractState) GetBalance() *big.Int

func (*ContractState) GetCode

func (st *ContractState) GetCode() ([]byte, error)

func (*ContractState) GetData

func (st *ContractState) GetData(key []byte) ([]byte, error)

GetData returns the value corresponding to the key from the buffered storage.

func (*ContractState) GetInitialData added in v0.10.0

func (st *ContractState) GetInitialData(key []byte) ([]byte, error)

GetInitialData returns the value corresponding to the key from the contract storage.

func (*ContractState) GetNonce

func (st *ContractState) GetNonce() uint64

func (*ContractState) GetRawKV added in v1.3.3

func (st *ContractState) GetRawKV(key []byte) ([]byte, error)

GetRawKV loads (key, value) from st.store.

func (*ContractState) HasKey added in v1.3.3

func (st *ContractState) HasKey(key []byte) bool

HasKey returns existence of the key

func (*ContractState) Hash added in v0.8.2

func (st *ContractState) Hash() []byte

Hash implements types.ImplHashBytes

func (*ContractState) Marshal added in v0.8.1

func (st *ContractState) Marshal() ([]byte, error)

Marshal implements types.ImplMarshal

func (*ContractState) Rollback added in v0.8.1

func (st *ContractState) Rollback(revision Snapshot) error

Rollback discards changes of storage buffer to revision number

func (*ContractState) SetBalance

func (st *ContractState) SetBalance(balance *big.Int)

func (*ContractState) SetCode

func (st *ContractState) SetCode(code []byte) error

func (*ContractState) SetData

func (st *ContractState) SetData(key, value []byte) error

SetData store key and value pair to the storage.

func (*ContractState) SetNonce

func (st *ContractState) SetNonce(nonce uint64)

func (*ContractState) SetRawKV added in v1.3.3

func (st *ContractState) SetRawKV(key []byte, value []byte) error

SetRawKV saves (key, value) to st.store without any kind of encoding.

func (*ContractState) Snapshot added in v0.8.1

func (st *ContractState) Snapshot() Snapshot

Snapshot returns revision number of storage buffer

type Snapshot

type Snapshot int

Snapshot represents revision number of statedb

type StateDB

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

StateDB manages trie of states

func NewStateDB

func NewStateDB(dbstore db.DB, root []byte, test bool) *StateDB

NewStateDB craete StateDB instance

func (*StateDB) Clone

func (states *StateDB) Clone() *StateDB

Clone returns a new StateDB which has same store and Root

func (*StateDB) Commit

func (states *StateDB) Commit() error

Commit writes state buffer and trie to db

func (*StateDB) CreateAccountStateV

func (states *StateDB) CreateAccountStateV(id []byte) (*V, error)

func (*StateDB) GetAccountAndProof added in v0.11.0

func (states *StateDB) GetAccountAndProof(id []byte, root []byte, compressed bool) (*types.AccountProof, error)

GetAccountAndProof gets the state and associated proof of an account in the given trie root. If the account doesnt exist, a proof of non existence is returned.

func (*StateDB) GetAccountState

func (states *StateDB) GetAccountState(id types.AccountID) (*types.State, error)

GetAccountState gets state of account id from statedb. empty state is returned when there is no state corresponding to account id.

func (*StateDB) GetAccountStateV

func (states *StateDB) GetAccountStateV(id []byte) (*V, error)

func (*StateDB) GetEnterpriseAccountState added in v1.3.3

func (states *StateDB) GetEnterpriseAccountState() (*ContractState, error)

GetEnterpriseAccountState returns the ContractState of the AERGO enterprise account.

func (*StateDB) GetNameAccountState added in v1.3.3

func (states *StateDB) GetNameAccountState() (*ContractState, error)

GetNameAccountState returns the ContractState of the AERGO name account.

func (*StateDB) GetRoot

func (states *StateDB) GetRoot() []byte

GetRoot returns root hash of trie

func (*StateDB) GetState

func (states *StateDB) GetState(id types.AccountID) (*types.State, error)

GetState gets state of account id from state buffer and trie. nil value is returned when there is no state corresponding to account id.

func (*StateDB) GetSystemAccountState added in v0.11.0

func (states *StateDB) GetSystemAccountState() (*ContractState, error)

GetSystemAccountState returns the ContractState of the AERGO system account.

func (*StateDB) GetVarAndProof added in v0.8.1

func (states *StateDB) GetVarAndProof(id []byte, root []byte, compressed bool) (*types.ContractVarProof, error)

GetVarAndProof gets the value of a variable in the given contract trie root.

func (*StateDB) HasMarker added in v1.3.3

func (states *StateDB) HasMarker(root []byte) bool

HasMarker represents that the state root is finalized or not.

func (*StateDB) InitAccountStateV added in v1.0.0

func (states *StateDB) InitAccountStateV(id []byte, old *types.State, new *types.State) *V

func (*StateDB) LoadCache

func (states *StateDB) LoadCache(root []byte) error

LoadCache reads first layer of trie given root hash and also updates root node of trie as a given root hash

func (*StateDB) OpenContractState

func (states *StateDB) OpenContractState(aid types.AccountID, st *types.State) (*ContractState, error)

func (*StateDB) OpenContractStateAccount

func (states *StateDB) OpenContractStateAccount(aid types.AccountID) (*ContractState, error)

func (*StateDB) PutState

func (states *StateDB) PutState(id types.AccountID, state *types.State) error

PutState puts account id and its state into state buffer.

func (*StateDB) Revert

func (states *StateDB) Revert(root types.HashID) error

Revert rollbacks trie to previous root hash

func (*StateDB) Rollback

func (states *StateDB) Rollback(revision Snapshot) error

Rollback discards changes of state buffer to revision number

func (*StateDB) SetRoot

func (states *StateDB) SetRoot(root []byte) error

SetRoot updates root node of trie as a given root hash

func (*StateDB) Snapshot

func (states *StateDB) Snapshot() Snapshot

Snapshot returns revision number of state buffer

func (*StateDB) StageContractState added in v0.8.1

func (states *StateDB) StageContractState(st *ContractState) error

func (*StateDB) TrieQuery added in v0.8.1

func (states *StateDB) TrieQuery(id []byte, root []byte, compressed bool) ([]byte, [][]byte, int, bool, []byte, []byte, error)

func (*StateDB) Update

func (states *StateDB) Update() error

Update applies changes of state buffer to trie

type V

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

func (*V) AccountID

func (v *V) AccountID() types.AccountID

func (*V) AddBalance

func (v *V) AddBalance(amount *big.Int)

func (*V) Balance

func (v *V) Balance() *big.Int

func (*V) ID

func (v *V) ID() []byte

func (*V) IsDeploy added in v1.3.3

func (v *V) IsDeploy() bool

func (*V) IsNew

func (v *V) IsNew() bool

func (*V) IsRedeploy added in v1.3.3

func (v *V) IsRedeploy() bool

func (*V) PutState

func (v *V) PutState() error

func (*V) RP

func (v *V) RP() uint64

func (*V) Reset

func (v *V) Reset()

func (*V) SetNonce

func (v *V) SetNonce(nonce uint64)

func (*V) SetRedeploy added in v1.3.3

func (v *V) SetRedeploy()

func (*V) State

func (v *V) State() *types.State

func (*V) SubBalance

func (v *V) SubBalance(amount *big.Int)

Jump to

Keyboard shortcuts

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