Skip to content

Commit 40967a7

Browse files
committed
logs wip
1 parent cca8809 commit 40967a7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

services/chronikService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,32 +844,38 @@ export class ChronikBlockchainClient {
844844

845845
for await (const batch of this.fetchLatestTxsForAddresses(addresses)) {
846846
if (batch.addressesSynced.length > 0) {
847-
// marcador de slice => desmarca syncing
847+
console.log(`${pfx} marking batch as syncing...`)
848848
await setSyncingBatch(batch.addressesSynced, false)
849+
console.log(`${pfx} marked batch as syncing.`)
849850
continue
850851
}
851852

852853
const involvedAddrIds = new Set(batch.chronikTxs.map(({ address }) => address.id))
853854

854855
try {
856+
console.log(`${pfx} getting txs from chronik...`)
855857
const pairsFromBatch: RowWithRaw[] = await Promise.all(
856858
batch.chronikTxs.map(async ({ tx, address }) => {
857859
const row = await this.getTransactionFromChronikTransaction(tx, address)
858860
return { row, raw: tx }
859861
})
860862
)
863+
console.log(`${pfx} got txs from chronik.`)
861864

862865
for (const { row } of pairsFromBatch) {
863866
perAddrCount.set(row.addressId, (perAddrCount.get(row.addressId) ?? 0) + 1)
864867
}
865868

869+
console.log(`${pfx} added ${pairsFromBatch.length} to commit buffer ${toCommit.length}`)
866870
toCommit.push(...pairsFromBatch)
867871

868872
if (toCommit.length >= DB_COMMIT_BATCH_SIZE) {
873+
console.log(`${pfx} ${toCommit.length} reached commit batch size of ${DB_COMMIT_BATCH_SIZE}, committing to DB...`)
869874
const commitPairs = toCommit.slice(0, DB_COMMIT_BATCH_SIZE)
870875
toCommit = toCommit.slice(DB_COMMIT_BATCH_SIZE)
871876

872877
const rows = commitPairs.map(p => p.row)
878+
console.log(`${pfx} creating txs from ${rows.length} rows...`)
873879
const createdTxs = await createManyTransactions(rows)
874880
console.log(`${this.CHRONIK_MSG_PREFIX} committed — created=${createdTxs.length}`)
875881

0 commit comments

Comments
 (0)