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

Commit

Permalink
Updated bundle and address value counting to add exact
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul D Handy committed Sep 23, 2017
1 parent 9fb9198 commit 67cf05a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/iota/iri/BundleValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Hash hash

instanceTransactionViewModels.add(transactionViewModel);

if (transactionViewModel.getCurrentIndex() != i || transactionViewModel.lastIndex() != lastIndex
|| ((bundleValue += transactionViewModel.value()) < -TransactionViewModel.SUPPLY || bundleValue > TransactionViewModel.SUPPLY)) {

if (
transactionViewModel.getCurrentIndex() != i
|| transactionViewModel.lastIndex() != lastIndex
|| ((bundleValue = Math.addExact(bundleValue, transactionViewModel.value())) < -TransactionViewModel.SUPPLY
|| bundleValue > TransactionViewModel.SUPPLY)
) {
instanceTransactionViewModels.get(0).setValidity(tangle, -1);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/iota/iri/LedgerValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private Map<Hash,Long> getLatestDiff(Hash tip, int latestSnapshotIndex, boolean
final Hash address = bundleTransactionViewModel.getAddressHash();
final Long value = state.get(address);
state.put(address, value == null ? bundleTransactionViewModel.value()
: (value + bundleTransactionViewModel.value()));
: Math.addExact(value, bundleTransactionViewModel.value()));
}
}

Expand Down

0 comments on commit 67cf05a

Please sign in to comment.