state

package
v2.6.0-dev1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StageContractState

func StageContractState(st *ContractState, states *statedb.StateDB) error

Types

type AccountState added in v2.5.0

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

func CreateAccountState added in v2.5.0

func CreateAccountState(id []byte, sdb *statedb.StateDB) (*AccountState, error)

func GetAccountState added in v2.5.0

func GetAccountState(id []byte, states *statedb.StateDB) (*AccountState, error)

func InitAccountState added in v2.5.0

func InitAccountState(id []byte, sdb *statedb.StateDB, old *types.State, new *types.State) *AccountState

func (*AccountState) AccountID added in v2.5.0

func (as *AccountState) AccountID() types.AccountID

func (*AccountState) AddBalance added in v2.5.0

func (as *AccountState) AddBalance(amount *big.Int)

func (*AccountState) Balance added in v2.5.0

func (as *AccountState) Balance() *big.Int

func (*AccountState) ClearAid

func (as *AccountState) ClearAid()

func (*AccountState) ID added in v2.5.0

func (as *AccountState) ID() []byte

func (*AccountState) IsContract added in v2.5.0

func (as *AccountState) IsContract() bool

func (*AccountState) IsDeploy added in v2.5.0

func (as *AccountState) IsDeploy() bool

func (*AccountState) IsNew added in v2.5.0

func (as *AccountState) IsNew() bool

func (*AccountState) IsRedeploy added in v2.5.0

func (as *AccountState) IsRedeploy() bool

func (*AccountState) PutState added in v2.5.0

func (as *AccountState) PutState() error

func (*AccountState) RP added in v2.5.0

func (as *AccountState) RP() uint64

func (*AccountState) Reset added in v2.5.0

func (as *AccountState) Reset()

func (*AccountState) SetNonce added in v2.5.0

func (as *AccountState) SetNonce(nonce uint64)

func (*AccountState) SetRedeploy added in v2.5.0

func (as *AccountState) SetRedeploy()

func (*AccountState) State added in v2.5.0

func (as *AccountState) State() *types.State

func (*AccountState) SubBalance added in v2.5.0

func (as *AccountState) SubBalance(amount *big.Int)

type BlockSnapshot

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

type BlockState

type BlockState struct {
	*statedb.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.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.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.StateDB

OpenNewStateDB returns new instance of statedb given state root hash

func (*ChainStateDB) SetGenesis

func (sdb *ChainStateDB) SetGenesis(genesis *types.Genesis, bpInit func(*statedb.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 GetEnterpriseAccountState

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

GetEnterpriseAccountState returns the ContractState of the AERGO enterprise account.

func GetNameAccountState

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

GetNameAccountState returns the ContractState of the AERGO name account.

func GetSystemAccountState

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

GetSystemAccountState returns the ContractState of the AERGO system account.

func OpenContractState

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

func OpenContractStateAccount

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

func (*ContractState) DeleteData

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

DeleteData remove key and value pair from the storage.

func (*ContractState) GetAccountID

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

func (*ContractState) GetBalance

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

func (*ContractState) GetCode

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

func (*ContractState) GetData

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

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

func (*ContractState) GetInitialData

func (cs *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 (cs *ContractState) GetRawKV(key []byte) ([]byte, error)

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

func (*ContractState) HasKey

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

HasKey returns existence of the key

func (*ContractState) Hash

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

Hash implements types.ImplHashBytes

func (*ContractState) Marshal

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

Marshal implements types.ImplMarshal

func (*ContractState) Rollback

func (cs *ContractState) Rollback(revision statedb.Snapshot) error

Rollback discards changes of storage buffer to revision number

func (*ContractState) SetBalance

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

func (*ContractState) SetCode

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

func (*ContractState) SetData

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

SetData store key and value pair to the storage.

func (*ContractState) SetNonce

func (cs *ContractState) SetNonce(nonce uint64)

func (*ContractState) SetRawKV

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

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

func (*ContractState) Snapshot

func (cs *ContractState) Snapshot() statedb.Snapshot

Snapshot returns revision number of storage buffer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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