Documentation ¶
Overview ¶
Package mediator provides some functions for use in other modules
Index ¶
- Variables
- func ConsensusInit(mi model.SelfMinerDO, conf common.ConfManager) bool
- func NewConsensusHelper(id groupsig.ID) types.ConsensusHelper
- func StartMiner() bool
- func StopMiner()
- type ConsensusHelperImpl
- func (helper *ConsensusHelperImpl) CalculateQN(bh *types.BlockHeader) uint64
- func (helper *ConsensusHelperImpl) CheckProveRoot(bh *types.BlockHeader) (bool, error)
- func (helper *ConsensusHelperImpl) EstimatePreHeight(bh *types.BlockHeader) uint64
- func (helper *ConsensusHelperImpl) GenerateGenesisInfo() *types.GenesisInfo
- func (helper *ConsensusHelperImpl) GetBlockMinElapse(height uint64) int32
- func (helper *ConsensusHelperImpl) GroupSkipCountsBetween(preBH *types.BlockHeader, h uint64) map[common.Hash]uint16
- func (helper *ConsensusHelperImpl) VRFProve2Value(prove []byte) *big.Int
- func (helper *ConsensusHelperImpl) VerifyBlockHeaders(pre, bh *types.BlockHeader) (ok bool, err error)
- func (helper *ConsensusHelperImpl) VerifyBlockSign(bh *types.BlockHeader) (bool, error)
- func (helper *ConsensusHelperImpl) VerifyNewBlock(bh *types.BlockHeader, preBH *types.BlockHeader) (bool, error)
- func (helper *ConsensusHelperImpl) VerifyRewardTransaction(tx *types.Transaction) (ok bool, err error)
Constants ¶
This section is empty.
Variables ¶
var Proc logical.Processor
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
Types ¶
type ConsensusHelperImpl ¶
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