Skip to content

Commit

Permalink
Merge history sync compatibility (#230)
Browse files Browse the repository at this point in the history
* backwards compatibility
  • Loading branch information
amirylm authored Aug 5, 2021
1 parent 88588ab commit 93f2b85
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ibft/sync/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,22 @@ func (s *HistorySync) getHighestDecidedFromPeers(peers []string) []*network.Sync
zap.String("identifier", hex.EncodeToString(s.identifier)))
return
}
// backwards compatibility for version < v0.0.12, where EntryNotFoundError didn't exist
// TODO: can be removed once the release is deprecated
if len(res.SignedMessages) == 0 {
res.Error = kv.EntryNotFoundError
}

if len(res.Error) > 0 {
if res.Error != kv.EntryNotFoundError {
s.logger.Error("received error when fetching highest decided", zap.Error(err),
zap.String("identifier", hex.EncodeToString(s.identifier)))
} else { // peer has no decided msg
// assuming not found is a valid scenario (e.g. new validator)
// therefore we count the result now, and it will be identified afterwards in findHighestInstance()
if res.Error == kv.EntryNotFoundError {
lock.Lock()
results = append(results, res)
lock.Unlock()
} else {
s.logger.Error("received error when fetching highest decided", zap.Error(err),
zap.String("identifier", hex.EncodeToString(s.identifier)))
}
return
}
Expand Down

0 comments on commit 93f2b85

Please sign in to comment.