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 ¶
- Variables
- type API
- func (api *API) GetCandidateNodesInfo() []*types.Tally
- func (api *API) GetLightTokenAccountByAccountAddress(address common.Address) *types.LightTokenAccount
- func (api *API) GetLightTokenBalanceByAddress(accountAddress common.Address, lightTokenAddress common.Address) string
- func (api *API) GetLightTokenByAddress(address common.Address) *types.LightToken
- func (api *API) GetLightTokenStakingsByAddress(accountAddress common.Address, lightTokenAddress common.Address) []*types.Staking
- func (api *API) GetSigners(number uint64) ([]common.Address, error)
- func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error)
- func (api *API) GetSuperNodesInfo() []*types.Tally
- type HeaderExtra
- type SignTxFn
- type SignerFn
- type SnapContext
- type TallyItem
- type TallySlice
- type Vdpos
- func (v *Vdpos) APIs(chain consensus.ChainReader) []rpc.API
- func (v *Vdpos) Author(header *types.Header) (common.Address, error)
- func (v *Vdpos) Authorize(signer common.Address, signFn SignerFn, signTxFn SignTxFn)
- func (v *Vdpos) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (v *Vdpos) Close() error
- func (v *Vdpos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (v *Vdpos) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (v *Vdpos) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (v *Vdpos) SealHash(header *types.Header) common.Hash
- func (v *Vdpos) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (v *Vdpos) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (v *Vdpos) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (v *Vdpos) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
This section is empty.
Variables ¶
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 )
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) 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) 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) GetSignersAtHash ¶
func (*API) GetSuperNodesInfo ¶
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 ¶
type SignTxFn func(accounts.Account, *types.Transaction, *big.Int) (*types.Transaction, error)
SignTxFn is a signTx
type SignerFn ¶
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 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 ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*Vdpos) Authorize ¶
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 ¶
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 ¶
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) VerifyHeader ¶
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 ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Vdpos) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.