Skip to content

Commit

Permalink
in snap client, move child enqueue requests to after persist step to …
Browse files Browse the repository at this point in the history
…avoid throwing MerkleTrieException for failed lookups

Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed Dec 19, 2023
1 parent d21a553 commit 087ef29
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ public List<Task<SnapDataRequest>> persist(final List<Task<SnapDataRequest>> tas
final WorldStateStorage.Updater updater = worldStateStorage.updater();
for (Task<SnapDataRequest> task : tasks) {
if (task.getData().isResponseReceived()) {
// enqueue child requests
final Stream<SnapDataRequest> childRequests =
task.getData().getChildRequests(downloadState, worldStateStorage, snapSyncState);
if (!(task.getData() instanceof TrieNodeHealingRequest)) {
enqueueChildren(childRequests);
} else {
if (!task.getData().isExpired(snapSyncState)) {
enqueueChildren(childRequests);
} else {
continue;
}
}

// persist nodes
final int persistedNodes =
task.getData()
Expand All @@ -85,6 +72,19 @@ public List<Task<SnapDataRequest>> persist(final List<Task<SnapDataRequest>> tas
downloadState.getMetricsManager().notifyNodesGenerated(persistedNodes);
}
}

// enqueue child requests
final Stream<SnapDataRequest> childRequests =
task.getData().getChildRequests(downloadState, worldStateStorage, snapSyncState);
if (!(task.getData() instanceof TrieNodeHealingRequest)) {
enqueueChildren(childRequests);
} else {
if (!task.getData().isExpired(snapSyncState)) {
enqueueChildren(childRequests);
} else {
continue;
}
}
}
}
updater.commit();
Expand Down

0 comments on commit 087ef29

Please sign in to comment.