Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.

Commit 8a61193

Browse files
author
Gal Rogozinski
authored
Fix: Don't resave the transaction itself (#1671)
1 parent 3008f18 commit 8a61193

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/java/com/iota/iri/Iota.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ private void rescanDb() throws Exception {
223223
log.info("Rescanned {} Transactions", counter);
224224
}
225225
List<Pair<Indexable, Persistable>> saveBatch = tx.getSaveBatch();
226-
saveBatch.remove(5);
226+
//don't re-save the tx itself
227+
saveBatch.remove(saveBatch.size() - 1);
227228
tangle.saveBatch(saveBatch);
228229
tx = tx.next(tangle);
229230
}

src/main/java/com/iota/iri/controllers/TransactionViewModel.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,15 @@ public List<Pair<Indexable, Persistable>> getMetadataSaveBatch() {
350350
* The method then ensures that the {@link Transaction#bytes} are present before adding the {@link Transaction} and
351351
* {@link Hash} identifier to the already compiled list of {@link Transaction} components.
352352
*
353-
* @return A complete list of all {@link Transaction} component objects paired with their {@link Hash} identifiers
353+
* @return A complete list of all {@link Transaction} component objects paired with their {@link Hash} identifiers.
354+
* The transaction object itself must be the last item in the list.
354355
* @throws Exception Thrown if the metadata fails to fetch, or if the bytes are not retrieved correctly
355356
*/
356357
public List<Pair<Indexable, Persistable>> getSaveBatch() throws Exception {
357358
List<Pair<Indexable, Persistable>> hashesList = new ArrayList<>();
358359
hashesList.addAll(getMetadataSaveBatch());
359360
getBytes();
361+
//must be last
360362
hashesList.add(new Pair<>(hash, transaction));
361363
return hashesList;
362364
}

0 commit comments

Comments
 (0)