Documentation ¶
Overview ¶
Package dpor implements the dpor consensus engine.
Index ¶
- Constants
- Variables
- type API
- func (api *API) GetProposers(number rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetRNodes() ([]common.Address, error)
- func (api *API) GetSnapshot(number rpc.BlockNumber) (*DporSnapshot, error)
- func (api *API) GetSnapshotAtHash(hash common.Hash) (*DporSnapshot, error)
- func (api *API) GetValidators(number rpc.BlockNumber) ([]common.Address, error)
- type BroadcastBlockFn
- type Dpor
- func New(config *configs.DporConfig, db database.Database) *Dpor
- func NewDoNothingFaker(config *configs.DporConfig, db database.Database) *Dpor
- func NewFakeDelayer(config *configs.DporConfig, db database.Database, delay time.Duration) *Dpor
- func NewFakeFailer(config *configs.DporConfig, db database.Database, fail uint64) *Dpor
- func NewFaker(config *configs.DporConfig, db database.Database) *Dpor
- func NewPbftFaker(config *configs.DporConfig, db database.Database) *Dpor
- func (d *Dpor) APIs(chain consensus.ChainReader) []rpc.API
- func (d *Dpor) Author(header *types.Header) (common.Address, error)
- func (d *Dpor) Authorize(signer common.Address, signFn backend.SignFn)
- func (d *Dpor) BlockDelay() time.Duration
- func (d *Dpor) BroadcastBlock(block *types.Block, prop bool)
- func (d *Dpor) CanMakeBlock(chain consensus.ChainReader, coinbase common.Address, parent *types.Header) bool
- func (d *Dpor) Coinbase() common.Address
- func (d *Dpor) CreateFailbackImpeachBlocks() (firstImpeachment *types.Block, secondImpeachment *types.Block, err error)
- func (d *Dpor) CreateImpeachBlock() (*types.Block, error)
- func (d *Dpor) CreateImpeachBlockAt(parentHeader *types.Header) (*types.Block, error)
- func (d *Dpor) CurrentSnap() *DporSnapshot
- func (d *Dpor) ECRecoverProposer(header *types.Header) (common.Address, error)
- func (d *Dpor) ECRecoverSigs(header *types.Header, state consensus.State) ([]common.Address, []types.DporSignature, error)
- func (d *Dpor) Faulty() uint64
- func (d *Dpor) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (d *Dpor) FutureTermOf(number uint64) uint64
- func (d *Dpor) GetBlockFromChain(hash common.Hash, number uint64) *types.Block
- func (d *Dpor) GetBlockReward(blockNum uint64) *big.Int
- func (d *Dpor) GetCalcRptInfo(address common.Address, addresses []common.Address, blockNum uint64) int64
- func (d *Dpor) GetCandidateBackend() campaign.CandidateService
- func (d *Dpor) GetCurrentBlock() *types.Block
- func (d *Dpor) GetMac() (mac string, sig []byte, err error)
- func (d *Dpor) GetRNodes() ([]common.Address, error)
- func (d *Dpor) GetRptBackend() rpt.RptService
- func (d *Dpor) HandleMinedBlock(block *types.Block) error
- func (d *Dpor) HasBlockInChain(hash common.Hash, number uint64) bool
- func (d *Dpor) IfSigned(number uint64) (common.Hash, bool)
- func (d *Dpor) ImpeachTimeout() time.Duration
- func (d *Dpor) InsertChain(block *types.Block) error
- func (d *Dpor) IsCurrentOrFutureProposer(address common.Address) bool
- func (d *Dpor) IsDefaultProposer(address common.Address) bool
- func (d *Dpor) IsMiner() bool
- func (d *Dpor) IsProposerOf(addr common.Address, number uint64) (bool, error)
- func (d *Dpor) IsToCampaign() bool
- func (d *Dpor) IsValidator() bool
- func (d *Dpor) MarkAsSigned(number uint64, hash common.Hash) error
- func (d *Dpor) Mode() Mode
- func (d *Dpor) PbftStatus() *consensus.PbftStatus
- func (d *Dpor) PeerInfos() ([]*backend.PeerInfo, error)
- func (d *Dpor) Period() time.Duration
- func (d *Dpor) PrepareBlock(chain consensus.ChainReader, header *types.Header) error
- func (d *Dpor) ProposerOf(number uint64) (common.Address, error)
- func (d *Dpor) ProposersOf(number uint64) ([]common.Address, error)
- func (d *Dpor) ProposersOfTerm(term uint64) ([]common.Address, error)
- func (d *Dpor) Protocol() consensus.Protocol
- func (d *Dpor) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (d *Dpor) SetAsMiner(isMiner bool)
- func (d *Dpor) SetAsValidator(isValidator bool)
- func (d *Dpor) SetCampaignBackend(campaignContract common.Address, backend backend.ClientBackend)
- func (d *Dpor) SetChain(blockchain consensus.ChainReadWriter)
- func (d *Dpor) SetChainConfig(blockchain consensus.ChainReadWriter)
- func (d *Dpor) SetConfig(conf *configs.DporConfig)
- func (d *Dpor) SetCurrentSnap(snap *DporSnapshot)
- func (d *Dpor) SetHandler(handler *backend.Handler) error
- func (d *Dpor) SetRNodeBackend(rNodeContract common.Address, backend backend.ClientBackend)
- func (d *Dpor) SetRptBackend(rptContract common.Address, backend backend.ClientBackend)
- func (d *Dpor) SetToCampaign(isToCampaign bool)
- func (d *Dpor) SetupAdmission(ac admission.ApiBackend)
- func (d *Dpor) SetupAsValidator(blockchain consensus.ChainReadWriter, server *p2p.Server, ...)
- func (d *Dpor) SignHash(hash []byte) ([]byte, error)
- func (d *Dpor) SignHeader(header *types.Header, state consensus.State) error
- func (d *Dpor) StartMining(blockchain consensus.ChainReadWriter, server *p2p.Server, ...)
- func (d *Dpor) State() consensus.State
- func (d *Dpor) Status() *consensus.PbftStatus
- func (d *Dpor) StatusUpdate() error
- func (d *Dpor) StopMining()
- func (d *Dpor) SyncFrom(p *p2p.Peer)
- func (d *Dpor) Synchronize()
- func (d *Dpor) TermLength() uint64
- func (d *Dpor) TermOf(number uint64) uint64
- func (d *Dpor) TryCampaign()
- func (d *Dpor) UpdateFinalSigsCache(validator common.Address, hash common.Hash, sig types.DporSignature)
- func (d *Dpor) UpdatePrepareSigsCache(validator common.Address, hash common.Hash, sig types.DporSignature)
- func (d *Dpor) ValidateBlock(block *types.Block, verifySigs bool, verifyProposers bool) error
- func (d *Dpor) ValidatorsNum() uint64
- func (d *Dpor) ValidatorsOf(number uint64) ([]common.Address, error)
- func (d *Dpor) ValidatorsOfTerm(term uint64) ([]common.Address, error)
- func (d *Dpor) VerifyHeader(chain consensus.ChainReader, header *types.Header, verifySigs bool, ...) error
- func (d *Dpor) VerifyHeaderWithState(header *types.Header, state consensus.State) error
- func (d *Dpor) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, verifySigs []bool, ...) (chan<- struct{}, <-chan error)
- func (d *Dpor) VerifyProposerOf(signer common.Address, term uint64) (bool, error)
- func (d *Dpor) VerifySeal(chain consensus.ChainReader, header *types.Header, refHeader *types.Header) error
- func (d *Dpor) VerifySigs(chain consensus.ChainReader, header *types.Header, refHeader *types.Header) error
- func (d *Dpor) VerifyValidatorOf(signer common.Address, term uint64) (bool, error)
- func (d *Dpor) ViewLength() uint64
- type DporSnapshot
- func (s *DporSnapshot) ApplyHeader(header *types.Header, ifUpdateCommittee bool, ...) error
- func (s *DporSnapshot) FutureProposerViewOf(signer common.Address, number uint64) (int, error)
- func (s *DporSnapshot) FutureProposersOf(number uint64) []common.Address
- func (s *DporSnapshot) FutureTermOf(blockNum uint64) uint64
- func (s *DporSnapshot) FutureValidatorsOf(number uint64) []common.Address
- func (s *DporSnapshot) GetRecentProposers(term uint64) []common.Address
- func (s *DporSnapshot) InturnOf(number uint64, signer common.Address) bool
- func (s *DporSnapshot) IsFutureProposerOf(proposer common.Address, number uint64) bool
- func (s *DporSnapshot) IsProposerOf(signer common.Address, number uint64) (bool, error)
- func (s *DporSnapshot) IsValidatorOf(validator common.Address, number uint64) bool
- func (s *DporSnapshot) ProposersOf(number uint64) []common.Address
- func (s *DporSnapshot) StartBlockNumberOfTerm(term uint64) uint64
- func (s *DporSnapshot) Term() uint64
- func (s *DporSnapshot) TermOf(blockNum uint64) uint64
- func (s *DporSnapshot) UpdateCandidates(candidateService campaign.CandidateService, seed int64) error
- func (s *DporSnapshot) UpdateProposers(rpts rpt.RptList, seed int64, rptService rpt.RptService)
- func (s *DporSnapshot) UpdateRpts(rptService rpt.RptService) (rpt.RptList, error)
- func (s *DporSnapshot) ValidatorViewOf(validator common.Address, number uint64) (int, error)
- func (s *DporSnapshot) ValidatorsOf(number uint64) []common.Address
- type Mode
- type SyncFromBestPeerFn
- type SyncFromPeerFn
Constants ¶
const ( // TermDistBetweenElectionAndMining is the the term gap between election and mining. TermDistBetweenElectionAndMining = 2 // TermDistBetweenElectionAndMining = effective term - current term(last block) //MaxSizeOfRecentValidators is the size of the RecentValidators MaxSizeOfRecentValidators = 200 //MaxSizeOfRecentProposers is the size of the RecentProposers MaxSizeOfRecentProposers = 200 )
Variables ¶
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") // ErrInvalidGasLimit is returned if the gasLimit of a block is invalid ErrInvalidGasLimit = errors.New("invalid gas limit for the block") )
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 proof-of-authority scheme.
func (*API) GetProposers ¶
GetProposers retrieves the Proposers at a given block.
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number rpc.BlockNumber) (*DporSnapshot, error)
GetSnapshot retrieves the state Snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
func (api *API) GetSnapshotAtHash(hash common.Hash) (*DporSnapshot, error)
GetSnapshotAtHash retrieves the state Snapshot at a given block.
func (*API) GetValidators ¶
GetValidators retrieves the Validators at a given block.
type BroadcastBlockFn ¶
BroadcastBlockFn broadcasts a block to normal peers(not pbft replicas)
type Dpor ¶
type Dpor struct {
// contains filtered or unexported fields
}
Dpor is the proof-of-reputation consensus engine proposed to support the cpchain testnet.
func New ¶
func New(config *configs.DporConfig, db database.Database) *Dpor
New creates a Dpor proof-of-reputation consensus engine with the initial signers set to the ones provided by the user.
func NewDoNothingFaker ¶
func NewDoNothingFaker(config *configs.DporConfig, db database.Database) *Dpor
NewDoNothingFaker creates a new fake dpor, do nothing when verifying blocks
func NewFakeDelayer ¶
NewFakeDelayer creates a new fake dpor, delays when verifying blocks
func NewFakeFailer ¶
NewFakeFailer creates a new fake dpor, always fails when verifying blocks
func NewFaker ¶
func NewFaker(config *configs.DporConfig, db database.Database) *Dpor
NewFaker creates a new fake dpor
func NewPbftFaker ¶
func NewPbftFaker(config *configs.DporConfig, db database.Database) *Dpor
NewPbftFaker creates a new fake dpor to work with pbft, not in use now
func (*Dpor) APIs ¶
func (d *Dpor) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.
func (*Dpor) Author ¶
Author implements consensus.Engine, returning the cpchain address recovered from the signature in the header's extra-data section.
func (*Dpor) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*Dpor) BlockDelay ¶
BlockDelay returns max delay of preprepare block propagation
func (*Dpor) BroadcastBlock ¶
BroadcastBlock broadcasts a block to normal peers(not pbft replicas)
func (*Dpor) CanMakeBlock ¶
func (d *Dpor) CanMakeBlock(chain consensus.ChainReader, coinbase common.Address, parent *types.Header) bool
CanMakeBlock checks if the given coinbase is ready to propose a block
func (*Dpor) CreateFailbackImpeachBlocks ¶
func (d *Dpor) CreateFailbackImpeachBlocks() (firstImpeachment *types.Block, secondImpeachment *types.Block, err error)
CreateFailbackImpeachBlocks creates impeachment blocks with failback timestamps
func (*Dpor) CreateImpeachBlock ¶
CreateImpeachBlock creates an impeachment block
func (*Dpor) CreateImpeachBlockAt ¶
CreateImpeachBlockAt creates an impeachment block
func (*Dpor) CurrentSnap ¶
func (d *Dpor) CurrentSnap() *DporSnapshot
CurrentSnap returns current dpor snapshot
func (*Dpor) ECRecoverProposer ¶
ECRecoverProposer recovers a proposer address from the seal of given header
func (*Dpor) ECRecoverSigs ¶
func (d *Dpor) ECRecoverSigs(header *types.Header, state consensus.State) ([]common.Address, []types.DporSignature, error)
ECRecoverSigs recovers signer address and corresponding signature, it ignores empty signature and return empty addresses if one of the sigs are illegal TODO: refactor this, return a map[common.Address]dpor.Signature
func (*Dpor) Finalize ¶
func (d *Dpor) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*Dpor) FutureTermOf ¶
FutureTermOf returns the future term number of given block number
func (*Dpor) GetBlockFromChain ¶
GetBlockFromChain implements DporService.GetBlockFromChain
func (*Dpor) GetBlockReward ¶
GetBlockReward returns block reward according to block number
func (*Dpor) GetCalcRptInfo ¶
func (d *Dpor) GetCalcRptInfo(address common.Address, addresses []common.Address, blockNum uint64) int64
GetCalcRptInfo get the rpt value of an address at specific block number
func (*Dpor) GetCandidateBackend ¶
func (d *Dpor) GetCandidateBackend() campaign.CandidateService
func (*Dpor) GetCurrentBlock ¶
GetCurrentBlock returns current block
func (*Dpor) GetRptBackend ¶
func (d *Dpor) GetRptBackend() rpt.RptService
func (*Dpor) HandleMinedBlock ¶
HandleMinedBlock receives a block to add to handler's pending block channel
func (*Dpor) HasBlockInChain ¶
HasBlockInChain returns if a block is in local chain
func (*Dpor) ImpeachTimeout ¶
ImpeachTimeout returns impeach time out
func (*Dpor) InsertChain ¶
InsertChain inserts a block to chain
func (*Dpor) IsCurrentOrFutureProposer ¶
IsCurrentOrFutureProposer checks if an address is a proposer in the period between current term and future term
func (*Dpor) IsDefaultProposer ¶
IsDefaultProposer returns if the given address is a default proposer
func (*Dpor) IsProposerOf ¶
IsProposerOf returns whether the given address is the proposer for the block number
func (*Dpor) IsToCampaign ¶
IsToCampaign returns if it is time to campaign
func (*Dpor) IsValidator ¶
IsValidator returns if the node is running as a validator
func (*Dpor) MarkAsSigned ¶
MarkAsSigned marks signed a hash as signed
func (*Dpor) PbftStatus ¶
func (d *Dpor) PbftStatus() *consensus.PbftStatus
PbftStatus returns current state of dpor
func (*Dpor) PrepareBlock ¶
PrepareBlock implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Dpor) ProposerOf ¶
ProposerOf returns the proposer of the specified block number by rpt and election calculation
func (*Dpor) ProposersOf ¶
ProposersOf returns proposers of given block number
func (*Dpor) ProposersOfTerm ¶
ProposersOfTerm returns proposers of given term TODO: same as above
func (*Dpor) Seal ¶
func (d *Dpor) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials. NB please populate the correct field values. we are now removing some fields such as nonce.
func (*Dpor) SetAsMiner ¶
SetAsMiner sets local coinbase as a miner
func (*Dpor) SetAsValidator ¶
SetAsValidator sets the consensus engine working as a validator
func (*Dpor) SetCampaignBackend ¶
func (d *Dpor) SetCampaignBackend(campaignContract common.Address, backend backend.ClientBackend)
func (*Dpor) SetChain ¶
func (d *Dpor) SetChain(blockchain consensus.ChainReadWriter)
SetChain is called by test file to assign the value of Dpor.chain, as well as DPor.currentSnapshot
func (*Dpor) SetChainConfig ¶
func (d *Dpor) SetChainConfig(blockchain consensus.ChainReadWriter)
Set chainconfig is called for unittest
func (*Dpor) SetConfig ¶
func (d *Dpor) SetConfig(conf *configs.DporConfig)
func (*Dpor) SetCurrentSnap ¶
func (d *Dpor) SetCurrentSnap(snap *DporSnapshot)
SetCurrentSnap sets current dpor snapshot
func (*Dpor) SetHandler ¶
SetHandler sets dpor.handler
func (*Dpor) SetRNodeBackend ¶
func (d *Dpor) SetRNodeBackend(rNodeContract common.Address, backend backend.ClientBackend)
func (*Dpor) SetRptBackend ¶
func (d *Dpor) SetRptBackend(rptContract common.Address, backend backend.ClientBackend)
func (*Dpor) SetToCampaign ¶
SetToCampaign sets isToCampaign as true
func (*Dpor) SetupAdmission ¶
func (d *Dpor) SetupAdmission(ac admission.ApiBackend)
SetupAdmission setups admission backend
func (*Dpor) SetupAsValidator ¶
func (d *Dpor) SetupAsValidator(blockchain consensus.ChainReadWriter, server *p2p.Server, pmBroadcastBlockFn BroadcastBlockFn, pmSyncFromPeerFn SyncFromPeerFn, pmSyncFromBestPeerFn SyncFromBestPeerFn)
func (*Dpor) SignHeader ¶
SignHeader signs the header and adds all known sigs to header
func (*Dpor) StartMining ¶
func (d *Dpor) StartMining(blockchain consensus.ChainReadWriter, server *p2p.Server, pmBroadcastBlockFn BroadcastBlockFn, pmSyncFromPeerFn SyncFromPeerFn, pmSyncFromBestPeerFn SyncFromBestPeerFn)
StartMining starts to create a handler and start it.
func (*Dpor) Status ¶
func (d *Dpor) Status() *consensus.PbftStatus
Status returns a pbft replica's status
func (*Dpor) Synchronize ¶
func (d *Dpor) Synchronize()
Synchronize tries to sync blocks from best peer
func (*Dpor) UpdateFinalSigsCache ¶
func (d *Dpor) UpdateFinalSigsCache(validator common.Address, hash common.Hash, sig types.DporSignature)
UpdateFinalSigsCache updates final(commit) signature of a validator for a block in cache
func (*Dpor) UpdatePrepareSigsCache ¶
func (d *Dpor) UpdatePrepareSigsCache(validator common.Address, hash common.Hash, sig types.DporSignature)
UpdatePrepareSigsCache updates prepare signature of a validator for a block in cache
func (*Dpor) ValidateBlock ¶
ValidateBlock validates a basic field excepts seal of a block.
func (*Dpor) ValidatorsNum ¶
ValidatorsNum returns number of validators
func (*Dpor) ValidatorsOf ¶
ValidatorsOf returns validators of given block number
func (*Dpor) ValidatorsOfTerm ¶
ValidatorsOfTerm returns validators of given term TODO: this only returns validators known recently from cache, does not retrieve block from local chain to get needed information. maybe i'll add it later.
func (*Dpor) VerifyHeader ¶
func (d *Dpor) VerifyHeader(chain consensus.ChainReader, header *types.Header, verifySigs bool, refHeader *types.Header) error
VerifyHeader checks whether a header conforms to the consensus rules.
func (*Dpor) VerifyHeaderWithState ¶
VerifyHeaderWithState verifies the given header TODO: review this!
func (*Dpor) VerifyHeaders ¶
func (d *Dpor) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, verifySigs []bool, refHeaders []*types.Header) (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 (*Dpor) VerifyProposerOf ¶
VerifyProposerOf verifies if an address is a proposer of given term
func (*Dpor) VerifySeal ¶
func (d *Dpor) VerifySeal(chain consensus.ChainReader, header *types.Header, refHeader *types.Header) error
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Dpor) VerifySigs ¶
func (d *Dpor) VerifySigs(chain consensus.ChainReader, header *types.Header, refHeader *types.Header) error
VerifySigs checks if header has enough signatures of validators.
func (*Dpor) VerifyValidatorOf ¶
VerifyValidatorOf verifies if an address is a validator of given term
type DporSnapshot ¶
type DporSnapshot struct { Mode Mode `json:"mode"` Number uint64 `json:"number"` // Block number where the Snapshot was created Hash common.Hash `json:"hash"` // Block hash where the Snapshot was created Candidates []common.Address `json:"candidates"` // Set of candidates read from campaign contract RecentProposers map[uint64][]common.Address `json:"proposers"` // Set of recent proposers RecentValidators map[uint64][]common.Address `json:"validators"` // Set of recent validators // contains filtered or unexported fields }
DporSnapshot is the state of the authorization voting at a given point in time.
func NewSnapshot ¶
func (*DporSnapshot) ApplyHeader ¶
func (s *DporSnapshot) ApplyHeader(header *types.Header, ifUpdateCommittee bool, candidateService campaign.CandidateService, rptService rpt.RptService) error
func (*DporSnapshot) FutureProposerViewOf ¶
FutureProposerViewOf returns the future signer view with given signer address and block number
func (*DporSnapshot) FutureProposersOf ¶
func (s *DporSnapshot) FutureProposersOf(number uint64) []common.Address
FutureProposersOf returns future proposers of given block number
func (*DporSnapshot) FutureTermOf ¶
func (s *DporSnapshot) FutureTermOf(blockNum uint64) uint64
FutureTermOf returns future term idx with given block number
func (*DporSnapshot) FutureValidatorsOf ¶
func (s *DporSnapshot) FutureValidatorsOf(number uint64) []common.Address
FutureValidatorsOf returns future validators of given block number
func (*DporSnapshot) GetRecentProposers ¶
func (s *DporSnapshot) GetRecentProposers(term uint64) []common.Address
func (*DporSnapshot) InturnOf ¶
func (s *DporSnapshot) InturnOf(number uint64, signer common.Address) bool
InturnOf returns if a signer at a given block height is in-turn or not
func (*DporSnapshot) IsFutureProposerOf ¶
func (s *DporSnapshot) IsFutureProposerOf(proposer common.Address, number uint64) bool
IsFutureProposerOf returns if an address is a future proposer in the given block number
func (*DporSnapshot) IsProposerOf ¶
IsProposerOf returns if an address is a proposer in the given block number
func (*DporSnapshot) IsValidatorOf ¶
func (s *DporSnapshot) IsValidatorOf(validator common.Address, number uint64) bool
IsValidatorOf returns if an address is a validator in the given block number
func (*DporSnapshot) ProposersOf ¶
func (s *DporSnapshot) ProposersOf(number uint64) []common.Address
ProposersOf returns proposers of given block number
func (*DporSnapshot) StartBlockNumberOfTerm ¶
func (s *DporSnapshot) StartBlockNumberOfTerm(term uint64) uint64
StartBlockNumberOfTerm returns the first block number of a term
func (*DporSnapshot) Term ¶
func (s *DporSnapshot) Term() uint64
Term returns the term index of current block number, which is 0-based
func (*DporSnapshot) TermOf ¶
func (s *DporSnapshot) TermOf(blockNum uint64) uint64
TermOf returns the term index of given block number
func (*DporSnapshot) UpdateCandidates ¶
func (s *DporSnapshot) UpdateCandidates(candidateService campaign.CandidateService, seed int64) error
func (*DporSnapshot) UpdateProposers ¶
func (s *DporSnapshot) UpdateProposers(rpts rpt.RptList, seed int64, rptService rpt.RptService)
func (*DporSnapshot) UpdateRpts ¶
func (s *DporSnapshot) UpdateRpts(rptService rpt.RptService) (rpt.RptList, error)
func (*DporSnapshot) ValidatorViewOf ¶
ValidatorViewOf returns validator's view with given validator's address and block number
func (*DporSnapshot) ValidatorsOf ¶
func (s *DporSnapshot) ValidatorsOf(number uint64) []common.Address
ValidatorsOf returns validators of given block number
type SyncFromBestPeerFn ¶
type SyncFromBestPeerFn func()
SyncFromBestPeerFn tries to sync blocks from best peer
type SyncFromPeerFn ¶
SyncFromPeerFn tries to sync blocks from given peer