Skip to content

Commit

Permalink
refactor: invert if check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Jan 16, 2024
1 parent c0e230d commit fbf6542
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions yarn-project/sequencer-client/src/sequencer/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,24 @@ export class Sequencer {
this.state = SequencerState.PUBLISHING_CONTRACT_DATA;
const newContracts = validTxs.flatMap(tx => tx.newContracts).filter(cd => !cd.isEmpty());

if (newContracts.length > 0) {
const blockHash = block.getCalldataHash();
this.log.info(`Publishing ${newContracts.length} contracts in block hash ${blockHash.toString('hex')}`);

const publishedContractData = await this.publisher.processNewContractData(block.number, blockHash, newContracts);
if (publishedContractData) {
this.log(`Successfully published new contract data for block ${block.number}`);
} else if (!publishedContractData && newContracts.length) {
this.log(`Failed to publish new contract data for block ${block.number}`);
}
if (newContracts.length === 0) {
this.log.debug(`No new contracts to publish in block ${block.number}`);
return;
}

const blockCalldataHash = block.getCalldataHash();
this.log.info(`Publishing ${newContracts.length} contracts in block ${block.number}`);

const publishedContractData = await this.publisher.processNewContractData(
block.number,
blockCalldataHash,
newContracts,
);

if (publishedContractData) {
this.log(`Successfully published new contract data for block ${block.number}`);
} else if (!publishedContractData && newContracts.length) {
this.log(`Failed to publish new contract data for block ${block.number}`);
}
}

Expand Down

0 comments on commit fbf6542

Please sign in to comment.