dpos

package
v0.8.3-dl0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInitialBPs added in v0.8.2

func GetInitialBPs() []string

GetInitialBPs returns the initial BP IDs, which are loaded from Genesis info in the chain DB.

func Init

func Init(cfg *config.ConsensusConfig)

Init initilizes the DPoS parameters.

func New

New returns a new DPos object

Types

type BlockFactory

type BlockFactory struct {
	*component.ComponentHub

	ID string
	// contains filtered or unexported fields
}

BlockFactory is the main data structure for DPoS block factory.

func NewBlockFactory

func NewBlockFactory(hub *component.ComponentHub, quitC <-chan interface{}) *BlockFactory

NewBlockFactory returns a new BlockFactory

func (*BlockFactory) JobQueue

func (bf *BlockFactory) JobQueue() chan<- interface{}

JobQueue returns the queue for block production triggering.

func (*BlockFactory) Start

func (bf *BlockFactory) Start()

Start run a DPoS block factory service.

type DPoS

type DPoS struct {
	*Status
	*component.ComponentHub
	// contains filtered or unexported fields
}

DPoS is the main data structure of DPoS consensus

func (*DPoS) BlockFactory

func (dpos *DPoS) BlockFactory() consensus.BlockFactory

BlockFactory returns the BlockFactory interface in dpos.

func (*DPoS) IsBlockValid

func (dpos *DPoS) IsBlockValid(block *types.Block, bestBlock *types.Block) error

IsBlockValid checks the DPoS consensus level validity of a block

func (*DPoS) IsTransactionValid

func (dpos *DPoS) IsTransactionValid(tx *types.Tx) bool

IsTransactionValid checks the DPoS consensus level validity of a transaction

func (*DPoS) QueueJob

func (dpos *DPoS) QueueJob(now time.Time, jq chan<- interface{})

QueueJob send a block triggering information to jq.

func (*DPoS) QuitChan

func (dpos *DPoS) QuitChan() chan interface{}

QuitChan returns the channel from which consensus-related goroutines check when shutdown is initiated.

func (*DPoS) SetChainAccessor

func (dpos *DPoS) SetChainAccessor(chainAccessor types.ChainAccessor)

SetChainAccessor sets dpost.ca to chainAccessor

func (*DPoS) SetStateDB

func (dpos *DPoS) SetStateDB(sdb *state.ChainStateDB)

SetStateDB sets sdb to the corresponding field of DPoS. This method is called only once during the boot sequence.

func (*DPoS) Ticker

func (dpos *DPoS) Ticker() *time.Ticker

Ticker returns a time.Ticker for the main consensus loop.

type Status

type Status struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Status manages DPoS-related infomations like LIB.

func NewStatus

func NewStatus(confirmsRequired uint16, cdb consensus.ChainDbReader) *Status

NewStatus returns a newly allocated Status.

func (*Status) NeedReorganization

func (s *Status) NeedReorganization(rootNo types.BlockNo) bool

NeedReorganization reports whether reorganization is needed or not.

func (*Status) Save

func (s *Status) Save(tx db.Transaction) error

Save saves the consensus status information for the later recovery.

func (*Status) Update

func (s *Status) Update(block *types.Block)

Update updates the last irreversible block (LIB).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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