Documentation ¶
Index ¶
- func HeadersToBlocks(headers []*types.Header) []*types.Block
- func NewTestBodyChain(n int) ([]*types.Header, []*types.Block, [][]*types.Receipt)
- func NewTestHeaderChain(n int) []*types.Header
- func NewTestHeaderChainWithSeed(genesis *types.Header, n int, seed int) []*types.Header
- func NewTestHeaderFromChain(headers []*types.Header, n int) []*types.Header
- func NewTestHeaderFromChainWithSeed(headers []*types.Header, n int, seed int) []*types.Header
- type Blockchain
- func (b *Blockchain) Close() error
- func (b *Blockchain) CommitBodies(headers []types.Hash, bodies []*types.Body) error
- func (b *Blockchain) CommitChain(blocks []*types.Block, receipts [][]*types.Receipt) error
- func (b *Blockchain) CommitReceipts(headers []types.Hash, receipts [][]*types.Receipt) error
- func (b *Blockchain) Config() *chain.Params
- func (b *Blockchain) CurrentBlock(full bool) *types.Block
- func (b *Blockchain) CurrentHeader() (*types.Header, bool)
- func (b *Blockchain) Empty() bool
- func (b *Blockchain) Executor() *state.Executor
- func (b *Blockchain) Genesis() types.Hash
- func (b *Blockchain) GetBlock(hash types.Hash, number uint64, full bool) (*types.Block, bool)
- func (b *Blockchain) GetBlockByHash(hash types.Hash, full bool) (*types.Block, bool)
- func (b *Blockchain) GetBlockByNumber(n uint64, full bool) (*types.Block, bool)
- func (b *Blockchain) GetBodyByHash(hash types.Hash) (*types.Body, bool)
- func (b *Blockchain) GetChainTD() (*big.Int, bool)
- func (b *Blockchain) GetConsensus() consensus.Consensus
- func (b *Blockchain) GetForks() []types.Hash
- func (b *Blockchain) GetHashByNumber(i uint64) types.Hash
- func (b *Blockchain) GetHashHelper(header *types.Header) func(i uint64) (res types.Hash)
- func (b *Blockchain) GetHeader(hash types.Hash, number uint64) (*types.Header, bool)
- func (b *Blockchain) GetHeaderByHash(hash types.Hash) (*types.Header, bool)
- func (b *Blockchain) GetHeaderByNumber(n uint64) (*types.Header, bool)
- func (b *Blockchain) GetParent(header *types.Header) (*types.Header, bool)
- func (b *Blockchain) GetReceiptsByHash(hash types.Hash) []*types.Receipt
- func (b *Blockchain) GetTD(hash types.Hash) (*big.Int, bool)
- func (b *Blockchain) HasBadBlock(hash types.Hash) bool
- func (b *Blockchain) Header() (*types.Header, bool)
- func (b *Blockchain) ReadTransactionBlockHash(hash types.Hash) (types.Hash, bool)
- func (b *Blockchain) SideChainCh() chan *types.Header
- func (b *Blockchain) Subscribe() chan *types.Header
- func (b *Blockchain) VerifyUncles(block *types.Block) error
- func (b *Blockchain) WriteBlock(block *types.Block) error
- func (b *Blockchain) WriteBlocks(blocks []*types.Block) error
- func (b *Blockchain) WriteGenesis(genesis *chain.Genesis) error
- func (b *Blockchain) WriteHeader(header *types.Header) error
- func (b *Blockchain) WriteHeaderGenesis(header *types.Header) error
- func (b *Blockchain) WriteHeaders(headers []*types.Header) error
- func (b *Blockchain) WriteHeadersWithBodies(headers []*types.Header) error
- func (b *Blockchain) WriteReceipts(hash types.Hash, receipts []*types.Receipt) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestBodyChain ¶
NewTestBodyChain creates a test blockchain with headers, body and receipts
func NewTestHeaderChain ¶
NewTestHeaderChain creates a chain of valid headers
func NewTestHeaderChainWithSeed ¶
NewTestHeaderChainWithSeed creates a new chain with a seed factor
func NewTestHeaderFromChain ¶
NewTestHeaderFromChain creates n new headers from an already existing chain
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain is a blockchain reference
func NewBlockchain ¶
func NewBlockchain(db storage.Storage, config *chain.Params, consensus consensus.Consensus, executor *state.Executor) *Blockchain
NewBlockchain creates a new blockchain object
func NewTestBlockchain ¶
func NewTestBlockchain(t *testing.T, headers []*types.Header) *Blockchain
NewTestBlockchain creates a new dummy blockchain for testing
func NewTestBlockchainWithBlocks ¶
func NewTestBlockchainWithBlocks(t *testing.T, blocks []*types.Block, receipts [][]*types.Receipt) *Blockchain
NewTestBlockchainWithBlocks creates a dummy blockchain with headers, bodies and receipts
func (*Blockchain) Close ¶
func (b *Blockchain) Close() error
func (*Blockchain) CommitBodies ¶
CommitBodies writes the bodies
func (*Blockchain) CommitChain ¶
CommitChain writes all the other data related to the chain (body and receipts). TODO: I think this function is not used anymore.
func (*Blockchain) CommitReceipts ¶
CommitReceipts writes the receipts
func (*Blockchain) Config ¶
func (b *Blockchain) Config() *chain.Params
func (*Blockchain) CurrentBlock ¶
func (b *Blockchain) CurrentBlock(full bool) *types.Block
func (*Blockchain) CurrentHeader ¶
func (b *Blockchain) CurrentHeader() (*types.Header, bool)
func (*Blockchain) Empty ¶
func (b *Blockchain) Empty() bool
Empty checks if the blockchain is empty
func (*Blockchain) Executor ¶
func (b *Blockchain) Executor() *state.Executor
func (*Blockchain) Genesis ¶
func (b *Blockchain) Genesis() types.Hash
Genesis returns the genesis block
func (*Blockchain) GetBlockByHash ¶
GetBlockByHash returns the block by their hash
func (*Blockchain) GetBlockByNumber ¶
GetBlockByNumber returns the block by their number
func (*Blockchain) GetBodyByHash ¶
GetBodyByHash returns the body by their hash
func (*Blockchain) GetChainTD ¶
func (b *Blockchain) GetChainTD() (*big.Int, bool)
func (*Blockchain) GetConsensus ¶
func (b *Blockchain) GetConsensus() consensus.Consensus
GetConsensus returns the consensus engine
func (*Blockchain) GetForks ¶
func (b *Blockchain) GetForks() []types.Hash
GetForks returns the forks
func (*Blockchain) GetHashByNumber ¶
func (b *Blockchain) GetHashByNumber(i uint64) types.Hash
func (*Blockchain) GetHashHelper ¶
func (*Blockchain) GetHeaderByHash ¶
GetHeaderByHash returns the header by his hash
func (*Blockchain) GetHeaderByNumber ¶
func (b *Blockchain) GetHeaderByNumber(n uint64) (*types.Header, bool)
GetHeaderByNumber returns the header by his number
func (*Blockchain) GetReceiptsByHash ¶
func (b *Blockchain) GetReceiptsByHash(hash types.Hash) []*types.Receipt
GetReceiptsByHash returns the receipts by their hash
func (*Blockchain) HasBadBlock ¶
func (b *Blockchain) HasBadBlock(hash types.Hash) bool
func (*Blockchain) Header ¶
func (b *Blockchain) Header() (*types.Header, bool)
Header returns the header of the blockchain
func (*Blockchain) ReadTransactionBlockHash ¶
ReadTransactionBlockHash fetches block hash for provided transaction hash
func (*Blockchain) SideChainCh ¶
func (b *Blockchain) SideChainCh() chan *types.Header
SideChainCh returns the channel of headers
func (*Blockchain) Subscribe ¶
func (b *Blockchain) Subscribe() chan *types.Header
func (*Blockchain) VerifyUncles ¶
func (b *Blockchain) VerifyUncles(block *types.Block) error
func (*Blockchain) WriteBlock ¶
func (b *Blockchain) WriteBlock(block *types.Block) error
WriteBlock writes a block of data
func (*Blockchain) WriteBlocks ¶
func (b *Blockchain) WriteBlocks(blocks []*types.Block) error
WriteBlocks writes a batch of blocks
func (*Blockchain) WriteGenesis ¶
func (b *Blockchain) WriteGenesis(genesis *chain.Genesis) error
WriteGenesis writes the genesis block if not present
func (*Blockchain) WriteHeader ¶
func (b *Blockchain) WriteHeader(header *types.Header) error
WriteHeader writes a block and the data, assumes the genesis is already set
func (*Blockchain) WriteHeaderGenesis ¶
func (b *Blockchain) WriteHeaderGenesis(header *types.Header) error
WriteHeaderGenesis writes the genesis without any state allocation TODO, remove
func (*Blockchain) WriteHeaders ¶
func (b *Blockchain) WriteHeaders(headers []*types.Header) error
func (*Blockchain) WriteHeadersWithBodies ¶
func (b *Blockchain) WriteHeadersWithBodies(headers []*types.Header) error
WriteHeadersWithBodies writes a batch of headers
func (*Blockchain) WriteReceipts ¶
WriteReceipts writes a block receipts