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

Fix Layered World State issue #5076

Merged
merged 14 commits into from
Feb 13, 2023
Merged
Prev Previous commit
Next Next commit
not close layered worldstate during getAccount
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
  • Loading branch information
matkt committed Feb 13, 2023
commit ac4f6f78072524929d449673c6873801a5823cc1
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,19 @@ public <U> Optional<U> getAndMapWorldState(
.getBlockHeader(blockHash)
.flatMap(
blockHeader -> {
try (var ws =
try (final var worldState =
worldStateArchive
.getMutable(blockHeader.getStateRoot(), blockHeader.getHash(), false)
.map(
ws -> {
if (!ws.isPersistable()) {
return ws.copy();
}
return ws;
})
.orElse(null)) {
if (ws != null) {
return Optional.ofNullable(mapper.apply(ws));
if (worldState != null) {
return Optional.ofNullable(mapper.apply(worldState));
}
} catch (Exception ex) {
LOG.error("failed worldstate query for " + blockHash.toShortHexString(), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ private void maybeSubscribe() {
.filter(BonsaiPersistedWorldState.class::isInstance)
.map(BonsaiPersistedWorldState.class::cast)
.ifPresent(
worldState ->
newtWorldViewSubscribeId =
Optional.of(worldState.worldStateStorage.subscribe(this)));
worldState -> {
newtWorldViewSubscribeId = Optional.of(worldState.worldStateStorage.subscribe(this));
});
}

private void maybeUnSubscribe() {
Expand Down