Make VerifyBlock private.

pull/4509/head
frozen 2 years ago committed by Casey Gardiner
parent d39fb7f5e5
commit 2621d31ca5
  1. 2
      consensus/consensus_v2.go
  2. 9
      consensus/validator.go

@ -662,7 +662,7 @@ func (consensus *Consensus) tryCatchup() error {
}
blk.SetCurrentCommitSig(msg.Payload)
if err := consensus.VerifyBlock(blk); err != nil {
if err := consensus.verifyBlock(blk); err != nil {
consensus.getLogger().Err(err).Msg("[TryCatchup] failed block verifier")
return err
}

@ -42,8 +42,6 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
Uint64("MsgBlockNum", recvMsg.BlockNum).
Msg("[OnAnnounce] Announce message Added")
consensus.FBFTLog.AddVerifiedMessage(recvMsg)
consensus.mutex.Lock()
defer consensus.mutex.Unlock()
consensus.blockHash = recvMsg.BlockHash
// we have already added message and block, skip check viewID
// and send prepare message if is in ViewChanging mode
@ -78,6 +76,11 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
}
}
func (consensus *Consensus) ValidateNewBlock(recvMsg *FBFTMessage) (*types.Block, error) {
consensus.mutex.Lock()
defer consensus.mutex.Unlock()
return consensus.validateNewBlock(recvMsg)
}
func (consensus *Consensus) validateNewBlock(recvMsg *FBFTMessage) (*types.Block, error) {
if consensus.FBFTLog.IsBlockVerified(recvMsg.BlockHash) {
var blockObj *types.Block
@ -132,7 +135,7 @@ func (consensus *Consensus) validateNewBlock(recvMsg *FBFTMessage) (*types.Block
return nil, errors.New("nil block verifier")
}
if err := consensus.VerifyBlock(&blockObj); err != nil {
if err := consensus.verifyBlock(&blockObj); err != nil {
consensus.getLogger().Error().Err(err).Msg("[validateNewBlock] Block verification failed")
return nil, errors.New("Block verification failed")
}

Loading…
Cancel
Save