statedb

package
v0.0.0-...-24d451d Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StateDB

type StateDB struct {
	Transaction *statedb.Transaction
}

func NewStateDB

func NewStateDB() *StateDB

func (*StateDB) BeginBlock

func (sdb *StateDB) BeginBlock(transaction *statedb.Transaction)

func (*StateDB) CheckAccountNonce

func (sdb *StateDB) CheckAccountNonce(exAddress smc.Address, nonce uint64) error

CheckTx需要调用此接口检查nonce

func (*StateDB) CommitBlock

func (sdb *StateDB) CommitBlock() error

func (*StateDB) CommitTx

func (sdb *StateDB) CommitTx(txBuffer map[string][]byte)

func (*StateDB) Get

func (sdb *StateDB) Get(key string) ([]byte, error)

func (*StateDB) GetAccountNonce

func (sdb *StateDB) GetAccountNonce(exAddress smc.Address) (uint64, error)

Get nonce of the account

func (*StateDB) GetAllValidators

func (sdb *StateDB) GetAllValidators() ([]types.Validator, error)

func (*StateDB) GetBalance

func (sdb *StateDB) GetBalance(contractAddress smc.Address, exAddress smc.Address) (big.Int, error)

先在内存中找,如果找不到,再到db中找

func (*StateDB) GetBlockBuffer

func (sdb *StateDB) GetBlockBuffer() []byte

func (*StateDB) GetChainID

func (sdb *StateDB) GetChainID() string

func (*StateDB) GetContract

func (sdb *StateDB) GetContract(contractAddr smc.Address) (*types.Contract, error)

func (*StateDB) GetContractAddrList

func (sdb *StateDB) GetContractAddrList() ([]string, error)

func (*StateDB) GetGenesisContract

func (sdb *StateDB) GetGenesisContract(contractAddr smc.Address) (*types.Contract, error)

func (*StateDB) GetGenesisContractList

func (sdb *StateDB) GetGenesisContractList() ([]string, error)

func (*StateDB) GetGenesisToken

func (sdb *StateDB) GetGenesisToken() (*types.IssueToken, error)

func (*StateDB) GetToken

func (sdb *StateDB) GetToken(contractAddr smc.Address) (*types.IssueToken, error)

func (*StateDB) GetTokenAddrList

func (sdb *StateDB) GetTokenAddrList() ([]string, error)

func (*StateDB) GetTokenBalListWithAccAddr

func (sdb *StateDB) GetTokenBalListWithAccAddr(accountAddr smc.Address) ([]types.TokenBalance, error)

func (*StateDB) GetValidator

func (sdb *StateDB) GetValidator(nodeAddr string) (*types.Validator, error)

func (*StateDB) GetWorldAppState

func (sdb *StateDB) GetWorldAppState() (*abci.AppState, error)

func (*StateDB) NewTxState

func (sdb *StateDB) NewTxState(contractAddress smc.Address, senderAddress smc.Address) *TxState

func (*StateDB) RollBlock

func (sdb *StateDB) RollBlock()

func (*StateDB) Set

func (sdb *StateDB) Set(key string, value []byte)

func (*StateDB) SetAccountNonce

func (sdb *StateDB) SetAccountNonce(exAddress smc.Address, nonce uint64) (nonceBuffer map[string][]byte, err error)

DeliverTx需要调用此接口检查并设置nonce

func (*StateDB) SetChainID

func (sdb *StateDB) SetChainID(chainID string)

func (*StateDB) SetGenesisContract

func (sdb *StateDB) SetGenesisContract(contract *types.Contract) error

func (*StateDB) SetGenesisToken

func (sdb *StateDB) SetGenesisToken(genesisToken *types.IssueToken) error

先设置合约,再设置代币

func (*StateDB) SetStrategys

func (sdb *StateDB) SetStrategys(strategys []types.RewardStrategy) error

func (*StateDB) SetValidator

func (sdb *StateDB) SetValidator(validator *types.Validator) error

