vdpos

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: GPL-3.0, LGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package vdpos implements the delegated-proof-of-stake consensus engine.

Package vdpos implements the delegated-proof-of-stake consensus engine.

Package vdpos implements the delegated-proof-of-stake consensus engine.

Package vdpos implements the delegated-proof-of-stake consensus engine.

Package vdpos implements the delegated-proof-of-stake consensus engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultVerifyRewardOneYear     = new(big.Int).Mul(big.NewInt(1e+7), big.NewInt(params.Inber))
	DefaultTeamRewardOneYear       = new(big.Int).Mul(big.NewInt(2e+6), big.NewInt(params.Inber))
	DefaultOfflineRewardOneYear    = new(big.Int).Mul(big.NewInt(6e+5), big.NewInt(params.Inber))
	DefaultFoundationRewardOneYear = new(big.Int).Mul(big.NewInt(2e+6), big.NewInt(params.Inber))
	DefaultMiningRewardOneYear     = new(big.Int).Mul(big.NewInt(2e+6), big.NewInt(params.Inber))
	DefaultVotingRewardOneYear     = new(big.Int).Mul(big.NewInt(2e+6), big.NewInt(params.Inber))
	DefaultOnlineRewardOneYear     = new(big.Int).Mul(big.NewInt(14e+5), big.NewInt(params.Inber))
	WeekNumberOfOneYear            = new(big.Int).Div(big.NewInt(365), big.NewInt(7))
	//OneWeekHeight                    = new(big.Int).Mul(big.NewInt(86400/2), big.NewInt(7))
	OneYearBySec = int64(365 * 86400)

	DefaultMinerReward = big.NewInt(12683)                                             // default min mortgage INB of candidates
	BeVotedNeedINB     = new(big.Int).Mul(big.NewInt(10000), big.NewInt(params.Inber)) // default min mortgage INB of candidates

)
View Source
var (

	// ErrInvalidTimestamp is returned if the timestamp of a block is lower than
	// the previous block's timestamp + the minimum block period.
	ErrInvalidTimestamp = errors.New("invalid timestamp")
)

various error messages to mark blocks invalid. These should be private to prevent engine specific errors from being referenced in the remainder of the codebase, inherently breaking if the engine is swapped out. Please put common error types into the consensus package.

Functions

This section is empty.

Types

type API

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

API is a user facing RPC API to allow controlling the signer and voting mechanisms of the delegated-proof-of-stake scheme.

func (*API) GetCandidateNodesInfo added in v1.0.1

func (api *API) GetCandidateNodesInfo() []*types.Tally

func (*API) GetLightTokenAccountByAccountAddress added in v1.1.2

func (api *API) GetLightTokenAccountByAccountAddress(address common.Address) *types.LightTokenAccount

func (*API) GetLightTokenBalanceByAddress added in v1.1.2

func (api *API) GetLightTokenBalanceByAddress(accountAddress common.Address, lightTokenAddress common.Address) string

func (*API) GetLightTokenByAddress added in v1.1.2

func (api *API) GetLightTokenByAddress(address common.Address) *types.LightToken

func (*API) GetLightTokenStakingsByAddress added in v1.1.2

func (api *API) GetLightTokenStakingsByAddress(accountAddress common.Address, lightTokenAddress common.Address) []*types.Staking

func (*API) GetSigners

func (api *API) GetSigners(number uint64) ([]common.Address, error)

func (*API) GetSignersAtHash

func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error)

func (*API) GetSuperNodesInfo

func (api *API) GetSuperNodesInfo() []*types.Tally

type HeaderExtra

type HeaderExtra struct {
	LoopStartTime        uint64
	SignersPool          []common.Address
	SignerMissing        []common.Address
	ConfirmedBlockNumber uint64
}

HeaderExtra is the struct of info in header.Extra[extraVanity:len(header.extra)-extraSeal] HeaderExtra is the current struct

type SignTxFn

SignTxFn is a signTx

type SignerFn

type SignerFn func(accounts.Account, []byte) ([]byte, error)

SignerFn is a signer callback function to request a hash to be signed by a backing account.

type SnapContext added in v1.0.3

type SnapContext struct {
	Number       uint64
	ParentHash   common.Hash
	TimeStamp    int64
	VdposContext *types.VdposContext
	SignersPool  []common.Address
	// contains filtered or unexported fields
}

type TallyItem

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

type TallySlice

type TallySlice []TallyItem

func (TallySlice) Len

func (s TallySlice) Len() int

func (TallySlice) Less

func (s TallySlice) Less(i, j int) bool

func (TallySlice) Swap

func (s TallySlice) Swap(i, j int)

type Vdpos

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

func New

func New(config *params.VdposConfig, db ethdb.Database) *Vdpos

New creates a Vdpos delegated-proof-of-stake consensus engine with the initial signers set to the ones provided by the user.

func (*Vdpos) APIs

func (v *Vdpos) APIs(chain consensus.ChainReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.

func (*Vdpos) Author

func (v *Vdpos) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.

func (*Vdpos) Authorize

func (v *Vdpos) Authorize(signer common.Address, signFn SignerFn, signTxFn SignTxFn)

Authorize injects a private key into the consensus engine to mint new blocks with.

func (*Vdpos) CalcDifficulty

func (v *Vdpos) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have. In Vdpos just return 1.

func (*Vdpos) Close

func (v *Vdpos) Close() error

Close implements consensus.Engine. It's a noop for vdpos as there are no background threads.

func (*Vdpos) Finalize

func (v *Vdpos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, vdposContext *types.VdposContext) (*types.Block, error)

Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.

func (*Vdpos) Prepare

func (v *Vdpos) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.

func (*Vdpos) Seal

func (v *Vdpos) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.

func (*Vdpos) SealHash

func (v *Vdpos) SealHash(header *types.Header) common.Hash

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

func (*Vdpos) VerifyHeader

func (v *Vdpos) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules.

func (*Vdpos) VerifyHeaders

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

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. 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 (*Vdpos) VerifySeal

func (v *Vdpos) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*Vdpos) VerifyUncles

func (v *Vdpos) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

Jump to

Keyboard shortcuts

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