repository

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

README

Repository

Repositories is a module for chain which is used to abstract the statedb and blockstore layer. This makes chain data persistent much easier.

Build Status codecov

Getting started

Running it then should be as simple as:

$ make all
Testing
$ make test

Documentation

Index

Constants

View Source
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 (repo *Repository) ForEachStorage(addr types.Address, cb func(key, value types.Hash) bool)

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

func (repo *Repository) GetBlockByHash(hash types.Hash) (*types.Block, error)

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

func (repo *Repository) GetCommittedHashTypeState(addr types.Address, hash types.Hash) types.Hash

GetCommittedHashTypeState retrieves a value from the given account's committed storage trie.

func (*Repository) GetCommittedState added in v1.1.0

func (repo *Repository) GetCommittedState(addr types.Address, hash types.Hash) []byte

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 (repo *Repository) GetHashTypeState(address types.Address, bhash types.Hash) types.Hash

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) GetState added in v1.1.0

func (repo *Repository) GetState(address types.Address, bhash types.Hash) []byte

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) SetState added in v1.1.0

func (repo *Repository) SetState(address types.Address, key types.Hash, value []byte)

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

func (repo *Repository) WriteBlockWithReceipts(block *types.Block, receipts []*types.Receipt) error

WriteBlock write the block and relative receipts to database. return error if write failed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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