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: race condition #1427

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Changes from all commits
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
16 changes: 8 additions & 8 deletions yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ export class Synchroniser {

protected async workNoteProcessorCatchUp(limit = 1, retryInterval = 1000): Promise<void> {
const noteProcessor = this.noteProcessorsToCatchUp[0];
if (noteProcessor.status.syncedToBlock === this.synchedToBlock) {
// Note processor already synched, nothing to do
this.noteProcessorsToCatchUp.shift();
this.noteProcessors.push(noteProcessor);
return;
}

const from = noteProcessor.status.syncedToBlock + 1;
// Ensuring that the note processor does not sync further than the main sync.
limit = Math.min(limit, this.synchedToBlock - from + 1);
Expand Down Expand Up @@ -230,14 +237,7 @@ export class Synchroniser {
return;
}

const noteProcessor = new NoteProcessor(publicKey, keyStore, this.db, this.node);
if (this.synchedToBlock === 0) {
// The main sync thread was never started before and for this reason the synchroniser does not have to catch up
this.noteProcessors.push(noteProcessor);
} else {
// The main sync thread was started before and for this reason the synchroniser has to catch up
this.noteProcessorsToCatchUp.push(noteProcessor);
}
this.noteProcessorsToCatchUp.push(new NoteProcessor(publicKey, keyStore, this.db, this.node));
}

/**
Expand Down