mediator

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package mediator provides some functions for use in other modules

Index

Constants

This section is empty.

Variables

Proc is the global unique instance of the consensus engine

Functions

func ConsensusInit

func ConsensusInit(mi model.SelfMinerDO, conf common.ConfManager) bool

ConsensusInit means consensus initialization

Returns: true - the initialization is successful The internal will interact with the chain for initial data loading and pre-processing. False - failed.

func NewConsensusHelper

func NewConsensusHelper(id groupsig.ID) types.ConsensusHelper

func StartMiner

func StartMiner() bool

Start the miner process and participate in the consensus Returns true if successful, false returns false

func StopMiner

func StopMiner()

StopMiner ends the miner process and no longer participate in the consensus

Types

type ConsensusHelperImpl

type ConsensusHelperImpl struct {
	ID groupsig.ID
}

ConsensusHelperImpl implements ConsensusHelper interface. It provides functions for chain use

func (*ConsensusHelperImpl) CalculateQN

func (helper *ConsensusHelperImpl) CalculateQN(bh *types.BlockHeader) uint64

CalculateQN calculates the blockheader's qn It needs to be equal to the blockheader's totalQN - preHeader's totalQN

func (*ConsensusHelperImpl) CheckProveRoot

func (helper *ConsensusHelperImpl) CheckProveRoot(bh *types.BlockHeader) (bool, error)

CheckProveRoot check the prove root hash for weight node when add block on chain

func (*ConsensusHelperImpl) EstimatePreHeight

func (helper *ConsensusHelperImpl) EstimatePreHeight(bh *types.BlockHeader) uint64

EstimatePreHeight estimate pre block's height

func (*ConsensusHelperImpl) GenerateGenesisInfo

func (helper *ConsensusHelperImpl) GenerateGenesisInfo() *types.GenesisInfo

GenerateGenesisInfo generate genesis group and pk info of members

func (*ConsensusHelperImpl) GetBlockMinElapse

func (helper *ConsensusHelperImpl) GetBlockMinElapse(height uint64) int32

GetBlockMinElapse return the min elapsed second for blocks

func (*ConsensusHelperImpl) GroupSkipCountsBetween

func (helper *ConsensusHelperImpl) GroupSkipCountsBetween(preBH *types.BlockHeader, h uint64) map[common.Hash]uint16

func (*ConsensusHelperImpl) VRFProve2Value

func (helper *ConsensusHelperImpl) VRFProve2Value(prove []byte) *big.Int

VRFProve2Value convert the vrf prove to big int

func (*ConsensusHelperImpl) VerifyBlockHeaders

func (helper *ConsensusHelperImpl) VerifyBlockHeaders(pre, bh *types.BlockHeader) (ok bool, err error)

func (*ConsensusHelperImpl) VerifyBlockSign

func (helper *ConsensusHelperImpl) VerifyBlockSign(bh *types.BlockHeader) (bool, error)

VerifyBlockSign verify the blockheader: mainly verify the group signature

func (*ConsensusHelperImpl) VerifyNewBlock

func (helper *ConsensusHelperImpl) VerifyNewBlock(bh *types.BlockHeader, preBH *types.BlockHeader) (bool, error)

VerifyNewBlock check the new block. Mainly verify the cast legality and the group signature

func (*ConsensusHelperImpl) VerifyRewardTransaction

func (helper *ConsensusHelperImpl) VerifyRewardTransaction(tx *types.Transaction) (ok bool, err error)

VerifyRewardTransaction verify reward transaction

Jump to

Keyboard shortcuts

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