Skip to content

Commit

Permalink
Fixed block server if there are no blocks (#2413)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilWindle authored Feb 22, 2023
1 parent d660a73 commit 02630df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions yarn-project/block-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ export class Server {

const latestRollupId = await ensureGetRollupId();
this.blockCache.init(latestRollupId + 1);
const latestBlock = await this.getRollupProviderBlocks(this.blockCache.getLatestRollupId());
this.blockCache.addBlocks(latestBlock, latestRollupId);
this.log(`Received ${latestBlock.length} blocks. Total blocks: ${this.blockCache.getLatestRollupId() + 1}`);
if (latestRollupId !== -1) {
// can only populate cache if there is a rollup
const latestBlock = await this.getRollupProviderBlocks(this.blockCache.getLatestRollupId());
this.blockCache.addBlocks(latestBlock, latestRollupId);
this.log(`Received ${latestBlock.length} blocks. Total blocks: ${this.blockCache.getLatestRollupId() + 1}`);
}
}

// Asynchronously kick off a polling loop for the latest blocks.
Expand Down

0 comments on commit 02630df

Please sign in to comment.