update save block failed handler
@@ -293,13 +293,19 @@ public class BlockServiceImpl implements BlockService {
List<Transaction> savedList = new ArrayList<>();
for (Transaction transaction : block.getTxs()) {
transaction.setBlockHeight(height);
+ boolean needRollback = false;
Result result = transactionService.commitTx(transaction, block.getHeader());
if (result.isSuccess()) {
result = ledgerService.saveTx(transaction);
+ } else {
+ needRollback = true;
}
if (result.isSuccess()) {
savedList.add(transaction);
} else {
+ if (needRollback) {
+ this.transactionService.rollbackCommit(transaction, block.getHeader());
+ }
this.rollbackTxList(savedList, block.getHeader(), false);
return result;
}