func (*StateDB) SetWorldAppState

func (sdb *StateDB) SetWorldAppState(appState *abci.AppState) error

type TxState

type TxState struct {
	StateDB         *StateDB //read
	ContractAddress smc.Address
	SenderAddress   smc.Address
	Tx              *statedb.Tx
}

func (*TxState) AddChildKey

func (txState *TxState) AddChildKey(key string, childKey string) error

func (*TxState) CheckBlackAddress

func (txState *TxState) CheckBlackAddress(address smc.Address) bool

func (*TxState) CommitTx

func (txState *TxState) CommitTx() ([]byte, map[string][]byte)

提交Tx缓存到block缓存,清除Tx缓存,把Tx缓存中的内容转换为字节数组返回

func (*TxState) DeleteContractAddr

func (txState *TxState) DeleteContractAddr(exAddress smc.Address, contractAddr smc.Address) error

func (*TxState) Get

func (txState *TxState) Get(key string) ([]byte, error)

按照Tx缓存、block缓存、数据库顺序找

func (*TxState) GetAllValidatorPubKeys

func (txState *TxState) GetAllValidatorPubKeys() ([]string, error)

func (*TxState) GetBalance

func (txState *TxState) GetBalance(exAddress smc.Address, tokenAddress smc.Address) (big.Int, error)

func (*TxState) GetBaseGasPrice

func (txState *TxState) GetBaseGasPrice() uint64

func (*TxState) GetChainID

func (txState *TxState) GetChainID() string

func (*TxState) GetContractsListByName

func (txState *TxState) GetContractsListByName(name string) ([]smc.Address, error)

func (*TxState) GetGas

func (txState *TxState) GetGas(contractAddr smc.Address, methodId uint32) (uint64, error)

func (*TxState) GetGenesisToken

func (txState *TxState) GetGenesisToken() (*types.IssueToken, error)

func (*TxState) GetStrategys

func (txState *TxState) GetStrategys() ([]types.RewardStrategy, error)

func (*TxState) GetToken

func (txState *TxState) GetToken(tokenAddr smc.Address) (*types.IssueToken, error)

func (*TxState) GetTokenAddrByName

func (txState *TxState) GetTokenAddrByName(name string) (smc.Address, error)

func (*TxState) GetTokenAddrBySymbol

func (txState *TxState) GetTokenAddrBySymbol(name string) (smc.Address, error)

func (*TxState) GetUDCNonce

func (txState *TxState) GetUDCNonce() (uint64, error)

func (*TxState) GetUDCOrder

func (txState *TxState) GetUDCOrder(udcHash []byte) (*types.UDCOrder, error)

func (*TxState) RollbackTx

func (txState *TxState) RollbackTx()

func (*TxState) Set

func (txState *TxState) Set(key string, value []byte) error

如果没有初始化Tx缓存直接报错,如果想直接写入block缓存,可以调用StateDB的设置接口

func (*TxState) SetBalance

func (txState *TxState) SetBalance(exAddress smc.Address, tokenAddress smc.Address, value big.Int) error

func (*TxState) SetBaseGasPrice

func (txState *TxState) SetBaseGasPrice(gasPrice uint64) error

func (*TxState) SetStrategys

func (txState *TxState) SetStrategys(strategys []types.RewardStrategy) error

func (*TxState) SetToken

func (txState *TxState) SetToken(issueToken *types.IssueToken) error

只设置Token信息,不设置账户的代币

func (*TxState) SetTokenContract

func (txState *TxState) SetTokenContract(contract *types.Contract) error

func (*TxState) SetUDCNonce

func (txState *TxState) SetUDCNonce(nonce uint64) error

func (*TxState) SetUDCOrder

func (txState *TxState) SetUDCOrder(udcOrder *types.UDCOrder) error

func (*TxState) SetValidator

func (txState *TxState) SetValidator(validator *types.Validator) error

Jump to

Keyboard shortcuts

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