dpos

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 21 Imported by: 0

README

dpos delegated-proof-of-stake

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTimestamp           = errors.New("invalid timestamp")
	ErrWaitForPrevBlock           = errors.New("wait for last block arrived")
	ErrMintIngoreBlock            = errors.New("mint the ingore block")
	ErrMintFutureBlock            = errors.New("mint the future block")
	ErrMismatchSignerAndValidator = errors.New("mismatch block signer and validator")
	ErrInvalidBlockValidator      = errors.New("invalid block validator")
	ErrTooMuchUnconfirmedBlock    = errors.New("too much unconfirmed block")
	ErrInvalidMintBlockTime       = errors.New("invalid time to mint the block")
	ErrNilBlockHeader             = errors.New("nil block header returned")
)
View Source
var Option = &option{
	BlockInterval:    int64(500 * time.Millisecond),
	BlockRepeat:      12,
	MaxValidatorSize: 3,
	MinStartQuantity: new(big.Int).Mul(big.NewInt(1000000), big.NewInt(1e18)),
	DelayEpcho:       2,
	MaxConfirmedNum:  72,
}

Functions

func Slot

func Slot(now int64) int64

Types

type Dpos

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

func NewDpos

func NewDpos(eventMux *feed.TypeMux, chainDb db.Database, db state.Database, signFn SignerFn, passphrase string) *Dpos

func (*Dpos) Author

func (d *Dpos) Author(header *types.BlockHeader) (utils.Address, error)

func (*Dpos) CalcDifficulty

func (d *Dpos) CalcDifficulty(chain consensus.IChainReader, config *params.ChainConfig, time uint64, parent *types.BlockHeader) *big.Int

func (*Dpos) CheckValidator

func (d *Dpos) CheckValidator(chain consensus.IChainReader, lastBlock *types.Block, coinbase utils.Address, now int64) error

func (*Dpos) EpchoBlockHeader

func (d *Dpos) EpchoBlockHeader(chain consensus.IChainReader, timestamp int64, lastBlock *types.Block) *types.BlockHeader

func (*Dpos) Finalize

func (d *Dpos) Finalize(chain consensus.IChainReader, header *types.BlockHeader, state *state.StateDB, txs []*types.Transaction, actions []*types.Action, receipts []*types.Receipt, dposContext *types.DposContext) (*types.Block, error)

func (*Dpos) GetBFTConfirmedBlockNumber

func (dpos *Dpos) GetBFTConfirmedBlockNumber() (*big.Int, error)

func (*Dpos) GetConfirmedBlockNumber

func (d *Dpos) GetConfirmedBlockNumber() (*big.Int, error)

func (*Dpos) Init

func (d *Dpos) Init(chain consensus.IChainReader)

func (*Dpos) Seal

func (d *Dpos) Seal(chain consensus.IChainReader, block *types.Block, stop <-chan struct{}, threads int, updateHashes chan uint64) (*types.Block, error)

func (*Dpos) SetCoinBase

func (d *Dpos) SetCoinBase(addr utils.Address)

func (*Dpos) VerifySeal

func (d *Dpos) VerifySeal(chain consensus.IChainReader, header *types.BlockHeader) error

type EpochContext

type EpochContext struct {
	TimeStamp   int64
	DposContext *types.DposContext
	Statedb     *state.StateDB
	Config      *params.ChainConfig
}

func (*EpochContext) CountVotes

func (ec *EpochContext) CountVotes() (votes map[utils.Address]*big.Int, total *big.Int, err error)

CountVotes

type SignerFn

type SignerFn func(utils.Address, string, []byte) ([]byte, error)

type UInt64Slice

type UInt64Slice []uint64

UInt64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order.

func (UInt64Slice) Len

func (s UInt64Slice) Len() int

func (UInt64Slice) Less

func (s UInt64Slice) Less(i, j int) bool

func (UInt64Slice) Swap

func (s UInt64Slice) Swap(i, j int)

Jump to

Keyboard shortcuts

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