core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 GenesisHeader added in v0.2.0

func GenesisHeader(networkId config.Network) *types.Header

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) *RpcTransaction

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 GetBlockByMinerData added in v0.1.0

type GetBlockByMinerData struct {
	Data      []uint64 `json:"data"`
	TotalPage int      `json:"totalPage"`
}

type GetBlockByMinerParam added in v0.1.0

type GetBlockByMinerParam struct {
	Miner types.Address `json:"miner"`
	Limit int           `json:"limit"`
	Page  int           `json:"page"`
}

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 RpcTransaction added in v0.0.3

type RpcTransaction struct {
	Data tx.TypedTx `json:"data"`
	Type tx.Type    `json:"type"`
	Hash types.Hash `json:"hash"`
}

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