consensus

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBlockIntervalSec  is the default block generation interval in seconds.
	DefaultBlockIntervalSec = int64(1) // block production interval in sec

	// DefaultDposBpNumber is the default number of block producers.
	DefaultDposBpNumber = 23
)

Variables

View Source
var (
	// BlockIntervalSec is the block genration interval in seconds.
	BlockIntervalSec = DefaultBlockIntervalSec

	// BlockInterval is the maximum block generation time limit.
	BlockInterval = time.Second * time.Duration(DefaultBlockIntervalSec)
)

Functions

func InitBlockInterval

func InitBlockInterval(blockIntervalSec int64)

InitBlockInterval initializes block interval parameters.

func Start

func Start(c Consensus)

Start run a selected consesus service.

func Stop

func Stop(c Consensus)

Stop shutdown consensus service.

Types

type BlockFactory

type BlockFactory interface {
	Start()
	JobQueue() chan<- interface{}
}

BlockFactory is an interface for a block factory implementation.

type ChainConsensus

type ChainConsensus interface {
	SetStateDB(sdb *state.ChainStateDB)
	IsTransactionValid(tx *types.Tx) bool
	IsBlockValid(block *types.Block, bestBlock *types.Block) error
	Init(cdb ChainDbReader)
	Update(block *types.Block)
	Save(tx db.Transaction) error
	NeedReorganization(rootNo types.BlockNo) bool
}

ChainConsensus includes chainstatus and validation API.

type ChainDbReader

type ChainDbReader interface {
	GetBestBlock() (*types.Block, error)
	GetBlockByNo(blockNo types.BlockNo) (*types.Block, error)
	Get(key []byte) []byte
}

ChainDbReader is a reader interface for the ChainDB.

type Consensus

type Consensus interface {
	ChainConsensus
	Ticker() *time.Ticker
	QueueJob(now time.Time, jq chan<- interface{})
	BlockFactory() BlockFactory
	QuitChan() chan interface{}
	SetChainAccessor(chainAccessor types.ChainAccessor)
}

Consensus is an interface for a consensus implementation.

type ErrorConsensus

type ErrorConsensus struct {
	Msg string
	Err error
}

ErrorConsensus is a basic error struct for consensus modules.

func (ErrorConsensus) Error

func (e ErrorConsensus) Error() string

Directories

Path Synopsis
sbp

Jump to

Keyboard shortcuts

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