Documentation ¶
Index ¶
- Constants
- func CopyHeader(h *ethereum.Header) *ethereum.Header
- func GenerateChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, ...) ([]*types.Block, []types.Receipts)
- func Genesis()
- func OpenDatabase(file string, cache, handles int) (ethdb.Database, error)
- type BlockGen
- type HeaderChainStore
- func (hc *HeaderChainStore) CurrentHeaderHash() common.Hash
- func (hc *HeaderChainStore) CurrentHeaderNumber() uint64
- func (hc *HeaderChainStore) DeleteHeader(hash common.Hash, number uint64)
- func (hc *HeaderChainStore) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash
- func (hc *HeaderChainStore) GetBlockNumber(hash common.Hash) *uint64
- func (hc *HeaderChainStore) GetHeader(hash common.Hash, number uint64) *ethereum.Header
- func (hc *HeaderChainStore) GetHeaderByHash(hash common.Hash) *ethereum.Header
- func (hc *HeaderChainStore) GetHeaderByNumber(number uint64) *ethereum.Header
- func (hc *HeaderChainStore) GetStoreMgr(chainType rawdb.ChainType) (*HeaderChainStore, error)
- func (hc *HeaderChainStore) GetTd(hash common.Hash, number uint64) *big.Int
- func (hc *HeaderChainStore) GetTdByHash(hash common.Hash) *big.Int
- func (hc *HeaderChainStore) HasHeader(hash common.Hash, number uint64) bool
- func (hc *HeaderChainStore) InsertHeaderChain(chains []*ethereum.Header, start time.Time) (WriteStatus, error)
- func (hc *HeaderChainStore) ReadCanonicalHash(number uint64) common.Hash
- func (hc *HeaderChainStore) ReadFistBlock(number uint64) common.Hash
- func (hc *HeaderChainStore) ReadHeader(Hash common.Hash, number uint64) *ethereum.Header
- func (hc *HeaderChainStore) SetChainType(m rawdb.ChainType)
- func (hc *HeaderChainStore) ValidateHeaderChain(chain []*ethereum.Header, checkFreq int) (int, error)
- func (hc *HeaderChainStore) WriteHeader(header *ethereum.Header)
- type WriteStatus
Constants ¶
const (
DefaultChainType = rawdb.ChainType(0)
)
Variables ¶
This section is empty.
Functions ¶
func CopyHeader ¶
CopyHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func GenerateChain ¶
func GenerateChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, db ethdb.Database, n int, gen func(int, *BlockGen)) ([]*types.Block, []types.Receipts)
GenerateChain creates a chain of n blocks. The first block's parent will be the provided parent. db is used to store intermediate states and should contain the parent's state trie.
The generator function is called with a new block generator for every block. Any transactions and uncles added to the generator become part of the block. If gen is nil, the blocks will be empty and their coinbase will be the zero address.
Blocks created by GenerateChain do not contain valid proof of work values. Inserting them into BlockChain requires use of FakePow or a similar non-validating proof of work implementation.
Types ¶
type BlockGen ¶
type BlockGen struct {
// contains filtered or unexported fields
}
BlockGen creates blocks for testing. See GenerateChain for a detailed explanation.
func (*BlockGen) SetCoinbase ¶
SetCoinbase sets the coinbase of the generated block. It can be called at most once.
type HeaderChainStore ¶
type HeaderChainStore struct { Mu sync.RWMutex // blockchaindb insertion lock // contains filtered or unexported fields }
func GetStoreMgr ¶
func GetStoreMgr(chainType rawdb.ChainType) (*HeaderChainStore, error)
func NewStoreDb ¶
func NewStoreDb(ctx *cli.Context, DatabaseCache int, DatabaseHandles int) *HeaderChainStore
func (*HeaderChainStore) CurrentHeaderHash ¶
func (hc *HeaderChainStore) CurrentHeaderHash() common.Hash
func (*HeaderChainStore) CurrentHeaderNumber ¶
func (hc *HeaderChainStore) CurrentHeaderNumber() uint64
func (*HeaderChainStore) DeleteHeader ¶
func (hc *HeaderChainStore) DeleteHeader(hash common.Hash, number uint64)
func (*HeaderChainStore) GetBlockHashesFromHash ¶
GetBlockHashesFromHash retrieves a number of block hashes starting at a given hash, fetching towards the genesis block.
func (*HeaderChainStore) GetBlockNumber ¶
func (hc *HeaderChainStore) GetBlockNumber(hash common.Hash) *uint64
GetBlockNumber retrieves the block number belonging to the given hash from the cache or database
func (*HeaderChainStore) GetHeaderByHash ¶
func (hc *HeaderChainStore) GetHeaderByHash(hash common.Hash) *ethereum.Header
GetHeaderByHash retrieves a block header from the database by hash, caching it if found.
func (*HeaderChainStore) GetHeaderByNumber ¶
func (hc *HeaderChainStore) GetHeaderByNumber(number uint64) *ethereum.Header
GetHeaderByNumber retrieves a block header from the database by number, caching it (associated with its hash) if found.
func (*HeaderChainStore) GetStoreMgr ¶
func (hc *HeaderChainStore) GetStoreMgr(chainType rawdb.ChainType) (*HeaderChainStore, error)
func (*HeaderChainStore) GetTdByHash ¶
func (hc *HeaderChainStore) GetTdByHash(hash common.Hash) *big.Int
GetTdByHash retrieves a block's total difficulty in the canonical chain from the database by hash, caching it if found.
func (*HeaderChainStore) HasHeader ¶
func (hc *HeaderChainStore) HasHeader(hash common.Hash, number uint64) bool
func (*HeaderChainStore) InsertHeaderChain ¶
func (hc *HeaderChainStore) InsertHeaderChain(chains []*ethereum.Header, start time.Time) (WriteStatus, error)
func (*HeaderChainStore) ReadCanonicalHash ¶
func (hc *HeaderChainStore) ReadCanonicalHash(number uint64) common.Hash
func (*HeaderChainStore) ReadFistBlock ¶
func (hc *HeaderChainStore) ReadFistBlock(number uint64) common.Hash
func (*HeaderChainStore) ReadHeader ¶
func (*HeaderChainStore) SetChainType ¶
func (hc *HeaderChainStore) SetChainType(m rawdb.ChainType)
func (*HeaderChainStore) ValidateHeaderChain ¶
func (*HeaderChainStore) WriteHeader ¶
func (hc *HeaderChainStore) WriteHeader(header *ethereum.Header)
type WriteStatus ¶
type WriteStatus byte
WriteStatus status of write
const ( NonStatTyState WriteStatus = iota // the no CanonStatTyState // the Canonical SideStatTyState // the branch )