Documentation ¶
Index ¶
- Constants
- func InitRepository(chainConfig config.RepositoryConfig, eventCenter types.EventCenter) error
- type Repository
- func (repo *Repository) AddBalance(address types.Address, value *big.Int)
- func (repo *Repository) AddLog(log *types.Log)
- func (repo *Repository) AddPreimage(hash types.Hash, preimage []byte)
- func (repo *Repository) AddRefund(value uint64)
- func (repo *Repository) Commit(deleteEmptyObjects bool) (root types.Hash, err error)
- func (repo *Repository) CreateAccount(address types.Address)
- func (repo *Repository) Delete(key []byte) error
- func (repo *Repository) Empty(address types.Address) bool
- func (repo *Repository) EventWriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt, emitCommitEvent bool) error
- func (repo *Repository) Exist(address types.Address) bool
- func (repo *Repository) Finalise(deleteEmptyObjects bool)
- func (repo *Repository) ForEachStorage(addr types.Address, cb func(key, value types.Hash) bool)
- func (repo *Repository) Get(key []byte) ([]byte, error)
- func (repo *Repository) GetBalance(address types.Address) *big.Int
- func (repo *Repository) GetBlockByHash(hash types.Hash) (*types.Block, error)
- func (repo *Repository) GetBlockByHeight(height uint64) (*types.Block, error)
- func (repo *Repository) GetCode(address types.Address) []byte
- func (repo *Repository) GetCodeHash(address types.Address) types.Hash
- func (repo *Repository) GetCodeSize(address types.Address) int
- func (repo *Repository) GetCommittedHashTypeState(addr types.Address, hash types.Hash) types.Hash
- func (repo *Repository) GetCommittedState(addr types.Address, hash types.Hash) []byte
- func (repo *Repository) GetCurrentBlock() *types.Block
- func (repo *Repository) GetCurrentBlockHeight() uint64
- func (repo *Repository) GetHashTypeState(address types.Address, bhash types.Hash) types.Hash
- func (repo *Repository) GetLogs(txHash types.Hash) []*types.Log
- func (repo *Repository) GetNonce(address types.Address) uint64
- func (repo *Repository) GetReceiptByBlockHash(blockHash types.Hash) []*types.Receipt
- func (repo *Repository) GetReceiptByTxHash(txHash types.Hash) (*types.Receipt, types.Hash, uint64, uint64, error)
- func (repo *Repository) GetRefund() uint64
- func (repo *Repository) GetState(address types.Address, bhash types.Hash) []byte
- func (repo *Repository) GetTransactionByHash(hash types.Hash) (*types.Transaction, types.Hash, uint64, uint64, error)
- func (repo *Repository) HasSuicided(address types.Address) bool
- func (repo *Repository) IntermediateRoot(deleteEmptyObjects bool) types.Hash
- func (repo *Repository) Prepare(thash, bhash types.Hash, ti int)
- func (repo *Repository) Put(key []byte, value []byte) error
- func (repo *Repository) Reset(root types.Hash) error
- func (repo *Repository) RevertToSnapshot(revid int)
- func (repo *Repository) SetBalance(addr types.Address, amount *big.Int)
- func (repo *Repository) SetCode(address types.Address, code []byte)
- func (repo *Repository) SetHashTypeState(address types.Address, key, value types.Hash)
- func (repo *Repository) SetNonce(address types.Address, value uint64)
- func (repo *Repository) SetState(address types.Address, key types.Hash, value []byte)
- func (repo *Repository) Snapshot() int
- func (repo *Repository) SubBalance(address types.Address, value *big.Int)
- func (repo *Repository) SubRefund(gas uint64)
- func (repo *Repository) Suicide(address types.Address) bool
- func (repo *Repository) WriteBlock(block *types.Block) error
- func (repo *Repository) WriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt) error
Constants ¶
const ( // DB plugin PLUGIN_LEVELDB = "leveldb" // memory plugin PLUGIN_MEMDB = "memorydb" )
repository module constant value.
Variables ¶
This section is empty.
Functions ¶
func InitRepository ¶ added in v1.1.0
func InitRepository(chainConfig config.RepositoryConfig, eventCenter types.EventCenter) error
InitRepository init repository module config.
Types ¶
type Repository ¶ added in v1.1.0
type Repository struct {
// contains filtered or unexported fields
}
Repository is the chain manager.
The Repository is used to write block to chain, get block from chain, and get the block state.
func NewLatestStateRepository ¶ added in v1.1.0
func NewLatestStateRepository() (*Repository, error)
NewLatestStateRepository create a repository with latest state hash.
func NewRepositoryByBlockHash ¶ added in v1.1.0
func NewRepositoryByBlockHash(blockHash types.Hash) (*Repository, error)
NewRepositoryByBlockHash create a repository with specified block hash.
func NewRepositoryByHash ¶ added in v1.1.0
func NewRepositoryByHash(root types.Hash) (*Repository, error)
NewRepositoryByHash returns a repository instance with specified hash.
func (*Repository) AddBalance ¶ added in v1.1.0
func (repo *Repository) AddBalance(address types.Address, value *big.Int)
func (*Repository) AddLog ¶ added in v1.1.0
func (repo *Repository) AddLog(log *types.Log)
AddLog add contract execute log.
func (*Repository) AddPreimage ¶ added in v1.1.0
func (repo *Repository) AddPreimage(hash types.Hash, preimage []byte)
func (*Repository) AddRefund ¶ added in v1.1.0
func (repo *Repository) AddRefund(value uint64)
func (*Repository) Commit ¶ added in v1.1.0
func (repo *Repository) Commit(deleteEmptyObjects bool) (root types.Hash, err error)
Commit writes the state to the underlying in-memory trie database.
func (*Repository) CreateAccount ¶ added in v1.1.0
func (repo *Repository) CreateAccount(address types.Address)
CreateAccount create an account
func (*Repository) Delete ¶ added in v1.1.0
func (repo *Repository) Delete(key []byte) error
Delete removes the key from the key-value data store.
func (*Repository) Empty ¶ added in v1.1.0
func (repo *Repository) Empty(address types.Address) bool
Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).
func (*Repository) EventWriteBlockWithReceipts ¶ added in v1.1.0
func (repo *Repository) 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 (*Repository) Exist ¶ added in v1.1.0
func (repo *Repository) Exist(address types.Address) bool
Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.
func (*Repository) Finalise ¶ added in v1.1.0
func (repo *Repository) Finalise(deleteEmptyObjects bool)
Finalise finalises the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*Repository) ForEachStorage ¶ added in v1.1.0
func (*Repository) Get ¶ added in v1.1.0
func (repo *Repository) Get(key []byte) ([]byte, error)
Get get a record by key
func (*Repository) GetBalance ¶ added in v1.1.0
func (repo *Repository) GetBalance(address types.Address) *big.Int
func (*Repository) GetBlockByHash ¶ added in v1.1.0
GetBlockByHash retrieves a block from the local chain.
func (*Repository) GetBlockByHeight ¶ added in v1.1.0
func (repo *Repository) GetBlockByHeight(height uint64) (*types.Block, error)
GetBlockByHeight get block by height.
func (*Repository) GetCode ¶ added in v1.1.0
func (repo *Repository) GetCode(address types.Address) []byte
func (*Repository) GetCodeHash ¶ added in v1.1.0
func (repo *Repository) GetCodeHash(address types.Address) types.Hash
func (*Repository) GetCodeSize ¶ added in v1.1.0
func (repo *Repository) GetCodeSize(address types.Address) int
func (*Repository) GetCommittedHashTypeState ¶ added in v1.1.0
GetCommittedHashTypeState retrieves a value from the given account's committed storage trie.
func (*Repository) GetCommittedState ¶ added in v1.1.0
GetCommittedHashTypeState retrieves a value from the given account's committed storage trie.
func (*Repository) GetCurrentBlock ¶ added in v1.1.0
func (repo *Repository) GetCurrentBlock() *types.Block
GetCurrentBlock get current block.
func (*Repository) GetCurrentBlockHeight ¶ added in v1.1.0
func (repo *Repository) GetCurrentBlockHeight() uint64
GetCurrentBlockHeight get current block height.
func (*Repository) GetHashTypeState ¶ added in v1.1.0
func (*Repository) GetLogs ¶ added in v1.1.0
func (repo *Repository) GetLogs(txHash types.Hash) []*types.Log
GetLogs get transaction's execution log
func (*Repository) GetNonce ¶ added in v1.1.0
func (repo *Repository) GetNonce(address types.Address) uint64
GetNonce get account's nounce
func (*Repository) GetReceiptByBlockHash ¶ added in v1.1.0
func (repo *Repository) GetReceiptByBlockHash(blockHash types.Hash) []*types.Receipt
GetReceiptByHash get receipt by relative block's hash
func (*Repository) GetReceiptByTxHash ¶ added in v1.1.0
func (repo *Repository) GetReceiptByTxHash(txHash types.Hash) (*types.Receipt, types.Hash, uint64, uint64, error)
GetReceiptByHash get receipt by relative tx's hash
func (*Repository) GetRefund ¶ added in v1.1.0
func (repo *Repository) GetRefund() uint64
func (*Repository) GetTransactionByHash ¶ added in v1.1.0
func (repo *Repository) GetTransactionByHash(hash types.Hash) (*types.Transaction, types.Hash, uint64, uint64, error)
GetTransactionByHash get transaction by hash
func (*Repository) HasSuicided ¶ added in v1.1.0
func (repo *Repository) HasSuicided(address types.Address) bool
func (*Repository) IntermediateRoot ¶ added in v1.1.0
func (repo *Repository) 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 (*Repository) Prepare ¶ added in v1.1.0
func (repo *Repository) 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 (*Repository) Put ¶ added in v1.1.0
func (repo *Repository) Put(key []byte, value []byte) error
Put add a record to database
func (*Repository) Reset ¶ added in v1.1.0
func (repo *Repository) 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 (*Repository) RevertToSnapshot ¶ added in v1.1.0
func (repo *Repository) RevertToSnapshot(revid int)
func (*Repository) SetBalance ¶ added in v1.1.0
func (repo *Repository) SetBalance(addr types.Address, amount *big.Int)
func (*Repository) SetCode ¶ added in v1.1.0
func (repo *Repository) SetCode(address types.Address, code []byte)
func (*Repository) SetHashTypeState ¶ added in v1.1.0
func (repo *Repository) SetHashTypeState(address types.Address, key, value types.Hash)
func (*Repository) SetNonce ¶ added in v1.1.0
func (repo *Repository) SetNonce(address types.Address, value uint64)
func (*Repository) Snapshot ¶ added in v1.1.0
func (repo *Repository) Snapshot() int
func (*Repository) SubBalance ¶ added in v1.1.0
func (repo *Repository) SubBalance(address types.Address, value *big.Int)
func (*Repository) SubRefund ¶ added in v1.1.0
func (repo *Repository) SubRefund(gas uint64)
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
func (*Repository) Suicide ¶ added in v1.1.0
func (repo *Repository) Suicide(address types.Address) bool
func (*Repository) WriteBlock ¶ added in v1.1.0
func (repo *Repository) WriteBlock(block *types.Block) error
WriteBlockWithState writes the block to the database.
func (*Repository) WriteBlockWithReceipts ¶ added in v1.1.0
WriteBlock write the block and relative receipts to database. return error if write failed.