Documentation ¶
Index ¶
- Constants
- Variables
- func NextMintSlotInSec(ts int64) int64
- type Dpos
- func (d *Dpos) DynastyInterval() time.Duration
- func (d *Dpos) DynastySize() int
- func (d *Dpos) FindLIB(bc *core.BlockChain) (newLIB *core.Block)
- func (d *Dpos) FindMintProposer(ts int64, parent *core.Block) (common.Address, error)
- func (d *Dpos) MakeMintDynasty(ts int64, parentState *core.BlockState) ([]common.Address, error)
- func (d *Dpos) MaximumHeightWithTimestamp(libHeight uint64, libTs, ts int64) uint64
- func (d *Dpos) MinimumTimestampWithHeight(libTs int64, libHeight, height uint64) int64
- func (d *Dpos) MissingBlocks(lib, bd *core.BlockData) uint64
- func (d *Dpos) NewConsensusState(dposRootBytes []byte, stor storage.Storage) (*dState.State, error)
- func (d *Dpos) Proposers() map[common.Address]*Proposer
- func (d *Dpos) SetEventEmitter(emitter *event.Emitter)
- func (d *Dpos) Setup(cfg *medletpb.Config, genesis *corepb.Genesis, bm *core.BlockManager, ...) error
- func (d *Dpos) Start()
- func (d *Dpos) Stop()
- func (d *Dpos) VerifyHeightAndTimestamp(lib, bd *core.BlockData) error
- func (d *Dpos) VerifyInterval(bd *core.BlockData, parent *core.Block) error
- func (d *Dpos) VerifyProposer(b *core.Block) error
- type Proposer
Constants ¶
const ( BlockInterval = 3 * time.Second NumberOfRounds = 1 )
Consensus properties.
Variables ¶
var ( ErrBlockMintedInNextSlot = errors.New("cannot mint block now, there is a block minted in current slot") ErrInvalidBlockInterval = errors.New("invalid block interval") ErrInvalidBlockProposer = errors.New("invalid block proposer") ErrInvalidDynastySize = errors.New("invalid dynasty size") ErrWaitingBlockInLastSlot = errors.New("cannot mint block now, waiting for last block") ErrProposerConfigNotFound = errors.New("proposer config not found") ErrCannotRevertLIB = errors.New("cannot revert lib") ErrInvalidHeightByLIB = errors.New("high height compare to timestamp") ErrInvalidTimestampByLIB = errors.New("early timestamp compare to block height") )
Error types of dpos package.
Functions ¶
func NextMintSlotInSec ¶
NextMintSlotInSec returns timestamp for next mint slot
Types ¶
type Dpos ¶
type Dpos struct {
// contains filtered or unexported fields
}
Dpos returns dpos consensus model.
func (*Dpos) DynastyInterval ¶
DynastyInterval returns dynasty interval
func (*Dpos) FindLIB ¶
func (d *Dpos) FindLIB(bc *core.BlockChain) (newLIB *core.Block)
FindLIB finds new LIB.
func (*Dpos) FindMintProposer ¶
FindMintProposer returns proposer for mint block
func (*Dpos) MakeMintDynasty ¶
MakeMintDynasty returns dynasty slice for mint block
func (*Dpos) MaximumHeightWithTimestamp ¶
MaximumHeightWithTimestamp return maximum height based on lib
func (*Dpos) MinimumTimestampWithHeight ¶
MinimumTimestampWithHeight returns minimum timestamp based on lib
func (*Dpos) MissingBlocks ¶
MissingBlocks returns number of missing blocks based on lib
func (*Dpos) NewConsensusState ¶
NewConsensusState generates new dpos state
func (*Dpos) SetEventEmitter ¶
SetEventEmitter sets eventEmitter
func (*Dpos) Setup ¶
func (d *Dpos) Setup(cfg *medletpb.Config, genesis *corepb.Genesis, bm *core.BlockManager, tm *core.TransactionManager) error
Setup sets up dpos.
func (*Dpos) VerifyHeightAndTimestamp ¶
VerifyHeightAndTimestamp verify height and timestamp based on lib
func (*Dpos) VerifyInterval ¶
VerifyInterval verifies block interval.