Documentation ¶
Index ¶
- Constants
- func InitBlockChain(chainConfig config.BlockChainConfig, eventCenter types.EventCenter) error
- func ResetBlockChain(genesisPath string) error
- type BlockChain
- func (blockChain *BlockChain) AddBalance(address types.Address, value *big.Int)
- func (blockChain *BlockChain) AddLog(interface{})
- func (blockChain *BlockChain) AddPreimage(hash types.Hash, preimage []byte)
- func (blockChain *BlockChain) AddRefund(value uint64)
- func (blockChain *BlockChain) CreateAccount(address types.Address)
- func (blockChain *BlockChain) Empty(address types.Address) bool
- func (blockChain *BlockChain) EventWriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt, emitCommitEvent bool) error
- func (blockChain *BlockChain) Exist(address types.Address) bool
- func (blockChain *BlockChain) Finalise(deleteEmptyObjects bool)
- func (blockChain *BlockChain) ForEachStorage(addr types.Address, cb func(key, value types.Hash) bool)
- func (blockChain *BlockChain) GetBalance(address types.Address) *big.Int
- func (blockChain *BlockChain) GetBlockByHash(hash types.Hash) (*types.Block, error)
- func (blockChain *BlockChain) GetBlockByHeight(height uint64) (*types.Block, error)
- func (blockChain *BlockChain) GetCode(address types.Address) []byte
- func (blockChain *BlockChain) GetCodeHash(address types.Address) types.Hash
- func (blockChain *BlockChain) GetCodeSize(address types.Address) int
- func (blockChain *BlockChain) GetCurrentBlock() *types.Block
- func (blockChain *BlockChain) GetCurrentBlockHeight() uint64
- func (blockChain *BlockChain) GetNonce(address types.Address) uint64
- func (blockChain *BlockChain) GetReceiptByTxHash(txHash types.Hash) (*types.Receipt, types.Hash, uint64, uint64, error)
- func (blockChain *BlockChain) GetRefund() uint64
- func (blockChain *BlockChain) GetState(address types.Address, bhash types.Hash) types.Hash
- func (blockChain *BlockChain) GetTransactionByHash(hash types.Hash) (*types.Transaction, types.Hash, uint64, uint64, error)
- func (blockChain *BlockChain) HasSuicided(address types.Address) bool
- func (blockChain *BlockChain) IntermediateRoot(deleteEmptyObjects bool) types.Hash
- func (blockChain *BlockChain) Prepare(thash, bhash types.Hash, ti int)
- func (blockChain *BlockChain) Reset(root types.Hash) error
- func (blockChain *BlockChain) RevertToSnapshot(revid int)
- func (blockChain *BlockChain) SetBalance(addr types.Address, amount *big.Int)
- func (blockChain *BlockChain) SetCode(address types.Address, code []byte)
- func (blockChain *BlockChain) SetNonce(address types.Address, value uint64)
- func (blockChain *BlockChain) SetState(address types.Address, key, value types.Hash)
- func (blockChain *BlockChain) Snapshot() int
- func (blockChain *BlockChain) SubBalance(address types.Address, value *big.Int)
- func (blockChain *BlockChain) Suicide(address types.Address) bool
- func (blockChain *BlockChain) WriteBlock(block *types.Block) error
- func (blockChain *BlockChain) WriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt) error
Constants ¶
const ( // DB plugin PLUGIN_LEVELDB = "leveldb" // memory plugin PLUGIN_MEMDB = "memorydb" )
blockchain module constant value.
Variables ¶
This section is empty.
Functions ¶
func InitBlockChain ¶
func InitBlockChain(chainConfig config.BlockChainConfig, eventCenter types.EventCenter) error
InitBlockChain init blockchain module config.
func ResetBlockChain ¶
reset blockchain to genesis state.
Types ¶
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain is the chain manager.
The BlockChain is used to write block to chain, get block from chain, and get the block state.
func NewBlockChainByBlockHash ¶
func NewBlockChainByBlockHash(blockHash types.Hash) (*BlockChain, error)
NewLatestStateBlockChain create a blockchain with specified block hash.
func NewBlockChainByHash ¶
func NewBlockChainByHash(root types.Hash) (*BlockChain, error)
NewBlockChain returns a blockchain instance with specified hash.
func NewLatestStateBlockChain ¶
func NewLatestStateBlockChain() (*BlockChain, error)
NewLatestStateBlockChain create a blockchain with latest state hash.
func (*BlockChain) AddBalance ¶
func (blockChain *BlockChain) AddBalance(address types.Address, value *big.Int)
func (*BlockChain) AddLog ¶
func (blockChain *BlockChain) AddLog(interface{})
TODO: add contract execute log.
func (*BlockChain) AddPreimage ¶
func (blockChain *BlockChain) AddPreimage(hash types.Hash, preimage []byte)
func (*BlockChain) AddRefund ¶
func (blockChain *BlockChain) AddRefund(value uint64)
func (*BlockChain) CreateAccount ¶
func (blockChain *BlockChain) CreateAccount(address types.Address)
CreateAccount create an account
func (*BlockChain) Empty ¶
func (blockChain *BlockChain) Empty(address types.Address) bool
Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).
func (*BlockChain) EventWriteBlockWithReceipts ¶
func (blockChain *BlockChain) EventWriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt, emitCommitEvent bool) error
WriteBlock write the block and relative receipts to database. return error if write failed.
func (*BlockChain) Exist ¶
func (blockChain *BlockChain) Exist(address types.Address) bool
Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.
func (*BlockChain) Finalise ¶
func (blockChain *BlockChain) Finalise(deleteEmptyObjects bool)
Finalise finalises the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*BlockChain) ForEachStorage ¶
func (*BlockChain) GetBalance ¶
func (blockChain *BlockChain) GetBalance(address types.Address) *big.Int
func (*BlockChain) GetBlockByHash ¶
GetBlockByHash retrieves a block from the local chain.
func (*BlockChain) GetBlockByHeight ¶
func (blockChain *BlockChain) GetBlockByHeight(height uint64) (*types.Block, error)
GetBlockByHeight get block by height.
func (*BlockChain) GetCodeHash ¶
func (blockChain *BlockChain) GetCodeHash(address types.Address) types.Hash
func (*BlockChain) GetCodeSize ¶
func (blockChain *BlockChain) GetCodeSize(address types.Address) int
func (*BlockChain) GetCurrentBlock ¶
func (blockChain *BlockChain) GetCurrentBlock() *types.Block
GetCurrentBlock get current block.
func (*BlockChain) GetCurrentBlockHeight ¶
func (blockChain *BlockChain) GetCurrentBlockHeight() uint64
GetCurrentBlockHeight get current block height.
func (*BlockChain) GetNonce ¶
func (blockChain *BlockChain) GetNonce(address types.Address) uint64
GetNonce get account's nounce
func (*BlockChain) GetReceiptByTxHash ¶
func (blockChain *BlockChain) GetReceiptByTxHash(txHash types.Hash) (*types.Receipt, types.Hash, uint64, uint64, error)
GetReceiptByHash get receipt by relative tx's hash
func (*BlockChain) GetRefund ¶
func (blockChain *BlockChain) GetRefund() uint64
func (*BlockChain) GetTransactionByHash ¶
func (blockChain *BlockChain) GetTransactionByHash(hash types.Hash) (*types.Transaction, types.Hash, uint64, uint64, error)
GetTransactionByHash get transaction by hash
func (*BlockChain) HasSuicided ¶
func (blockChain *BlockChain) HasSuicided(address types.Address) bool
func (*BlockChain) IntermediateRoot ¶
func (blockChain *BlockChain) IntermediateRoot(deleteEmptyObjects bool) types.Hash
IntermediateRoot computes the current root hash of the state trie. It is called in between transactions to get the root hash that goes into transaction receipts.
func (*BlockChain) Prepare ¶
func (blockChain *BlockChain) Prepare(thash, bhash types.Hash, ti int)
Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.
func (*BlockChain) Reset ¶
func (blockChain *BlockChain) Reset(root types.Hash) error
Reset clears out all ephemeral state objects from the state db, but keeps the underlying state trie to avoid reloading data for the next operations.
func (*BlockChain) RevertToSnapshot ¶
func (blockChain *BlockChain) RevertToSnapshot(revid int)
func (*BlockChain) SetBalance ¶
func (blockChain *BlockChain) SetBalance(addr types.Address, amount *big.Int)
func (*BlockChain) SetCode ¶
func (blockChain *BlockChain) SetCode(address types.Address, code []byte)
func (*BlockChain) SetNonce ¶
func (blockChain *BlockChain) SetNonce(address types.Address, value uint64)
func (*BlockChain) SetState ¶
func (blockChain *BlockChain) SetState(address types.Address, key, value types.Hash)
func (*BlockChain) Snapshot ¶
func (blockChain *BlockChain) Snapshot() int
func (*BlockChain) SubBalance ¶
func (blockChain *BlockChain) SubBalance(address types.Address, value *big.Int)
func (*BlockChain) WriteBlock ¶
func (blockChain *BlockChain) WriteBlock(block *types.Block) error
WriteBlockWithState writes the block to the database.
func (*BlockChain) WriteBlockWithReceipts ¶
func (blockChain *BlockChain) WriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt) error
WriteBlock write the block and relative receipts to database. return error if write failed.