blockchain

package
v0.0.0-...-8f649d9 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeadersToBlocks

func HeadersToBlocks(headers []*types.Header) []*types.Block

func NewTestBodyChain

func NewTestBodyChain(n int) ([]*types.Header, []*types.Block, [][]*types.Receipt)

NewTestBodyChain creates a test blockchain with headers, body and receipts

func NewTestHeaderChain

func NewTestHeaderChain(n int) []*types.Header

NewTestHeaderChain creates a chain of valid headers

func NewTestHeaderChainWithSeed

func NewTestHeaderChainWithSeed(genesis *types.Header, n int, seed int) []*types.Header

NewTestHeaderChainWithSeed creates a new chain with a seed factor

func NewTestHeaderFromChain

func NewTestHeaderFromChain(headers []*types.Header, n int) []*types.Header

NewTestHeaderFromChain creates n new headers from an already existing chain

func NewTestHeaderFromChainWithSeed

func NewTestHeaderFromChainWithSeed(headers []*types.Header, n int, seed int) []*types.Header

NewTestHeaderFromChainWithSeed 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

func (b *Blockchain) CommitBodies(headers []types.Hash, bodies []*types.Body) error

CommitBodies writes the bodies

func (*Blockchain) CommitChain

func (b *Blockchain) CommitChain(blocks []*types.Block, receipts [][]*types.Receipt) error

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

func (b *Blockchain) CommitReceipts(headers []types.Hash, receipts [][]*types.Receipt) error

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) GetBlock

func (b *Blockchain) GetBlock(hash types.Hash, number uint64, full bool) (*types.Block, bool)

func (*Blockchain) GetBlockByHash

func (b *Blockchain) GetBlockByHash(hash types.Hash, full bool) (*types.Block, bool)

GetBlockByHash returns the block by their hash

func (*Blockchain) GetBlockByNumber

func (b *Blockchain) GetBlockByNumber(n uint64, full bool) (*types.Block, bool)

GetBlockByNumber returns the block by their number

func (*Blockchain) GetBodyByHash

func (b *Blockchain) GetBodyByHash(hash types.Hash) (*types.Body, bool)

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 (b *Blockchain) GetHashHelper(header *types.Header) func(i uint64) (res types.Hash)

func (*Blockchain) GetHeader

func (b *Blockchain) GetHeader(hash types.Hash, number uint64) (*types.Header, bool)

func (*Blockchain) GetHeaderByHash

func (b *Blockchain) GetHeaderByHash(hash types.Hash) (*types.Header, bool)

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) GetParent

func (b *Blockchain) GetParent(header *types.Header) (*types.Header, bool)

GetParent return the parent

func (*Blockchain) GetReceiptsByHash

func (b *Blockchain) GetReceiptsByHash(hash types.Hash) []*types.Receipt

GetReceiptsByHash returns the receipts by their hash

func (*Blockchain) GetTD

func (b *Blockchain) GetTD(hash types.Hash) (*big.Int, bool)

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

func (b *Blockchain) ReadTransactionBlockHash(hash types.Hash) (types.Hash, bool)

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

func (b *Blockchain) WriteReceipts(hash types.Hash, receipts []*types.Receipt) error

WriteReceipts writes a block receipts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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