fix block decode issue and add more nil check (#3953)

pull/3958/head
Rongjian Lan 3 years ago committed by GitHub
parent 65614950c7
commit f5dea3995b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      consensus/validator.go

@ -84,7 +84,7 @@ func (consensus *Consensus) validateNewBlock(recvMsg *FBFTMessage) (*types.Block
blockObj = consensus.FBFTLog.GetBlockByHash(recvMsg.BlockHash)
if blockObj == nil {
if err := rlp.DecodeBytes(recvMsg.Block, &blockObj); err != nil {
if err := rlp.DecodeBytes(recvMsg.Block, blockObj); err != nil {
consensus.getLogger().Warn().
Err(err).
Uint64("MsgBlockNum", recvMsg.BlockNum).
@ -157,7 +157,7 @@ func (consensus *Consensus) prepare() {
// sendCommitMessages send out commit messages to leader
func (consensus *Consensus) sendCommitMessages(blockObj *types.Block) {
if consensus.IsBackup() {
if consensus.IsBackup() || blockObj == nil {
return
}
@ -269,6 +269,9 @@ func (consensus *Consensus) onPrepared(recvMsg *FBFTMessage) {
go func() {
// Try process future committed messages and process them in case of receiving committed before prepared
if blockObj == nil {
return
}
curBlockNum := consensus.blockNum
for _, committedMsg := range consensus.FBFTLog.GetNotVerifiedCommittedMessages(blockObj.NumberU64(), blockObj.Header().ViewID().Uint64(), blockObj.Hash()) {
if committedMsg != nil {

Loading…
Cancel
Save