core

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownAncestor is returned when validating a block requires an ancestor
	// that is unknown.
	ErrUnknownAncestor = errors.New("unknown ancestor")

	// ErrFutureBlock is returned when a block's timestamp is in the future according
	// to the current node.
	ErrFutureBlock = errors.New("block in the future")
)

Functions

func RegisterAPI

func RegisterAPI(chain *BlockChain)

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func (*API) CurrentBlock

func (a *API) CurrentBlock() *types.Block

func (*API) CurrentHeight

func (a *API) CurrentHeight() uint64

func (*API) CurrentTD

func (a *API) CurrentTD() *big.Int

func (*API) GetBlockByHash

func (a *API) GetBlockByHash(hash types.Hash) *types.Block

func (*API) GetBlockByHeight

func (a *API) GetBlockByHeight(height uint64) *types.Block

func (*API) GetBlockHashByHeight

func (a *API) GetBlockHashByHeight(height uint64) types.Hash

func (*API) GetBlockTD

func (a *API) GetBlockTD(hash types.Hash) *big.Int

func (*API) GetTransactionByHash

func (a *API) GetTransactionByHash(hash types.Hash) types.Tx

func (*API) GetTransactionReceipt

func (a *API) GetTransactionReceipt(hash types.Hash) *types.StoredReceipt

type BlockChain

type BlockChain struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

func NewBlockChain

func NewBlockChain(logger log.Logger) (*BlockChain, error)

func (*BlockChain) ApplyBlock

func (bc *BlockChain) ApplyBlock(block *types.Block) error

func (*BlockChain) ApplyHeaderChain

func (bc *BlockChain) ApplyHeaderChain(hc *HeaderChain) error

func (*BlockChain) BlockByHeight

func (bc *BlockChain) BlockByHeight(height uint64) *types.Block

func (*BlockChain) Close

func (bc *BlockChain) Close()

func (*BlockChain) GetBlock

func (bc *BlockChain) GetBlock(height uint64, hash types.Hash) *types.Block

func (*BlockChain) GetTd

func (bc *BlockChain) GetTd() *big.Int

func (*BlockChain) HasBlock

func (bc *BlockChain) HasBlock(height uint64, hash types.Hash) bool

func (*BlockChain) LatestBlock

func (bc *BlockChain) LatestBlock() *types.Block

LatestBlock retrieves the latest head block of the canonical chain. The block is retrieved from the blockchain's internal cache.

func (*BlockChain) LatestState

func (bc *BlockChain) LatestState() (*iavl.ImmutableTree, error)

func (*BlockChain) NewHeaderChain

func (bc *BlockChain) NewHeaderChain() *HeaderChain

func (*BlockChain) Simulate

func (bc *BlockChain) Simulate(txs types.Txs) (*transactor.ExecutionResult, error)

type HeaderChain

type HeaderChain struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

used to store a sort of contiguous block headers for later applying

func (*HeaderChain) AppendBlocks

func (hc *HeaderChain) AppendBlocks(blocks []*types.Block) error

append blocks to calculate total difficulty, only contiguous and valid blocks are included

func (*HeaderChain) CanStartFrom

func (hc *HeaderChain) CanStartFrom(height uint64, hash types.Hash) bool

func (*HeaderChain) GetTd

func (hc *HeaderChain) GetTd() *big.Int

type SubAPI

type SubAPI struct {
	// contains filtered or unexported fields
}

func (*SubAPI) NewHeads

func (api *SubAPI) NewHeads(ctx context.Context) (*ethrpc.Subscription, error)

NewHeads send a notification each time a new (header) block is appended to the chain.

func (*SubAPI) NewTransactions

func (api *SubAPI) NewTransactions(ctx context.Context) (*ethrpc.Subscription, error)

NewTransactions send a notification each time a new (header) block is appended to the chain.

Jump to

Keyboard shortcuts

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