dpos

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BlockInterval  = 3 * time.Second
	NumberOfRounds = 1
)

Consensus properties.

Variables

View Source
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

func NextMintSlotInSec(ts int64) int64

NextMintSlotInSec returns timestamp for next mint slot

Types

type Dpos

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

Dpos returns dpos consensus model.

func New

func New(dynastySize int) *Dpos

New returns dpos consensus.

func (*Dpos) DynastyInterval

func (d *Dpos) DynastyInterval() time.Duration

DynastyInterval returns dynasty interval

func (*Dpos) DynastySize

func (d *Dpos) DynastySize() int

DynastySize returns dynastySize

func (*Dpos) FindLIB

func (d *Dpos) FindLIB(bc *core.BlockChain) (newLIB *core.Block)

FindLIB finds new LIB.

func (*Dpos) FindMintProposer

func (d *Dpos) FindMintProposer(ts int64, parent *core.Block) (common.Address, error)

FindMintProposer returns proposer for mint block

func (*Dpos) MakeMintDynasty

func (d *Dpos) MakeMintDynasty(ts int64, parentState *core.BlockState) ([]common.Address, error)

MakeMintDynasty returns dynasty slice for mint block

func (*Dpos) MaximumHeightWithTimestamp

func (d *Dpos) MaximumHeightWithTimestamp(libHeight uint64, libTs, ts int64) uint64

MaximumHeightWithTimestamp return maximum height based on lib

func (*Dpos) MinimumTimestampWithHeight

func (d *Dpos) MinimumTimestampWithHeight(libTs int64, libHeight, height uint64) int64

MinimumTimestampWithHeight returns minimum timestamp based on lib

func (*Dpos) MissingBlocks

func (d *Dpos) MissingBlocks(lib, bd *core.BlockData) uint64

MissingBlocks returns number of missing blocks based on lib

func (*Dpos) NewConsensusState

func (d *Dpos) NewConsensusState(dposRootBytes []byte, stor storage.Storage) (*dState.State, error)

NewConsensusState generates new dpos state

func (*Dpos) Proposers

func (d *Dpos) Proposers() map[common.Address]*Proposer

Proposers returns Proposers

func (*Dpos) SetEventEmitter

func (d *Dpos) SetEventEmitter(emitter *event.Emitter)

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) Start

func (d *Dpos) Start()

Start starts proposer.

func (*Dpos) Stop

func (d *Dpos) Stop()

Stop stops proposer.

func (*Dpos) VerifyHeightAndTimestamp

func (d *Dpos) VerifyHeightAndTimestamp(lib, bd *core.BlockData) error

VerifyHeightAndTimestamp verify height and timestamp based on lib

func (*Dpos) VerifyInterval

func (d *Dpos) VerifyInterval(bd *core.BlockData, parent *core.Block) error

VerifyInterval verifies block interval.

func (*Dpos) VerifyProposer

func (d *Dpos) VerifyProposer(b *core.Block) error

VerifyProposer verifies block Proposer.

type Proposer

type Proposer struct {
	ProposerAddress common.Address
	Coinbase        common.Address
	// contains filtered or unexported fields
}

Proposer returns proposer

Directories

Path Synopsis
Package dpospb is a generated protocol buffer package.
Package dpospb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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