state

package
v2.4.8-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 17 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 BlockSnapshot

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

type BlockState

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

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

func (bs *BlockState) AddABI(key types.AccountID, abi *types.ABI)

func (*BlockState) AddCode

func (bs *BlockState) AddCode(key types.AccountID, code []byte)

func (*BlockState) AddReceipt

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

func (*BlockState) Consensus

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

func (*BlockState) GetABI

func (bs *BlockState) GetABI(key types.AccountID) *types.ABI

func (*BlockState) GetCode

func (bs *BlockState) GetCode(key types.AccountID) []byte

func (*BlockState) PrevBlockHash

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

func (*BlockState) Receipts

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

func (*BlockState) RemoveCache

func (bs *BlockState) RemoveCache(key types.AccountID)

func (*BlockState) Rollback

func (bs *BlockState) Rollback(bSnap BlockSnapshot) error

func (*BlockState) SetConsensus

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

func (*BlockState) SetGasPrice

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

func (*BlockState) SetPrevBlockHash

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

func (*BlockState) SetTimeoutTx

func (bs *BlockState) SetTimeoutTx(tx types.Transaction)

func (*BlockState) Snapshot

func (bs *BlockState) Snapshot() BlockSnapshot

func (*BlockState) TimeoutTx

func (bs *BlockState) TimeoutTx() types.Transaction

type BlockStateOptFn

type BlockStateOptFn func(s *BlockState)

func SetGasPrice

func SetGasPrice(gasPrice *big.Int) BlockStateOptFn

func SetPrevBlockHash

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

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

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

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

DeleteData remove key and value pair from the storage.

func (*ContractState) GetAccountID

func (st *ContractState) GetAccountID() types.AccountID

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

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

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

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

func (*ContractState) HasKey

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

HasKey returns existence of the key

func (*ContractState) Hash

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

Hash implements types.ImplHashBytes

func (*ContractState) Marshal

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

Marshal implements types.ImplMarshal

func (*ContractState) Rollback

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

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

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

func (*ContractState) Snapshot

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

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

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

GetEnterpriseAccountState returns the ContractState of the AERGO enterprise account.

func (*StateDB) GetNameAccountState

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

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

GetSystemAccountState returns the ContractState of the AERGO system account.

func (*StateDB) GetVarAndProof

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

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

HasMarker represents that the state root is finalized or not.

func (*StateDB) InitAccountStateV

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

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

func (*StateDB) TrieQuery

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

func (v *V) ClearAid()

func (*V) ID

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

func (*V) IsDeploy

func (v *V) IsDeploy() bool

func (*V) IsNew

func (v *V) IsNew() bool

func (*V) IsRedeploy

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

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