Versions in this module Expand all Collapse all v0 v0.0.2 Dec 21, 2022 v0.0.1 Dec 21, 2022 Changes in this version + const BlockGasTargetDivisor + var ErrClosed = errors.New("blockchain is closed") + var ErrExistBlock = errors.New("exist block") + var ErrInvalidBlockSequence = errors.New("invalid block sequence") + var ErrInvalidGasUsed = errors.New("invalid block gas used") + var ErrInvalidParentHash = errors.New("parent block hash is invalid") + var ErrInvalidReceiptsRoot = errors.New("invalid block receipts root") + var ErrInvalidReceiptsSize = errors.New("invalid number of receipts") + var ErrInvalidSha3Uncles = errors.New("invalid block sha3 uncles root") + var ErrInvalidStateRoot = errors.New("invalid block state root") + var ErrInvalidTxRoot = errors.New("invalid block transactions root") + var ErrNilStorageBuilder = errors.New("nil storage builder") + var ErrNoBlock = errors.New("no block data passed in") + var ErrNoBlockHeader = errors.New("no block header data passed in") + var ErrParentHashMismatch = errors.New("invalid parent block hash") + var ErrParentNotFound = errors.New("parent block not found") + type BlockResult struct + Receipts []*types.Receipt + Root types.Hash + TotalGas uint64 + type Blockchain struct + func NewBlockchain(logger hclog.Logger, db ethdb.Database, chain *chain.Chain, executor Executor, ...) (*Blockchain, error) + func (b *Blockchain) CalculateGasLimit(number uint64) (uint64, error) + func (b *Blockchain) ChainDB() ethdb.Database + func (b *Blockchain) Close() error + func (b *Blockchain) Config() *chain.Chain + func (b *Blockchain) CurrentTD() *big.Int + func (b *Blockchain) GetBlockByNumber(blockNumber uint64, full bool) (*types.Block, bool) + func (b *Blockchain) GetBodyByHash(hash types.Hash) (*types.Body, bool) + func (b *Blockchain) GetHashHelper(header *types.Header) func(i uint64) (res types.Hash) + func (b *Blockchain) GetHeaderByHash(hash types.Hash) (*types.Header, bool) + func (b *Blockchain) GetHeaderByNumber(n uint64) (*types.Header, bool) + func (b *Blockchain) GetReceiptsByHash(hash types.Hash) ([]*types.Receipt, error) + func (b *Blockchain) GetTD(hash types.Hash) (*big.Int, bool) + func (b *Blockchain) HandleGenesis() error + func (b *Blockchain) Header() *types.Header + func (b *Blockchain) IsSystemTransaction(height uint64, coinbase types.Address, tx *types.Transaction) bool + func (b *Blockchain) SelfCheck() + func (b *Blockchain) SubscribeEvents() Subscription + func (b *Blockchain) VerifyFinalizedBlock(block *types.Block) error + func (b *Blockchain) VerifyHeader(header *types.Header) error + func (b *Blockchain) WriteBlock(block *types.Block) error + func (b *Blockchain) WriteHeader(header *types.Header) error + type Event struct + Difficulty *big.Int + NewChain []*types.Header + OldChain []*types.Header + Source string + Type EventType + func (e *Event) AddNewHeader(newHeader *types.Header) + func (e *Event) AddOldHeader(oldHeader *types.Header) + func (e *Event) Header() *types.Header + func (e *Event) SetDifficulty(b *big.Int) + type EventType int + const EventFork + const EventHead + const EventReorg + type Executor interface + BeginTxn func(parentRoot types.Hash, header *types.Header, coinbase types.Address) (*state.Transition, error) + ProcessTransactions func(transition *state.Transition, gasLimit uint64, ...) (*state.Transition, error) + Stop func() + type IBlockchain interface + ChainDB func() ethdb.Database + GetBlockByNumber func(blockNumber uint64, full bool) (*types.Block, bool) + Header func() *types.Header + SubscribeEvents func() Subscription + type MockSubscription struct + func NewMockSubscription() *MockSubscription + func (m *MockSubscription) Close() + func (m *MockSubscription) GetEvent() *Event + func (m *MockSubscription) GetEventCh() chan *Event + func (m *MockSubscription) Push(e *Event) + type Subscription interface + Close func() + GetEvent func() *Event + GetEventCh func() chan *Event