consensus

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBlockIntervalSec = int64(1)

DefaultBlockIntervalSec is the default block generation interval in seconds.

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 {
	IsTransactionValid(tx *types.Tx) bool
	VerifyTimestamp(block *types.Block) bool
	VerifySign(block *types.Block) error
	IsBlockValid(block *types.Block, bestBlock *types.Block) error
	Update(block *types.Block)
	Save(tx db.Transaction) error
	NeedReorganization(rootNo types.BlockNo) bool
}

ChainConsensus includes chainstatus and validation API.

type ChainDB added in v0.9.4

type ChainDB interface {
	GetBestBlock() (*types.Block, error)
	GetBlockByNo(blockNo types.BlockNo) (*types.Block, error)
	GetGenesisInfo() *types.Genesis
	Get(key []byte) []byte
	NewTx() db.Transaction
}

ChainDB 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{}
}

Consensus is an interface for a consensus implementation.

type Constructor added in v0.9.4

type Constructor func() (Consensus, error)

Constructor represents a function returning the Consensus interfactor for each 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