state

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendBalance added in v2.5.0

func SendBalance(sender, receiver *AccountState, amount *big.Int) 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, stOld, stNew *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) CodeHash added in v2.5.0

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

func (*AccountState) ID added in v2.5.0

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

func (*AccountState) IDNoPadding added in v2.5.0

func (as *AccountState) IDNoPadding() []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) Nonce added in v2.5.0

func (as *AccountState) Nonce() uint64

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) SetCodeHash added in v2.5.0

func (as *AccountState) SetCodeHash(codeHash []byte)

func (*AccountState) SetNonce added in v2.5.0

func (as *AccountState) SetNonce(nonce uint64)

func (*AccountState) SetRP added in v2.5.0

func (as *AccountState) SetRP(sqlRecoveryPoint uint64)

func (*AccountState) SetRedeploy added in v2.5.0

func (as *AccountState) SetRedeploy()

func (*AccountState) SetStorageRoot added in v2.5.0

func (as *AccountState) SetStorageRoot(storageRoot []byte)

func (*AccountState) State added in v2.5.0

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

func (*AccountState) StorageRoot added in v2.5.0

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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