elephanthash

package
v0.0.0-...-e1f35ab Latest Latest
Warning

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

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

Documentation

Overview

Package ethash implements the ethash proof-of-work consensus engine.

Index

Constants

View Source
const (
	Idle       uint = iota // Node is created successfully, but the consensus process is not started yet.
	PreConfirm             // The `preConfirmMsg` is processed successfully. The node is ready to head to the Confirm stage.
	Confirm                // The `confirmMsg` is processed successfully. The node is ready to head to the next block processing.
)

Stages copied from hbft_imp.go

Variables

View Source
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
View Source
var (
	FrontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block

)

Ethash proof-of-work protocol constants.

Functions

func CalcDifficulty

func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.

Types

type Config

type Config struct {
	PowMode    Mode
	DatasetDir string
}

Config are the configuration parameters of the ethash.

type Elephanthash

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

Ethash is a consensus engine based on proot-of-work implementing the ethash algorithm.

func New

func New(config Config, pbftNode *nodeHbft.Node) *Elephanthash

New creates a full sized ethash PoW scheme.

func NewTester

func NewTester() *Elephanthash

NewTester creates a small sized ethash PoW scheme useful only for testing purposes.

func (*Elephanthash) APIs

func (elephanthash *Elephanthash) APIs(chain consensus.ChainReaderCtt) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC APIs. Currently that is empty.

func (*Elephanthash) Author

func (elephanthash *Elephanthash) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.

func (*Elephanthash) CalcDifficulty

func (elephanthash *Elephanthash) CalcDifficulty(chain consensus.ChainReaderCtt, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.

func (*Elephanthash) Finalize

func (elephanthash *Elephanthash) Finalize(chain consensus.ChainReaderCtt, header *types.Header, state *state.StateDB,
	txs []*types.Transaction, inputTxs []*types.ShardingTxBatch, uncles []*types.Header, receipts []*types.Receipt, eBase *common.Address) (*types.Block, error)

Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.

func (*Elephanthash) Prepare

func (elephanthash *Elephanthash) Prepare(chain consensus.ChainReaderCtt, header *types.Header) error

Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the ethash protocol. The changes are done inline.

func (*Elephanthash) Seal

func (elephanthash *Elephanthash) Seal(chain consensus.ChainReaderCtt, block *types.Block, stop <-chan struct{}) (*types.Block,
	[]*types.HBFTStageCompleted, error)

Seal implements consensus.Engine, attempting to find a nonce that satisfies the block's difficulty requirements.

func (*Elephanthash) VerifyBFT

func (elephanthash *Elephanthash) VerifyBFT(chain consensus.ChainReaderCtt, block *types.Block) error

VerifyBFT verifies that the given block's BFT records conform to the consensus rules of the engine.

func (*Elephanthash) VerifyHeader

func (elephanthash *Elephanthash) VerifyHeader(chain consensus.ChainReaderCtt, header *types.Header) error

VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum ethash engine.

func (*Elephanthash) VerifyHeaders

func (elephanthash *Elephanthash) VerifyHeaders(chain consensus.ChainReaderCtt, headers []*types.Header) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications.

type Mode

type Mode uint

Mode defines the type and amount of PoW verification an ethash engine makes.

const (
	ModeNormal Mode = iota
	ModeShared
	ModeTest
	ModeFake
	ModeFullFake
)

type NodeHbftServer

type NodeHbftServer struct {
	Address common.Address
	Node    *discover.Node
}

Jump to

Keyboard shortcuts

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