Documentation ¶
Index ¶
- Constants
- Variables
- func FindProposer(now int64, miners []byteutils.Hash) (proposer byteutils.Hash, err error)
- func TraverseDynasty(dynasty *trie.Trie) ([]byteutils.Hash, error)
- type Dpos
- func (dpos *Dpos) CheckDoubleMint(block *core.Block) bool
- func (dpos *Dpos) CheckTimeout(block *core.Block) bool
- func (dpos *Dpos) DisableMining() error
- func (dpos *Dpos) Enable() bool
- func (dpos *Dpos) EnableMining(passphrase string) error
- func (dpos *Dpos) ForkChoice() error
- func (dpos *Dpos) GenesisConsensusState(chain *core.BlockChain, conf *corepb.Genesis) (state.ConsensusState, error)
- func (dpos *Dpos) NewState(root *consensuspb.ConsensusRoot, stor storage.Storage, needChangeLog bool) (state.ConsensusState, error)
- func (dpos *Dpos) NumberOfBlocksInDynasty() uint64
- func (dpos *Dpos) Pending() bool
- func (dpos *Dpos) ResumeMining()
- func (dpos *Dpos) Setup(neblet core.Neblet) error
- func (dpos *Dpos) Start()
- func (dpos *Dpos) Stop()
- func (dpos *Dpos) SuspendMining()
- func (dpos *Dpos) UpdateLIB()
- func (dpos *Dpos) VerifyBlock(block *core.Block) error
- type State
- func (ds *State) Clone() (state.ConsensusState, error)
- func (ds *State) Dynasty() ([]byteutils.Hash, error)
- func (ds *State) DynastyRoot() byteutils.Hash
- func (ds *State) NextConsensusState(elapsedSecond int64, worldState state.WorldState) (state.ConsensusState, error)
- func (ds *State) Proposer() byteutils.Hash
- func (ds *State) Replay(done state.ConsensusState) error
- func (ds *State) RootHash() *consensuspb.ConsensusRoot
- func (ds *State) String() string
- func (ds *State) TimeStamp() int64
Constants ¶
View Source
const ( SecondInMs = int64(1000) BlockIntervalInMs = int64(15000) AcceptedNetWorkDelayInMs = int64(3750) MaxMintDurationInMs = int64(5250) MinMintDurationInMs = int64(2250) DynastyIntervalInMs = int64(3150000) DynastySize = 21 ConsensusSize = DynastySize*2/3 + 1 )
Consensus Related Constants
View Source
const (
DefaultMaxUnlockDuration time.Duration = 1<<63 - 1
)
const
Variables ¶
View Source
var ( ErrInvalidBlockTimestamp = errors.New("invalid block timestamp, should be same as consensus's timestamp") ErrInvalidBlockInterval = errors.New("invalid block interval") ErrMissingConfigForDpos = errors.New("missing configuration for Dpos") ErrInvalidBlockProposer = errors.New("invalid block proposer") ErrCannotMintWhenPending = errors.New("cannot mint block now, waiting for cancel pending again") ErrCannotMintWhenDisable = errors.New("cannot mint block now, waiting for enable it again") ErrWaitingBlockInLastSlot = errors.New("cannot mint block now, waiting for last block") ErrBlockMintedInNextSlot = errors.New("cannot mint block now, there is a block minted in current slot") ErrGenerateNextConsensusState = errors.New("Failed to generate next consensus state") ErrDoubleBlockMinted = errors.New("double block minted") ErrAppendNewBlockFailed = errors.New("failed to append new block to real chain") ErrInvalidArgument = errors.New("invalid argument") )
Errors in PoW Consensus
View Source
var ( ErrTooFewCandidates = errors.New("the size of candidates in consensus is un-safe, should be greater than or equal " + strconv.Itoa(ConsensusSize)) ErrInitialDynastyNotEnough = errors.New("the size of initial dynasty in genesis block is un-safe, should be greater than or equal " + strconv.Itoa(ConsensusSize)) ErrInvalidDynasty = errors.New("the size of initial dynasty in genesis block is invalid, should be equal " + strconv.Itoa(DynastySize)) ErrCloneDynastyTrie = errors.New("Failed to clone dynasty trie") ErrCloneNextDynastyTrie = errors.New("Failed to clone next dynasty trie") ErrCloneDelegateTrie = errors.New("Failed to clone delegate trie") ErrCloneCandidatesTrie = errors.New("Failed to clone candidates trie") ErrCloneVoteTrie = errors.New("Failed to clone vote trie") ErrCloneMintCntTrie = errors.New("Failed to clone mint count trie") ErrNotBlockForgTime = errors.New("now is not time to forg block") ErrFoundNilProposer = errors.New("found a nil proposer") )
Errors in dpos state
Functions ¶
func FindProposer ¶
FindProposer for now in given dynasty
Types ¶
type Dpos ¶
type Dpos struct {
// contains filtered or unexported fields
}
Dpos Delegate Proof-of-Stake
func (*Dpos) CheckDoubleMint ¶ added in v1.0.1
CheckDoubleMint if double mint exists
func (*Dpos) CheckTimeout ¶
CheckTimeout check whether the block is timeout
func (*Dpos) DisableMining ¶
DisableMining stop the consensus
func (*Dpos) EnableMining ¶
EnableMining start the consensus
func (*Dpos) GenesisConsensusState ¶
func (dpos *Dpos) GenesisConsensusState(chain *core.BlockChain, conf *corepb.Genesis) (state.ConsensusState, error)
GenesisConsensusState create a new genesis dpos state
func (*Dpos) NewState ¶
func (dpos *Dpos) NewState(root *consensuspb.ConsensusRoot, stor storage.Storage, needChangeLog bool) (state.ConsensusState, error)
NewState create a new dpos state
func (*Dpos) NumberOfBlocksInDynasty ¶ added in v1.0.2
NumberOfBlocksInDynasty number of blocks in one dynasty
type State ¶
type State struct {
// contains filtered or unexported fields
}
State carry context in dpos consensus
func (*State) DynastyRoot ¶
DynastyRoot return the roothash of current dynasty
func (*State) NextConsensusState ¶
func (ds *State) NextConsensusState(elapsedSecond int64, worldState state.WorldState) (state.ConsensusState, error)
NextConsensusState return the new state after some seconds elapsed
Click to show internal directories.
Click to hide internal directories.