Documentation ¶
Index ¶
- type BlockInfo
- type BlockSnapshot
- type BlockState
- func (bs *BlockState) AddABI(key types.AccountID, abi *types.ABI)
- func (bs *BlockState) AddCode(key types.AccountID, code []byte)
- func (bs *BlockState) AddReceipt(r *types.Receipt) error
- func (bs *BlockState) Consensus() []byte
- func (bs *BlockState) GetABI(key types.AccountID) *types.ABI
- func (bs *BlockState) GetCode(key types.AccountID) []byte
- func (bs *BlockState) PrevBlockHash() []byte
- func (bs *BlockState) Receipts() *types.Receipts
- func (bs *BlockState) RemoveCache(key types.AccountID)
- func (bs *BlockState) Rollback(bSnap BlockSnapshot) error
- func (bs *BlockState) SetConsensus(ch []byte)
- func (bs *BlockState) SetGasPrice(gasPrice *big.Int) *BlockState
- func (bs *BlockState) SetPrevBlockHash(prevHash []byte) *BlockState
- func (bs *BlockState) SetTimeoutTx(tx types.Transaction)
- func (bs *BlockState) Snapshot() BlockSnapshot
- func (bs *BlockState) TimeoutTx() types.Transaction
- type BlockStateOptFn
- type ChainStateDB
- func (sdb *ChainStateDB) Apply(bstate *BlockState) error
- func (sdb *ChainStateDB) Clone() *ChainStateDB
- func (sdb *ChainStateDB) Close() error
- func (sdb *ChainStateDB) GetRoot() []byte
- func (sdb *ChainStateDB) GetStateDB() *StateDB
- func (sdb *ChainStateDB) GetSystemAccountState() (*ContractState, error)
- func (sdb *ChainStateDB) Init(dbType string, dataDir string, bestBlock *types.Block, test bool) error
- func (sdb *ChainStateDB) IsExistState(hash []byte) bool
- func (sdb *ChainStateDB) NewBlockState(root []byte, options ...BlockStateOptFn) *BlockState
- func (sdb *ChainStateDB) OpenNewStateDB(root []byte) *StateDB
- func (sdb *ChainStateDB) SetGenesis(genesis *types.Genesis, bpInit func(*StateDB, *types.Genesis) error) error
- func (sdb *ChainStateDB) SetRoot(targetBlockRoot []byte) error
- func (sdb *ChainStateDB) UpdateRoot(bstate *BlockState) error
- type ContractState
- func (st *ContractState) DeleteData(key []byte) error
- func (st *ContractState) GetAccountID() types.AccountID
- func (st *ContractState) GetBalance() *big.Int
- func (st *ContractState) GetCode() ([]byte, error)
- func (st *ContractState) GetData(key []byte) ([]byte, error)
- func (st *ContractState) GetInitialData(key []byte) ([]byte, error)
- func (st *ContractState) GetNonce() uint64
- func (st *ContractState) GetRawKV(key []byte) ([]byte, error)
- func (st *ContractState) HasKey(key []byte) bool
- func (st *ContractState) Hash() []byte
- func (st *ContractState) Marshal() ([]byte, error)
- func (st *ContractState) Rollback(revision Snapshot) error
- func (st *ContractState) SetBalance(balance *big.Int)
- func (st *ContractState) SetCode(code []byte) error
- func (st *ContractState) SetData(key, value []byte) error
- func (st *ContractState) SetNonce(nonce uint64)
- func (st *ContractState) SetRawKV(key []byte, value []byte) error
- func (st *ContractState) Snapshot() Snapshot
- type Snapshot
- type StateDB
- func (states *StateDB) Clone() *StateDB
- func (states *StateDB) Commit() error
- func (states *StateDB) CreateAccountStateV(id []byte) (*V, error)
- func (states *StateDB) GetAccountAndProof(id []byte, root []byte, compressed bool) (*types.AccountProof, error)
- func (states *StateDB) GetAccountState(id types.AccountID) (*types.State, error)
- func (states *StateDB) GetAccountStateV(id []byte) (*V, error)
- func (states *StateDB) GetEnterpriseAccountState() (*ContractState, error)
- func (states *StateDB) GetNameAccountState() (*ContractState, error)
- func (states *StateDB) GetRoot() []byte
- func (states *StateDB) GetState(id types.AccountID) (*types.State, error)
- func (states *StateDB) GetSystemAccountState() (*ContractState, error)
- func (states *StateDB) GetVarAndProof(id []byte, root []byte, compressed bool) (*types.ContractVarProof, error)
- func (states *StateDB) HasMarker(root []byte) bool
- func (states *StateDB) InitAccountStateV(id []byte, old *types.State, new *types.State) *V
- func (states *StateDB) LoadCache(root []byte) error
- func (states *StateDB) OpenContractState(aid types.AccountID, st *types.State) (*ContractState, error)
- func (states *StateDB) OpenContractStateAccount(aid types.AccountID) (*ContractState, error)
- func (states *StateDB) PutState(id types.AccountID, state *types.State) error
- func (states *StateDB) Revert(root types.HashID) error
- func (states *StateDB) Rollback(revision Snapshot) error
- func (states *StateDB) SetRoot(root []byte) error
- func (states *StateDB) Snapshot() Snapshot
- func (states *StateDB) StageContractState(st *ContractState) error
- func (states *StateDB) TrieQuery(id []byte, root []byte, compressed bool) ([]byte, [][]byte, int, bool, []byte, []byte, error)
- func (states *StateDB) Update() error
- type V
- func (v *V) AccountID() types.AccountID
- func (v *V) AddBalance(amount *big.Int)
- func (v *V) Balance() *big.Int
- func (v *V) ClearAid()
- func (v *V) ID() []byte
- func (v *V) IsDeploy() bool
- func (v *V) IsNew() bool
- func (v *V) IsRedeploy() bool
- func (v *V) PutState() error
- func (v *V) RP() uint64
- func (v *V) Reset()
- func (v *V) SetNonce(nonce uint64)
- func (v *V) SetRedeploy()
- func (v *V) State() *types.State
- func (v *V) SubBalance(amount *big.Int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockInfo ¶
BlockInfo contains BlockHash and StateRoot
func (*BlockInfo) GetStateRoot ¶
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) AddReceipt ¶
func (bs *BlockState) AddReceipt(r *types.Receipt) error
func (*BlockState) Consensus ¶
func (bs *BlockState) Consensus() []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 ¶
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 (*ChainStateDB) SetRoot ¶
func (sdb *ChainStateDB) SetRoot(targetBlockRoot []byte) error
func (*ChainStateDB) UpdateRoot ¶
func (sdb *ChainStateDB) UpdateRoot(bstate *BlockState) error
type ContractState ¶
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 StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
StateDB manages trie of states
func NewStateDB ¶
NewStateDB craete StateDB instance
func (*StateDB) CreateAccountStateV ¶
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 ¶
GetAccountState gets state of account id from statedb. empty state is returned when there is no state corresponding to account id.
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) GetState ¶
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) InitAccountStateV ¶
func (*StateDB) LoadCache ¶
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 (*StateDB) OpenContractStateAccount ¶
func (states *StateDB) OpenContractStateAccount(aid types.AccountID) (*ContractState, error)
func (*StateDB) StageContractState ¶
func (states *StateDB) StageContractState(st *ContractState) error
type V ¶
type V struct {
// contains filtered or unexported fields
}
func (*V) AddBalance ¶
func (*V) IsRedeploy ¶
func (*V) SetRedeploy ¶
func (v *V) SetRedeploy()