Skip to content

Commit

Permalink
Reduce hash calculations in Bonsai Tries (hyperledger#1960)
Browse files Browse the repository at this point in the history
Setting contract code on a bonsai account results in a re-hashing. To
reduce this only set the code if the code was changed.  In some cases
this was responsible for 40% of load.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
  • Loading branch information
shemnon authored Mar 1, 2021
1 parent 8315ba6 commit 2e87576
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ public void commit() {
} else {
updatedAccount.setBalance(tracked.getBalance());
updatedAccount.setNonce(tracked.getNonce());
updatedAccount.setCode(tracked.getCode());
if (tracked.codeWasUpdated()) {
updatedAccount.setCode(tracked.getCode());
}
if (tracked.getStorageWasCleared()) {
updatedAccount.clearStorage();
}
Expand Down

0 comments on commit 2e87576

Please sign in to comment.