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

Snap Sync Fetchers: Highest-Known-Hash Optimization #2941

Merged
merged 11 commits into from
Aug 15, 2023
Prev Previous commit
Next Next commit
Use a object that is different from null object for termination check
scorbajio committed Aug 7, 2023
commit 5df820b3978daffd4dded82c1b0b7afb5d3a3946
4 changes: 2 additions & 2 deletions packages/client/src/sync/fetcher/accountfetcher.ts
Original file line number Diff line number Diff line change
@@ -286,7 +286,7 @@ export class AccountFetcher extends Fetcher<JobTask, AccountData[], AccountData>

if (this.highestKnownHash && compareBytes(limit, this.highestKnownHash) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ahh so this solves the problem that if some range is empty it won't be requested 👍

// skip this job and don't rerequest it if it's limit is lower than the highest known key hash
return Object.assign([], [Object.create({ skipped: true })], { completed: true })
return Object.assign([], [{ skipped: true }], { completed: true })
}

const rangeResult = await peer!.snap!.getAccountRange({
@@ -374,7 +374,7 @@ export class AccountFetcher extends Fetcher<JobTask, AccountData[], AccountData>
async store(result: AccountData[]): Promise<void> {
this.debug(`Stored ${result.length} accounts in account trie`)

if (JSON.stringify(result[0]) === JSON.stringify(Object.create({ skipped: true }))) {
if (JSON.stringify(result[0]) === JSON.stringify({ skipped: true })) {
// return without storing to skip this task
return
}