return back all_prev_ordered
@@ -1640,7 +1640,28 @@ class OrderingService:
# TODO: This method does a lot of work, choose correct data
# structures to make it efficient.
- return self.last_ordered_3pc[1] == commit.ppSeqNo - 1
+ viewNo, ppSeqNo = commit.viewNo, commit.ppSeqNo
+
+ if self.last_ordered_3pc[1] == ppSeqNo - 1:
+ # Last ordered was in same view as this COMMIT
+ return True
+
+ # if some PREPAREs/COMMITs were completely missed in the same view
+ toCheck = set()
+ toCheck.update(set(self.sent_preprepares.keys()))
+ toCheck.update(set(self.prePrepares.keys()))
+ toCheck.update(set(self.prepares.keys()))
+ toCheck.update(set(self.commits.keys()))
+ for (v, p) in toCheck:
+ if v < viewNo and (v, p) not in self.ordered:
+ # Have commits from previous view that are unordered.
+ return False
+ if v == viewNo and p < ppSeqNo and (v, p) not in self.ordered:
+ # If unordered commits are found with lower ppSeqNo then this
+ # cannot be ordered.
+ return False
+
+ return True
def _can_commit(self, prepare: Prepare) -> (bool, str):
"""
