dpos

package
v0.0.0-...-92cc422 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620

此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620

Index

Constants

This section is empty.

Variables

View Source
var (

	//如果块的时间戳低于,则返回errInvalidTimestamp
	//上一个块的时间戳+最小块周期。
	ErrInvalidTimestamp           = errors.New("invalid timestamp")
	ErrWaitForPrevBlock           = errors.New("wait for last block arrived")
	ErrMintFutureBlock            = errors.New("mint the future block")
	ErrMismatchSignerAndValidator = errors.New("mismatch block signer and validator")
	ErrInvalidBlockValidator      = errors.New("invalid block validator")
	ErrInvalidMintBlockTime       = errors.New("invalid time to mint the block")
	ErrNilBlockHeader             = errors.New("nil block header returned")
)

Functions

func AccumulateRewards

func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header)

func NextSlot

func NextSlot(now int64, blockInterval uint64) int64

func PrevSlot

func PrevSlot(now int64, blockInterval uint64) int64

Types

type API

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

API是面向用户的RPC API,允许控制委托和投票 委托股权证明机制

func (*API) GetConfirmedBlockNumber

func (api *API) GetConfirmedBlockNumber() (*big.Int, error)

getconfirmedBlockNumber检索最新的不可逆块

func (*API) GetValidators

func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)

getvalidators检索指定块上的验证程序列表

type Dpos

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

func New

func New(config *params.DposConfig, db ethdb.Database) *Dpos

func (*Dpos) APIs

func (d *Dpos) APIs(chain consensus.ChainReader) []rpc.API

func (*Dpos) Author

func (d *Dpos) Author(header *types.Header) (common.Address, error)

func (*Dpos) Authorize

func (d *Dpos) Authorize(signer common.Address, signFn SignerFn)

func (*Dpos) CalcDifficulty

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

func (*Dpos) CheckValidator

func (d *Dpos) CheckValidator(lastBlock *types.Block, now int64, blockInterval uint64) error

检查当前的验证人员是否在当前的节点上

func (*Dpos) Close

func (d *Dpos) Close() error

func (*Dpos) Finalize

func (d *Dpos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt, dposContext *types.DposContext) (*types.Block, error)

将出块周期内的交易打包进新的区域块中

func (*Dpos) Prepare

func (d *Dpos) Prepare(chain consensus.ChainReader, header *types.Header) error

func (*Dpos) Seal

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

Seal使用本地矿工的 密封顶部。 验证模块内容是否符合DPOSS计算法规(验证新模块是否应由该验证人员提出模块)

func (*Dpos) VerifyHeader

func (d *Dpos) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool, blockInterval uint64) error

验证批量是否符合共识算法规则

func (*Dpos) VerifyHeaders

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

批量验证区块头是否符合公共计算法规

func (*Dpos) VerifySeal

func (d *Dpos) VerifySeal(chain consensus.ChainReader, currentheader, genesisheader *types.Header) error

验证seal是否执行consension.engine,检查签名是否包含 头部满足共识协议要求。

func (*Dpos) VerifyUncles

func (d *Dpos) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

verifyuncles实现converse.engine,始终返回任何 因为这个共识机制不允许叔叔。

type EpochContext

type EpochContext struct {
	TimeStamp   int64
	DposContext *types.DposContext
	// contains filtered or unexported fields
}

type SignerFn

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

Jump to

Keyboard shortcuts

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