Skip to content

Commit

Permalink
redo of hyperledger#5039 without the saveTrieLog change
Browse files Browse the repository at this point in the history
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
macfarla committed Feb 9, 2023
1 parent b2d378e commit 94e8742
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,33 @@ public Optional<BonsaiWorldView> getNextWorldView() {
}

public void setNextWorldView(final Optional<BonsaiWorldView> nextWorldView) {
maybeUnSubscribe();
this.nextWorldView = nextWorldView;
}

private void maybeUnSubscribe() {
nextWorldView
.filter(WorldState.class::isInstance)
.map(WorldState.class::cast)
.ifPresent(
ws -> {
try {
ws.close();
} catch (final Exception e) {
// no-op
}
});
}

public TrieLogLayer getTrieLog() {
return trieLog;
}

@Override
public void close() throws Exception {
maybeUnSubscribe();
}

public long getHeight() {
return height;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,11 @@ private TransactionAddedStatus addTransaction(
LOG,
"Transaction {} not added because nonce too far in the future for sender {}",
transaction::toTraceLog,
maybeSenderAccount::toString);
() ->
maybeSenderAccount
.map(Account::getAddress)
.map(Address::toString)
.orElse("unknown"));
return NONCE_TOO_FAR_IN_FUTURE_FOR_SENDER;
}

Expand Down

0 comments on commit 94e8742

Please sign in to comment.