Skip to content

Commit

Permalink
Address comments from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Jul 22, 2024
1 parent e38447b commit 235404e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions yarn-project/p2p/src/client/p2p_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export class P2PClient implements P2P {
) {
const { p2pBlockCheckIntervalMS: checkInterval, p2pL2QueueSize } = getP2PConfigEnvVars();
const l2DownloaderOpts = { maxQueueSize: p2pL2QueueSize, pollIntervalMS: checkInterval };
// TODO(palla/prover-node): This effectively downloads blocks twice from the archiver, which is an issue
// if the archiver is remote. We should refactor this so the downloader keeps a single queue and handles
// latest/proven metadata, as well as block reorgs.
this.latestBlockDownloader = new L2BlockDownloader(l2BlockSource, l2DownloaderOpts);
this.provenBlockDownloader = new L2BlockDownloader(l2BlockSource, { ...l2DownloaderOpts, proven: true });

Expand Down Expand Up @@ -181,12 +184,12 @@ export class P2PClient implements P2P {
// start looking for further blocks
const processLatest = async () => {
while (!this.stopping) {
await this.latestBlockDownloader.getBlocks().then(this.handleLatestL2Blocks.bind(this));
await this.latestBlockDownloader.getBlocks(1).then(this.handleLatestL2Blocks.bind(this));
}
};
const processProven = async () => {
while (!this.stopping) {
await this.provenBlockDownloader.getBlocks().then(this.handleProvenL2Blocks.bind(this));
await this.provenBlockDownloader.getBlocks(1).then(this.handleProvenL2Blocks.bind(this));
}
};

Expand All @@ -210,7 +213,6 @@ export class P2PClient implements P2P {
await this.latestBlockDownloader.stop();
await this.provenBlockDownloader.stop();
this.log.debug('Stopped block downloader');
// TODO: This running promise will never resolve if there are no new blocks to sync.
await this.runningPromise;
this.setCurrentState(P2PClientState.STOPPED);
this.log.info('P2P client stopped.');
Expand Down

0 comments on commit 235404e

Please sign in to comment.