Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset cache after heal #5266

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ public TrieLogManager getTrieLogManager() {
@Override
public void setArchiveStateUnSafe(final BlockHeader blockHeader) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method name should change to reflect its use. IMO it isn't setting the archive unsafe for use like the name implies, but rather is resetting the archive cache and adding the new pivot as the only entry. Perhaps resetArchiveStateTo(BlockHeader)

Similarly, BonsaiWorldState.setArchiveUnsafe should be something more along the lines of resetWorldStateTo(BlockHeader)

These methods could use javadoc describing the intent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the code

persistedState.setArchiveStateUnSafe(blockHeader);
this.trieLogManager.reset();
this.trieLogManager.addCachedLayer(
blockHeader, persistedState.worldStateRootHash, persistedState);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public Optional<BonsaiWorldState> getHeadWorldState(
});
}

@Override
public void reset() {
this.cachedWorldStatesByHash.clear();
}

@Override
public void onClearStorage() {
this.cachedWorldStatesByHash.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ Optional<BonsaiWorldState> getHeadWorldState(

long getMaxLayersToLoad();

void reset();

Optional<TrieLogLayer> getTrieLogLayer(final Hash blockHash);
}