Skip to content

Commit

Permalink
Merge branch 'main' into jsonrpc_ipc
Browse files Browse the repository at this point in the history
  • Loading branch information
antonydenyer authored Apr 25, 2022
2 parents 376a3c0 + 714c538 commit 2e8f3c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public CompletableFuture<FastSyncState> start() {
protected CompletableFuture<FastSyncState> start(final FastSyncState fastSyncState) {
LOG.info("Starting fast sync.");
if (worldStateStorage instanceof BonsaiWorldStateKeyValueStorage) {
worldStateStorage.clear();
LOG.info("Clearing bonsai flat account db");
worldStateStorage.clearFlatDatabase();
}
return findPivotBlock(fastSyncState, fss -> downloadChainAndWorldState(fastSyncActions, fss));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ protected void doPersist(final Updater updater) {

@Override
public Optional<Bytes> getExistingData(final WorldStateStorage worldStateStorage) {
return worldStateStorage.getAccountTrieNodeData(getLocation().orElse(Bytes.EMPTY), getHash());
return getLocation()
.flatMap(
location ->
worldStateStorage
.getAccountStateTrieNode(location, getHash())
.filter(data -> Hash.hash(data).equals(getHash())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static Optional<FastSyncDownloader<?>> create(
return Optional.empty();
}
if (worldStateStorage instanceof BonsaiWorldStateKeyValueStorage) {
worldStateStorage.clear();
worldStateStorage.clearFlatDatabase();
} else {
final Path queueDataDir = fastSyncDataDirectory.resolve("statequeue");
if (queueDataDir.toFile().exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ protected void doPersist(final Updater updater) {

@Override
public Optional<Bytes> getExistingData(final WorldStateStorage worldStateStorage) {
return worldStateStorage.getAccountStorageTrieNode(
getAccountHash().orElse(Hash.EMPTY), getLocation().orElse(Hash.EMPTY), getHash());
return getAccountHash()
.flatMap(
accountHash ->
getLocation()
.flatMap(
location ->
worldStateStorage
.getAccountStorageTrieNode(accountHash, location, getHash())
.filter(data -> Hash.hash(data).equals(getHash()))));
}

@Override
Expand Down

0 comments on commit 2e8f3c3

Please sign in to comment.