Skip to content

Commit 5394bf9

Browse files
committed
fix: overriding bug
1 parent af60833 commit 5394bf9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

services/transactionService.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ export async function connectTransactionsListToPrices (
460460
}
461461

462462
// ---- efficient fetch ----
463-
const timestampToPrice: Record<number, AllPrices> = {}
463+
const priceByNetworkTs = new Map<string, AllPrices>()
464464
let pairs = 0
465465

466466
for (const [networkId, timestamps] of networkIdToTimestamps.entries()) {
@@ -502,7 +502,7 @@ export async function connectTransactionsListToPrices (
502502
)
503503
}
504504

505-
timestampToPrice[ts] = allPrices as AllPrices
505+
priceByNetworkTs.set(`${networkId}:${ts}`, allPrices as AllPrices)
506506
}
507507
}
508508

@@ -512,7 +512,10 @@ export async function connectTransactionsListToPrices (
512512
const rows: Prisma.PricesOnTransactionsCreateManyInput[] = []
513513
for (const t of txList) {
514514
const ts = flattenTimestamp(t.timestamp)
515-
const allPrices = timestampToPrice[ts]
515+
const allPrices = priceByNetworkTs.get(`${t.address.networkId}:${ts}`)
516+
if (allPrices == null) {
517+
throw new Error(`[PRICES] Missing price pair for networkId ${t.address.networkId} at ${moment.unix(ts).format(HUMAN_READABLE_DATE_FORMAT)}.`)
518+
}
516519
rows.push(...buildPriceTxConnectionInput(t, allPrices))
517520
}
518521
console.log(`[PRICES] Built ${rows.length} price links (2 per tx).`)

0 commit comments

Comments
 (0)