Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 6aa2f1c

Browse files
Merge pull request #53 from decentraland/feat/optimize-batchs-with-no-data
feat: add logic to check if the batch of blocks has relevant info
2 parents a0c261e + 676b991 commit 6aa2f1c

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/polygon/main.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,41 @@ processor.run(
8181
stateSchema: `polygon_processor_${schemaName}`,
8282
}),
8383
async (ctx) => {
84-
console.time("blocks iteration");
8584
// update the amount of bytes read
8685
bytesRead += ctx.blocks.reduce(
8786
(acc, block) => acc + Buffer.byteLength(JSON.stringify(block), "utf8"),
8887
0
8988
);
9089

90+
const isThereImportantDataInBatch = ctx.blocks.some((block) =>
91+
block.logs.some(
92+
(log) =>
93+
log.address === addresses.CollectionFactory ||
94+
log.address === addresses.CollectionFactoryV3 ||
95+
log.address === addresses.BidV2 ||
96+
log.address === addresses.ERC721Bid ||
97+
log.address === addresses.Marketplace ||
98+
log.address === addresses.MarketplaceV2 ||
99+
log.address === addresses.OldCommittee ||
100+
log.address === addresses.Committee ||
101+
log.address === addresses.CollectionStore ||
102+
log.address === addresses.RaritiesWithOracle ||
103+
log.address === addresses.Rarity ||
104+
log.address === addresses.CollectionManager ||
105+
preloadedCollections.includes(log.address) ||
106+
collectionsCreatedByFactory.has(log.address)
107+
)
108+
);
109+
110+
console.log(
111+
"INFO: Batch contains important data: ",
112+
isThereImportantDataInBatch
113+
);
114+
if (!isThereImportantDataInBatch) {
115+
return;
116+
}
117+
118+
console.time("blocks iteration");
91119
const rarities = await ctx.store
92120
.find(Rarity)
93121
.then((q) => new Map(q.map((i) => [i.id, i])));

0 commit comments

Comments
 (0)