consensus

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var (
	BigBalance = new(big.Int).Div(math.MaxBig256, big.NewInt(2))
)

Functions

func MigrationTx

func MigrationTx(
	signer types.Signer,
	header *types.Header,
	migration_file string,
	engine consensus.Engine,
) (res *types.Transaction)

Types

type AccountsFn

type AccountsFn func() []common.Address

type ChainReader

type ChainReader = eth_consensus.ChainReader

type ConsensusSigner

type ConsensusSigner struct{}

NOTE: it MUST NOT for untrusted transactions

func NewConsensusSigner

func NewConsensusSigner() *ConsensusSigner

func (ConsensusSigner) Equal

func (cs ConsensusSigner) Equal(s2 types.Signer) bool

func (ConsensusSigner) Hash

func (ConsensusSigner) Sender

func (ConsensusSigner) SignatureValues

func (cs ConsensusSigner) SignatureValues(tx *types.Transaction, sig []byte) (r, s, v *big.Int, err error)

type DiffFn

type DiffFn func(ChainReader, uint64, *types.Header, *timeTarget) *big.Int

type Energi

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

func New

func New(config *params.EnergiConfig, db ethdb.Database) *Energi

func (*Energi) APIs

func (e *Energi) APIs(chain ChainReader) []rpc.API

APIs returns the RPC APIs this consensus engine provides.

func (*Energi) Author

func (e *Energi) Author(header *types.Header) (common.Address, error)

Author retrieves the Ethereum address of the account that minted the given block, which may be different from the header's coinbase if a consensus engine is based on signatures.

func (*Energi) CalcDifficulty

func (e *Energi) CalcDifficulty(chain ChainReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have.

func (*Energi) Close

func (e *Energi) Close() error

Close terminates any background threads maintained by the consensus engine.

func (*Energi) Finalize

func (e *Energi) Finalize(
	chain ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt,
) (*types.Block, []*types.Receipt, error)

Finalize runs any post-transaction state modifications (e.g. block rewards) and assembles the final block. Note: The block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).

func (*Energi) GetMinerNonceCap added in v0.8.3

func (e *Energi) GetMinerNonceCap() uint64

func (*Energi) Prepare

func (e *Energi) Prepare(chain ChainReader, header *types.Header) error

Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.

func (*Energi) Seal

func (e *Energi) Seal(
	chain ChainReader,
	block *types.Block,
	results chan<- *eth_consensus.SealResult,
	stop <-chan struct{},
) (err error)

Seal generates a new sealing request for the given input block and pushes the result into the given channel.

Note, the method returns immediately and will send the result async. More than one result may also be returned depending on the consensus algorithm.

func (*Energi) SealHash

func (e *Energi) SealHash(header *types.Header) (hash common.Hash)

SealHash returns the hash of a block prior to it being sealed.

func (*Energi) SetMinerCB

func (e *Energi) SetMinerCB(
	accountsFn AccountsFn,
	signerFn SignerFn,
	peerCountFn PeerCountFn,
)

func (*Energi) SetMinerNonceCap

func (e *Energi) SetMinerNonceCap(nonceCap uint64)

func (*Energi) SignatureHash

func (e *Energi) SignatureHash(header *types.Header) (hash common.Hash)

func (*Energi) VerifyHeader

func (e *Energi) VerifyHeader(chain ChainReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.

func (*Energi) VerifyHeaders

func (e *Energi) VerifyHeaders(
	chain ChainReader, headers []*types.Header, seals []bool,
) (
	chan<- struct{}, <-chan error, chan<- bool,
)

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 (the order is that of the input slice).

func (*Energi) VerifySeal

func (e *Energi) VerifySeal(chain ChainReader, header *types.Header) error

VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.

func (*Energi) VerifyUncles

func (e *Energi) VerifyUncles(chain ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of a given engine.

type KnownStakeKey

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

type KnownStakeValue

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

type KnownStakes

type KnownStakes = sync.Map

type PeerCountFn

type PeerCountFn func() int

type SignerFn

type SignerFn func(common.Address, []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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