Skip to content

Commit

Permalink
Skip production for empty mempools (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanic committed Nov 29, 2023
1 parent 873726d commit 86c0935
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export class UnprovenProducerModule
try {
const block = await this.produceUnprovenBlock();

if (block === undefined) {
log.info("No transactions in mempool, skipping production");
return undefined;
}

log.info(`Produced unproven block (${block.transactions.length} txs)`);
this.events.emit("unprovenBlockProduced", [block]);

Expand Down Expand Up @@ -110,11 +115,16 @@ export class UnprovenProducerModule
};
}

private async produceUnprovenBlock(): Promise<UnprovenBlock> {
private async produceUnprovenBlock(): Promise<UnprovenBlock | undefined> {
this.productionInProgress = true;

const { txs, metadata } = await this.collectProductionData();

// Skip production if no transactions are available for now
if (txs.length === 0) {
return undefined;
}

const stateService = new CachedStateService(this.unprovenStateService);

const block = await this.executionService.createUnprovenBlock(
Expand Down

0 comments on commit 86c0935

Please sign in to comment.