dpos

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LibStatusKey = []byte("dpos.LibStatus")

LibStatusKey is the key when a LIB information is put into the chain DB.

Functions

func GetConstructor added in v0.9.4

GetConstructor build and returns consensus.Constructor from New function.

func GetName added in v1.0.0

func GetName() string

GetName returns the name of the consensus.

func Init

func Init(bpCount uint16)

Init initilizes the DPoS parameters.

func InitVPR added in v1.3.3

func InitVPR(sdb *state.StateDB) error

func New

New returns a new DPos object

func ValidateGenesis added in v1.3.3

func ValidateGenesis(genesis *types.Genesis) error

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,
	sdb *state.ChainStateDB,
	quitC <-chan interface{},
	bv types.BlockVersionner,
) *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
	consensus.ChainDB
	*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) ClusterInfo added in v1.3.3

func (dpos *DPoS) ClusterInfo(bestBlockHash []byte) *types.GetClusterInfoResponse

func (*DPoS) ConfChange added in v1.3.3

func (dpos *DPoS) ConfChange(req *types.MembershipChange) (*consensus.Member, error)

func (*DPoS) ConfChangeInfo added in v1.3.3

func (dpos *DPoS) ConfChangeInfo(requestID uint64) (*types.ConfChangeProgress, error)

func (*DPoS) ConsensusInfo added in v1.0.0

func (dpos *DPoS) ConsensusInfo() *types.ConsensusInfo

ConsensusInfo returns the basic DPoS-related info.

func (*DPoS) GetType added in v1.0.0

func (dpos *DPoS) GetType() consensus.ConsensusType

func (*DPoS) HasWAL added in v1.3.3

func (dpos *DPoS) HasWAL() bool

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) IsConnectedBlock added in v1.3.3

func (dpos *DPoS) IsConnectedBlock(block *types.Block) bool

func (*DPoS) IsForkEnable added in v1.3.3

func (dpos *DPoS) IsForkEnable() bool

func (*DPoS) IsTransactionValid

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

IsTransactionValid checks the DPoS consensus level validity of a transaction

func (*DPoS) MakeConfChangeProposal added in v1.3.3

func (dpos *DPoS) MakeConfChangeProposal(req *types.MembershipChange) (*consensus.ConfChangePropose, error)

func (*DPoS) NeedNotify added in v1.3.3

func (dpos *DPoS) NeedNotify() bool

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) RaftAccessor added in v1.3.3

func (dpos *DPoS) RaftAccessor() consensus.AergoRaftAccessor

func (*DPoS) Ticker

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

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

func (*DPoS) VerifySign added in v0.9.10

func (dpos *DPoS) VerifySign(block *types.Block) error

VerifySign reports the validity of the block signature.

func (*DPoS) VerifyTimestamp added in v0.11.0

func (dpos *DPoS) VerifyTimestamp(block *types.Block) bool

VerifyTimestamp checks the validity of the block timestamp.

type Status

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

Status manages DPoS-related infomations like LIB.

func NewStatus

func NewStatus(c bp.ClusterMember, cdb consensus.ChainDB, sdb *state.ChainStateDB, resetHeight types.BlockNo) *Status

NewStatus returns a newly allocated Status.

func (*Status) Info added in v1.0.0

func (s *Status) Info() string

Info returns the current last irreversible block information as a JSON string.

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 consensus.TxWriter) error

Save saves the consensus status information for the later recovery.

func (*Status) String added in v1.0.0

func (s *Status) String() string

String returns the current LIB as a JSON string.

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