diff --git a/src/polygon/main.ts b/src/polygon/main.ts index ef184e5..9719d2a 100644 --- a/src/polygon/main.ts +++ b/src/polygon/main.ts @@ -81,6 +81,7 @@ let bytesRead = 0; // amount of bytes received const preloadedCollections = loadCollections().addresses; const preloadedCollectionsHeight = loadCollections().height; const collectionsCreatedByFactory = new Set(); +const collectionIdsNotIncludedInPreloaded = new Set(); processor.run( new TypeormDatabase({ @@ -99,15 +100,6 @@ processor.run( .find(Rarity) .then((q) => new Map(q.map((i) => [i.id, i]))); - const collectionIdsNotIncludedInPreloaded = await ctx.store - .find(Collection, { - where: { - id: Not(In(preloadedCollections)), - network: ModelNetwork.POLYGON, - }, - }) - .then((q) => new Set(q.map((c) => c.id))); - const isThereImportantDataInBatch = ctx.blocks.some((block) => block.logs.some( (log) => @@ -924,6 +916,13 @@ processor.run( console.time("about to upsert"); + // add new collections to the list of ids from the not preloaded + storedData.collections.forEach((collection) => { + if (!preloadedCollections.includes(collection.id)) { + collectionIdsNotIncludedInPreloaded.add(collection.id); + } + }); + await ctx.store.upsert([...rarities.values()]); for (const [key, value] of Object.entries(storedData)) { if (