Skip to content

Commit

Permalink
[INDY-2324] Get back requests from PrePrepare
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
  • Loading branch information
Andrew Nikitin committed Jan 18, 2020
1 parent d627e33 commit 900dd54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions plenum/common/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def discardTxns(self, count: int):
raise LogicError("expected to revert {} txns while there are only {}".
format(count, len(self.uncommittedTxns)))
old_hash = self.uncommittedRootHash
discarded_txns = self.uncommittedTxns[-count:]
self.uncommittedTxns = self.uncommittedTxns[:-count]
if not self.uncommittedTxns:
self.uncommittedTree = None
Expand All @@ -126,7 +125,6 @@ def discardTxns(self, count: int):
logger.info('Discarding {} txns and root hash {} and new root hash is {}. {} are still uncommitted'.
format(count, Ledger.hashToStr(old_hash), Ledger.hashToStr(self.uncommittedRootHash),
len(self.uncommittedTxns)))
return discarded_txns

def treeWithAppliedTxns(self, txns: List, currentTree=None):
"""
Expand Down
9 changes: 5 additions & 4 deletions plenum/server/consensus/ordering_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,10 +1228,7 @@ def _revert(self, ledgerId, stateRootHash, reqCount):
.format(self, reqCount, Ledger.hashToStr(state.headHash),
Ledger.hashToStr(stateRootHash), ledgerId))
state.revertToHead(stateRootHash)
reverted_txns = ledger.discardTxns(reqCount)
if reverted_txns:
for txn in reverted_txns:
self.requestQueues[ledgerId].add(get_digest(txn))
ledger.discardTxns(reqCount)
self.post_batch_rejection(ledgerId)

def _track_batches(self, pp: PrePrepare, prevStateRootHash):
Expand Down Expand Up @@ -2186,6 +2183,10 @@ def revert_unordered_batches(self):
discarded = invalid_index_serializer.deserialize(discarded)
logger.debug('{} reverting 3PC key {}'.format(self, key))
self._revert(ledger_id, prevStateRoot, len_reqIdr - len(discarded))
pre_prepare = self.get_preprepare(*key)
if pre_prepare:
for req_id in pre_prepare.reqIdr:
self.requestQueues[ledger_id].add(req_id)
self._lastPrePrepareSeqNo -= 1
i += 1
else:
Expand Down

0 comments on commit 900dd54

Please sign in to comment.