single

package
v0.0.0-...-b124b1e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MinerAddressErr = errors.New("Block's proposer must be equal to its address.")
)

Functions

func NewSingleConsensus

func NewSingleConsensus(cctx base.ConsensusCtx, ccfg base.ConsensusConfig) base.CommonConsensus

NewSingleConsensus 初始化实例

Types

type SingleConfig

type SingleConfig struct {
	Miner string `json:"miner"`
	// 单位为毫秒
	Period  int64 `json:"period"`
	Version int64 `json:"version"`
}

type SingleConsensus

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

SingleConsensus 单点出块的共识逻辑

func (*SingleConsensus) CalculateBlock

func (s *SingleConsensus) CalculateBlock(block ledger.BlockHandle) error

func (*SingleConsensus) CheckMinerMatch

func (s *SingleConsensus) CheckMinerMatch(ctx xctx.Context, block ledger.BlockHandle) (bool, error)

func (*SingleConsensus) CompeteMaster

func (s *SingleConsensus) CompeteMaster(height int64) (bool, bool, error)

func (*SingleConsensus) GetConsensusStatus

func (s *SingleConsensus) GetConsensusStatus() (base.ConsensusStatus, error)

GetStatus 获取区块链共识信息

func (*SingleConsensus) ParseConsensusStorage

func (s *SingleConsensus) ParseConsensusStorage(block ledger.BlockHandle) (interface{}, error)

func (*SingleConsensus) ProcessBeforeMiner

func (s *SingleConsensus) ProcessBeforeMiner(height, timestamp int64) ([]byte, []byte, error)

ProcessBeforeMiner 开始挖矿前进行相应的处理, Single共识返回空

func (*SingleConsensus) ProcessConfirmBlock

func (s *SingleConsensus) ProcessConfirmBlock(block ledger.BlockHandle) error

func (*SingleConsensus) Start

func (s *SingleConsensus) Start() error

func (*SingleConsensus) Stop

func (s *SingleConsensus) Stop() error

type SingleStatus

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

func (*SingleStatus) GetConsensusBeginInfo

func (s *SingleStatus) GetConsensusBeginInfo() int64

func (*SingleStatus) GetConsensusName

func (s *SingleStatus) GetConsensusName() string

func (*SingleStatus) GetCurrentTerm

func (s *SingleStatus) GetCurrentTerm() int64

func (*SingleStatus) GetCurrentValidatorsInfo

func (s *SingleStatus) GetCurrentValidatorsInfo() []byte

func (*SingleStatus) GetStepConsensusIndex

func (s *SingleStatus) GetStepConsensusIndex() int

func (*SingleStatus) GetVersion

func (s *SingleStatus) GetVersion() int64

type ValidatorsInfo

type ValidatorsInfo struct {
	Validators []string `json:"validators"`
}

Jump to

Keyboard shortcuts

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