Skip to content

Commit

Permalink
Revert "Get only valid blocks. (#4628)" (#4637)
Browse files Browse the repository at this point in the history
This reverts commit f0dc999.
  • Loading branch information
Frozen authored Feb 26, 2024
1 parent f0dc999 commit 2dee6c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
13 changes: 2 additions & 11 deletions consensus/fbft_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,11 @@ func (log *FBFTLog) GetMessagesByTypeSeqViewHash(typ msg_pb.MessageType, blockNu
return found
}

func (log *FBFTLog) all(filters []func(*FBFTMessage, *FBFTLog) bool, value *FBFTMessage) bool {
for _, filter := range filters {
if !filter(value, log) {
return false
}
}
return true
}

// GetMessagesByTypeSeq returns pbft messages with matching type, blockNum
func (log *FBFTLog) GetMessagesByTypeSeq(typ msg_pb.MessageType, blockNum uint64, filters ...func(message *FBFTMessage, log *FBFTLog) bool) []*FBFTMessage {
func (log *FBFTLog) GetMessagesByTypeSeq(typ msg_pb.MessageType, blockNum uint64) []*FBFTMessage {
var found []*FBFTMessage
for _, msg := range log.messages {
if msg.MessageType == typ && msg.BlockNum == blockNum && msg.Verified && log.all(filters, msg) {
if msg.MessageType == typ && msg.BlockNum == blockNum && msg.Verified {
found = append(found, msg)
}
}
Expand Down
4 changes: 1 addition & 3 deletions consensus/view_change_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ func (consensus *Consensus) constructViewChangeMessage(priKey *bls.PrivateKeyWra
}

preparedMsgs := consensus.fBFTLog.GetMessagesByTypeSeq(
msg_pb.MessageType_PREPARED, consensus.getBlockNum(), func(message *FBFTMessage, log *FBFTLog) bool {
return log.IsBlockVerified(message.BlockHash)
},
msg_pb.MessageType_PREPARED, consensus.getBlockNum(),
)
preparedMsg := consensus.fBFTLog.FindMessageByMaxViewID(preparedMsgs)

Expand Down

0 comments on commit 2dee6c6

Please sign in to comment.