@odatano/core 2.0.0-rc.19 → 2.0.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@cds-models/CardanoAgentService/index.d.ts +1 -5
- package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
- package/@cds-models/CardanoIndexerService/index.js +7 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -10
- package/src/index.js +6 -16
- package/src/plugin.js +11 -27
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +39 -150
- package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
- package/srv/blockchain/backends/cardano-backend.js +1 -5
- package/srv/blockchain/backends/koios-backend.d.ts +26 -71
- package/srv/blockchain/backends/koios-backend.js +50 -132
- package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
- package/srv/blockchain/backends/ogmios-backend.js +71 -179
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
- package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
- package/srv/blockchain/cardano-client.d.ts +43 -216
- package/srv/blockchain/cardano-client.js +49 -234
- package/srv/blockchain/cardano-indexer.d.ts +79 -357
- package/srv/blockchain/cardano-indexer.js +98 -406
- package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
- package/srv/blockchain/cardano-tx-builder.js +21 -107
- package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
- package/srv/blockchain/crawler/certificate-backfill.js +150 -0
- package/srv/blockchain/crawler/crawler.d.ts +41 -145
- package/srv/blockchain/crawler/crawler.js +57 -172
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +2 -6
- package/srv/blockchain/crawler/index.js +4 -9
- package/srv/blockchain/crawler/sync-state.d.ts +17 -39
- package/srv/blockchain/crawler/sync-state.js +23 -55
- package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
- package/srv/blockchain/crawler/utxo-set-import.js +8 -28
- package/srv/blockchain/ledger-state.d.ts +3 -12
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -48
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +65 -174
- package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +9 -22
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
- package/srv/cardano-agent-service.cds +1 -5
- package/srv/cardano-agent-service.js +3 -7
- package/srv/cardano-indexer-service.cds +32 -4
- package/srv/cardano-indexer-service.js +83 -15
- package/srv/cardano-service.js +36 -98
- package/srv/cardano-sign-service.cds +1 -1
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +1 -1
- package/srv/cardano-tx-service.js +54 -174
- package/srv/cardano-worker-service.js +7 -15
- package/srv/server.d.ts +27 -86
- package/srv/server.js +52 -148
- package/srv/utils/agent-grants-config.d.ts +11 -50
- package/srv/utils/agent-grants-config.js +12 -45
- package/srv/utils/agent-grants.d.ts +34 -123
- package/srv/utils/agent-grants.js +57 -156
- package/srv/utils/agent-token-auth.d.ts +2 -5
- package/srv/utils/agent-token-auth.js +2 -5
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +19 -68
- package/srv/utils/const.js +20 -69
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +2 -7
- package/srv/utils/db-indexes.js +7 -34
- package/srv/utils/db-sanitize.d.ts +5 -18
- package/srv/utils/db-sanitize.js +6 -19
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +29 -191
- package/srv/utils/errors.js +44 -229
- package/srv/utils/liveness.d.ts +2 -9
- package/srv/utils/liveness.js +3 -11
- package/srv/utils/mappers.d.ts +50 -298
- package/srv/utils/mappers.js +80 -386
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-order-nulls.js +4 -23
- package/srv/utils/plutus-placeholders.d.ts +6 -18
- package/srv/utils/plutus-placeholders.js +6 -20
- package/srv/utils/rate-limiter.d.ts +6 -17
- package/srv/utils/rate-limiter.js +5 -15
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +18 -92
- package/srv/utils/tx-build-helper.js +32 -123
- package/srv/utils/tx-request-parsers.d.ts +7 -26
- package/srv/utils/tx-request-parsers.js +7 -26
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +67 -206
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +19 -89
- package/srv/utils/validators.js +31 -138
|
@@ -18,17 +18,8 @@ const sync_state_1 = require("./crawler/sync-state");
|
|
|
18
18
|
const { UPSERT, INSERT, UPDATE, SELECT, DELETE } = cds_1.default.ql;
|
|
19
19
|
const logger = cds_1.default.log('CardanoIndexer');
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* Provides methods to index & manage db consistency for various Cardano blockchain data (transactions, addresses, blocks, epochs, accounts, pools, dreps)
|
|
24
|
-
* 1. Fetches data from the configured Cardano data provider via the CardanoClient
|
|
25
|
-
* 2. Maps the provider data into corresponding OData entity rows
|
|
26
|
-
* 3. Upserts the data rows into the database via CAP transactions
|
|
27
|
-
* 4. Ensures referential integrity and consistency across related entities (e.g., addresses in transactions, UTxOs in addresses)
|
|
28
|
-
* 5. Returns the indexed entity data for further processing
|
|
29
|
-
*
|
|
30
|
-
* Each method corresponds to a specific Cardano Entity type and handles the necessary mapping and persistence
|
|
31
|
-
* into the corresponding OData entities defined in the CardanoODataService(M1) and CardanoTransactionService(M2) models.
|
|
21
|
+
* Indexes Cardano data into the OData entities: fetches via CardanoClient, maps provider data
|
|
22
|
+
* to entity rows and UPSERTs them inside the caller's CAP transaction.
|
|
32
23
|
*/
|
|
33
24
|
class CardanoIndexer {
|
|
34
25
|
client;
|
|
@@ -37,23 +28,14 @@ class CardanoIndexer {
|
|
|
37
28
|
static CRAWL_EPOCH_REFRESH_MS = 5 * 60 * 1000;
|
|
38
29
|
static CRAWL_EPOCH_RETRY_MS = 30 * 1000;
|
|
39
30
|
/**
|
|
40
|
-
* Crawler epoch memo
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* At most the current and immediately previous epoch are retained. The rows are
|
|
45
|
-
* intentionally UPSERTed in every block transaction: the caller owns that
|
|
46
|
-
* transaction, so an in-memory "persisted" bit cannot know whether its commit later
|
|
47
|
-
* succeeded. Repeating one local UPSERT is cheap and remains correct after rollback.
|
|
31
|
+
* Crawler epoch memo: refreshed periodically while an epoch is live and once more when the
|
|
32
|
+
* next one starts; holds at most the current and previous epoch. Rows are UPSERTed in every
|
|
33
|
+
* block transaction because the caller owns the commit.
|
|
48
34
|
*/
|
|
49
35
|
crawlEpochCache = new Map();
|
|
50
36
|
crawlEpochCurrent = null;
|
|
51
37
|
crawlEpochPrevious = null;
|
|
52
|
-
/**
|
|
53
|
-
* Analytics coverage of the crawl path (v2.0). The
|
|
54
|
-
* defaults mirror the crawler config defaults, so an indexer the crawler never configured
|
|
55
|
-
* (unit tests, the lazy-only path) behaves exactly like a configured one.
|
|
56
|
-
*/
|
|
38
|
+
/** Analytics coverage of the crawl path; defaults mirror the crawler config defaults. */
|
|
57
39
|
crawlAssetHistory = true;
|
|
58
40
|
crawlAssetCatalogue = 'bare';
|
|
59
41
|
/** Certificates + withdrawals per block (ledger-state coverage). Opt-in. */
|
|
@@ -61,37 +43,30 @@ class CardanoIndexer {
|
|
|
61
43
|
/** Logged once per process: the active source reports no certificates (Blockfrost). */
|
|
62
44
|
certificatesUnreportedWarned = false;
|
|
63
45
|
/**
|
|
64
|
-
* Crawler-fed ledger state (`crawler.utxoSet`)
|
|
65
|
-
*
|
|
66
|
-
* past it) means the mode is configured but inactive.
|
|
46
|
+
* Crawler-fed ledger state (`crawler.utxoSet`): blocks after `utxoAnchor` are applied to the
|
|
47
|
+
* Ledger* tables; no anchor means configured but inactive.
|
|
67
48
|
*/
|
|
68
49
|
crawlUtxoSet = false;
|
|
69
50
|
utxoAnchor = null;
|
|
70
51
|
/** The anchor block was found in the crawled chain (checked once, before the first apply). */
|
|
71
52
|
utxoAnchorVerified = false;
|
|
72
53
|
/**
|
|
73
|
-
* Invalidation decided inside a block transaction
|
|
74
|
-
*
|
|
75
|
-
* loses the anchor nor leaves the DB saying `active` while this process stopped applying.
|
|
54
|
+
* Invalidation decided inside a block transaction; the anchor stays until the crawler confirms
|
|
55
|
+
* the commit (`takeLedgerInvalidation`), so a rolled-back attempt changes nothing.
|
|
76
56
|
*/
|
|
77
57
|
ledgerInvalidation = null;
|
|
78
58
|
/** Units known to have an `Assets` row, so a repeat sighting costs no DB round-trip. */
|
|
79
59
|
static ASSET_MEMO_CAP = 200_000;
|
|
80
60
|
assetMemo = new Set();
|
|
81
61
|
/**
|
|
82
|
-
* Background registry enrichment (`assetCatalogue: 'enrich'`)
|
|
83
|
-
*
|
|
84
|
-
* but never the crawl. Above the cap the oldest entries are dropped: the unit keeps its bare
|
|
85
|
-
* row and is still enriched by the lazy path on its first API read.
|
|
62
|
+
* Background registry enrichment queue (`assetCatalogue: 'enrich'`), drained at a fixed rate
|
|
63
|
+
* outside the block transaction. Above the cap the oldest units are dropped (bare row stays).
|
|
86
64
|
*/
|
|
87
65
|
static ENRICH_QUEUE_CAP = 50_000;
|
|
88
66
|
enrichQueue = [];
|
|
89
67
|
enrichTimer = null;
|
|
90
68
|
enrichRate = 2;
|
|
91
|
-
/**
|
|
92
|
-
* Adopt the crawler's coverage settings. Called once from the crawler's start path; the
|
|
93
|
-
* lazy request path never touches these.
|
|
94
|
-
*/
|
|
69
|
+
/** Adopt the crawler's coverage settings; the lazy request path never touches these. */
|
|
95
70
|
configureCrawlCoverage(coverage) {
|
|
96
71
|
this.crawlAssetHistory = coverage.assetHistory;
|
|
97
72
|
this.crawlAssetCatalogue = coverage.assetCatalogue;
|
|
@@ -108,17 +83,9 @@ class CardanoIndexer {
|
|
|
108
83
|
this.ledgerInvalidation = null;
|
|
109
84
|
}
|
|
110
85
|
/**
|
|
111
|
-
* The imported set describes the chain AT the anchor block
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* never in its cursor) would otherwise seed the set with the wrong balances.
|
|
115
|
-
*
|
|
116
|
-
* The check is against the cursor, not the Blocks table: when the first block past the
|
|
117
|
-
* anchor arrives, the cursor (not yet advanced in this transaction) IS the block the
|
|
118
|
-
* crawler followed last, so it must equal the anchor exactly. That also covers the
|
|
119
|
-
* bootstrap case — the configured start block sits in the cursor without a Blocks row of
|
|
120
|
-
* its own. Once a block has been applied (`utxoAppliedSlot` set, same transaction), the
|
|
121
|
-
* anchor was verified and a restart skips the check.
|
|
86
|
+
* The imported set describes the chain AT the anchor block, so before the first block past it
|
|
87
|
+
* is applied the cursor (not yet advanced in this transaction) must equal the anchor exactly;
|
|
88
|
+
* otherwise the snapshot was taken on a fork. Skipped once `utxoAppliedSlot` is set.
|
|
122
89
|
*/
|
|
123
90
|
async verifyUtxoAnchor(tx, anchor) {
|
|
124
91
|
const cursor = await (0, sync_state_1.readCursor)(tx);
|
|
@@ -138,10 +105,7 @@ class CardanoIndexer {
|
|
|
138
105
|
getUtxoAnchor() {
|
|
139
106
|
return this.crawlUtxoSet && !this.ledgerInvalidation ? this.utxoAnchor : null;
|
|
140
107
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Called by the crawler right after a block transaction committed: hands out a pending
|
|
143
|
-
* invalidation (and drops the anchor) exactly once, or null.
|
|
144
|
-
*/
|
|
108
|
+
/** Hand out a pending invalidation (dropping the anchor) exactly once after the block commit, or null. */
|
|
145
109
|
takeLedgerInvalidation() {
|
|
146
110
|
const reason = this.ledgerInvalidation;
|
|
147
111
|
if (reason) {
|
|
@@ -153,9 +117,7 @@ class CardanoIndexer {
|
|
|
153
117
|
}
|
|
154
118
|
/**
|
|
155
119
|
* Drain the enrichment queue at `enrichRate` units per second, one `indexAsset()` per tick in
|
|
156
|
-
* its own transaction.
|
|
157
|
-
* unit (404 from every backend, provider outage) is dropped rather than retried — its bare row
|
|
158
|
-
* stays and the lazy path can still enrich it later.
|
|
120
|
+
* its own transaction. A failing unit is dropped; its bare row stays for the lazy path.
|
|
159
121
|
*/
|
|
160
122
|
startAssetEnrichment() {
|
|
161
123
|
if (this.enrichTimer || this.crawlAssetCatalogue !== 'enrich')
|
|
@@ -182,9 +144,8 @@ class CardanoIndexer {
|
|
|
182
144
|
this.enrichQueue = [];
|
|
183
145
|
}
|
|
184
146
|
/**
|
|
185
|
-
* Network-only epoch prefetch for the crawler. Call BEFORE opening the per-block
|
|
186
|
-
*
|
|
187
|
-
* lock is held (indexBlockFull then serves the epoch from this memo). Never throws.
|
|
147
|
+
* Network-only epoch prefetch for the crawler. Call BEFORE opening the per-block write
|
|
148
|
+
* transaction so no backend round-trip runs under the DB write lock. Never throws.
|
|
188
149
|
*/
|
|
189
150
|
async prefetchCrawlEpoch(epochNumber) {
|
|
190
151
|
const previousEpoch = this.crawlEpochCurrent;
|
|
@@ -236,26 +197,16 @@ class CardanoIndexer {
|
|
|
236
197
|
});
|
|
237
198
|
}
|
|
238
199
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Create a new CardanoIndexer instance
|
|
241
|
-
* @param client - The CardanoClient instance for blockchain queries
|
|
242
|
-
* @param txBuilder - The CardanoTransactionBuilder instance for transaction building
|
|
243
|
-
*/
|
|
244
200
|
constructor(client, txBuilder) {
|
|
245
201
|
this.client = client;
|
|
246
202
|
this.txBuilder = txBuilder;
|
|
247
203
|
logger.info('CardanoIndexer instance created');
|
|
248
204
|
}
|
|
249
205
|
/**
|
|
250
|
-
* Index
|
|
251
|
-
*
|
|
252
|
-
* atomicity: either all entities are persisted or none are (automatic rollback on error).
|
|
253
|
-
* @param tx CAP transaction (cds.tx(req))
|
|
254
|
-
* @param txHash Cardano transaction hash (hex)
|
|
255
|
-
* @returns {Promise<CardanoTransaction>} transaction entity data
|
|
206
|
+
* Index a transaction with inputs/outputs/assets/metadata; all UPSERTs run in the caller's
|
|
207
|
+
* transaction, so either everything persists or nothing does.
|
|
256
208
|
*/
|
|
257
209
|
async indexTransaction(tx, txHash) {
|
|
258
|
-
// getting data from cardano data provider
|
|
259
210
|
const providerTx = await this.client.getTransaction(txHash);
|
|
260
211
|
const txRow = (0, mappers_1.mapTransaction)(providerTx);
|
|
261
212
|
await tx.run(UPSERT.into(CardanoODataService_1.Transactions).entries(txRow));
|
|
@@ -273,8 +224,7 @@ class CardanoIndexer {
|
|
|
273
224
|
logger.debug(`indexTransaction: upserted ${inputAssetRows.length} transaction input assets for ${txHash}`);
|
|
274
225
|
}
|
|
275
226
|
}
|
|
276
|
-
// Outputs + OutputAssets —
|
|
277
|
-
// `inputs` previously skipped its outputs entirely)
|
|
227
|
+
// Outputs + OutputAssets — must not depend on the inputs branch
|
|
278
228
|
if (providerTx.outputs) {
|
|
279
229
|
const outputRows = (0, mappers_1.mapTransactionOutputs)(txHash, providerTx.outputs);
|
|
280
230
|
const outputAssetRows = (0, mappers_1.mapTransactionOutputAssets)(txHash, providerTx.outputs);
|
|
@@ -292,11 +242,8 @@ class CardanoIndexer {
|
|
|
292
242
|
return txRow;
|
|
293
243
|
}
|
|
294
244
|
/**
|
|
295
|
-
* Index
|
|
296
|
-
*
|
|
297
|
-
* @param tx CAP transaction
|
|
298
|
-
* @param addr bech32 address
|
|
299
|
-
* @return {Promise<Address>} address entity data
|
|
245
|
+
* Index address data with assets and UTxOs; transactions are loaded separately via
|
|
246
|
+
* indexAddressTransactions().
|
|
300
247
|
*/
|
|
301
248
|
async indexAddress(tx, addr) {
|
|
302
249
|
const addrData = await this.client.getAddress(addr);
|
|
@@ -306,8 +253,7 @@ class CardanoIndexer {
|
|
|
306
253
|
const validFrom = AddrEntity.validFrom ?? now;
|
|
307
254
|
const validTo = AddrEntity.validTo ?? now;
|
|
308
255
|
await tx.run(UPSERT.into(CardanoODataService_1.Addresses).entries(AddrEntity));
|
|
309
|
-
//
|
|
310
|
-
// Supplement address-level amounts with assets found in UTxOs but missing from addresses endpoint
|
|
256
|
+
// Supplement address-level amounts with assets only present in UTxOs
|
|
311
257
|
const addressAssetUnits = new Set(addrData.amount.filter(a => a.unit !== 'lovelace').map(a => a.unit));
|
|
312
258
|
for (const utxo of addrData.utxos) {
|
|
313
259
|
for (const amt of utxo.amount) {
|
|
@@ -357,17 +303,8 @@ class CardanoIndexer {
|
|
|
357
303
|
return AddrEntity;
|
|
358
304
|
}
|
|
359
305
|
/**
|
|
360
|
-
* Index UTxOs by 28-byte payment credential
|
|
361
|
-
*
|
|
362
|
-
* current data. Underlying AddressUTxOs/UTxOAssets rows are UPSERTed and stay
|
|
363
|
-
* available for follow-up address-keyed queries within the TTL.
|
|
364
|
-
*
|
|
365
|
-
* Does NOT upsert parent Addresses rows; child rows reference bech32 addresses
|
|
366
|
-
* that may not yet have a parent stub. Same pattern as TransactionInputs.
|
|
367
|
-
*
|
|
368
|
-
* @param tx CAP transaction
|
|
369
|
-
* @param credHash 28-byte payment credential as 56-char lowercase hex
|
|
370
|
-
* @return UTxO entity rows across all bech32 addresses sharing the credential
|
|
306
|
+
* Index UTxOs by 28-byte payment credential (56-char hex), always fresh from Koios. Child
|
|
307
|
+
* rows are UPSERTed without a parent Addresses row (same pattern as TransactionInputs).
|
|
371
308
|
*/
|
|
372
309
|
async indexCredentialUtxos(tx, credHash) {
|
|
373
310
|
const utxos = await this.client.getCredentialUtxos(credHash);
|
|
@@ -408,17 +345,8 @@ class CardanoIndexer {
|
|
|
408
345
|
return allRows;
|
|
409
346
|
}
|
|
410
347
|
/**
|
|
411
|
-
* Index
|
|
412
|
-
*
|
|
413
|
-
* the live UTxO set but not address aggregation (e.g. Ogmios). Used as the
|
|
414
|
-
* GetUTxOsByAddress fallback when no configured backend supports getAddress.
|
|
415
|
-
*
|
|
416
|
-
* Does NOT upsert a parent Addresses row (same pattern as indexCredentialUtxos);
|
|
417
|
-
* AddressUTxOs/UTxOAssets reference the bech32 address directly.
|
|
418
|
-
*
|
|
419
|
-
* @param tx CAP transaction
|
|
420
|
-
* @param addr bech32 address
|
|
421
|
-
* @return UTxO entity rows for the address (empty when the address holds none)
|
|
348
|
+
* Index only the UTxOs of an address via getAddressUtxos (no getAddress call), so it works on
|
|
349
|
+
* backends without address aggregation such as Ogmios. Writes no parent Addresses row.
|
|
422
350
|
*/
|
|
423
351
|
async indexAddressUtxos(tx, addr) {
|
|
424
352
|
const utxos = await this.client.getAddressUtxos(addr);
|
|
@@ -444,21 +372,9 @@ class CardanoIndexer {
|
|
|
444
372
|
return utxoEntities;
|
|
445
373
|
}
|
|
446
374
|
/**
|
|
447
|
-
* Evict cached rows a submitted transaction made stale
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* - all address-level rows of the output addresses (their UTxO set gained
|
|
451
|
-
* the new outputs — sender change included) and of `extraAddresses`
|
|
452
|
-
* (e.g. the build's sender when the CBOR could not be parsed).
|
|
453
|
-
*
|
|
454
|
-
* Only the read cache is touched; submissions/builds stay untouched. Note the
|
|
455
|
-
* next refetch may STILL see pre-submit state on lagging backends
|
|
456
|
-
* (Blockfrost/Koios propagation) — that matches cache-less behaviour and is
|
|
457
|
-
* not recoverable server-side.
|
|
458
|
-
*
|
|
459
|
-
* @param tx CAP transaction
|
|
460
|
-
* @param targets input refs + output addresses from extractTxCacheTargets
|
|
461
|
-
* @param extraAddresses additional bech32 addresses to evict
|
|
375
|
+
* Evict cached rows a submitted transaction made stale: every consumed input ref (under any
|
|
376
|
+
* address) and all address-level rows of the output addresses plus `extraAddresses`. Only the
|
|
377
|
+
* read cache is touched; lagging backends may still serve pre-submit state on refetch.
|
|
462
378
|
*/
|
|
463
379
|
async invalidateUtxoCacheForTx(tx, targets, extraAddresses = []) {
|
|
464
380
|
const addresses = [...new Set([...targets.outputAddresses, ...extraAddresses])];
|
|
@@ -476,21 +392,15 @@ class CardanoIndexer {
|
|
|
476
392
|
logger.debug(`Invalidated UTxO cache: ${addresses.length} address(es), ${targets.inputs.length} spent input ref(s)`);
|
|
477
393
|
}
|
|
478
394
|
}
|
|
479
|
-
/**
|
|
480
|
-
* Index & return address transactions (separate from indexAddress for lazy loading)
|
|
481
|
-
* @param tx CAP transaction
|
|
482
|
-
* @param addr bech32 address
|
|
483
|
-
* @param limit maximum number of transactions to fetch
|
|
484
|
-
* @return {Promise<AddressTransactions[]>} address transaction entities
|
|
485
|
-
*/
|
|
395
|
+
/** Index address transactions (separate from indexAddress for lazy loading). */
|
|
486
396
|
async indexAddressTransactions(tx, addr, limit) {
|
|
487
397
|
logger.debug(`indexAddressTransactions: fetching transactions for ${addr}`);
|
|
488
|
-
//
|
|
398
|
+
// Hash-only listing (one API call)
|
|
489
399
|
const txHashes = await this.client.getAddressTransactionHashes(addr, limit);
|
|
490
400
|
logger.debug(`indexAddressTransactions: found ${txHashes.length} tx hashes for ${addr}`);
|
|
491
401
|
if (txHashes.length === 0)
|
|
492
402
|
return [];
|
|
493
|
-
//
|
|
403
|
+
// DB-first dedup + batch fetch
|
|
494
404
|
const batchFetched = await this.ensureTransactionsIndexed(tx, txHashes);
|
|
495
405
|
// For address-transaction mapping we need full provider tx data (inputs/outputs for net amounts).
|
|
496
406
|
// Transactions already in DB were not re-fetched — batch-fetch those separately.
|
|
@@ -524,41 +434,21 @@ class CardanoIndexer {
|
|
|
524
434
|
transactionsEntities.sort((a, b) => (b.blockTime ?? 0) - (a.blockTime ?? 0));
|
|
525
435
|
return transactionsEntities;
|
|
526
436
|
}
|
|
527
|
-
/**
|
|
528
|
-
* Index & return address signing request association
|
|
529
|
-
* Links an address to a signing request for address-based queries
|
|
530
|
-
* @param tx CAP transaction
|
|
531
|
-
* @param addr bech32 address
|
|
532
|
-
* @param signingRequestId signing request UUID
|
|
533
|
-
* @return {Promise<void>}
|
|
534
|
-
*/
|
|
437
|
+
/** Link an address to a signing request for address-based queries. */
|
|
535
438
|
async indexAddressSigningRequests(tx, addr, signingRequestId) {
|
|
536
439
|
logger.debug(`indexAddressSigningRequests: linking address ${addr} to signing request ${signingRequestId}`);
|
|
537
440
|
const addressSigningRequestEntity = (0, mappers_1.mapAddressSigningRequest)(addr, signingRequestId);
|
|
538
441
|
await tx.run(UPSERT.into(CardanoSignService_1.AddressSigningRequests).entries(addressSigningRequestEntity));
|
|
539
442
|
logger.debug(`indexAddressSigningRequests: linked address ${addr} to signing request ${signingRequestId}`);
|
|
540
443
|
}
|
|
541
|
-
/**
|
|
542
|
-
* Index & return address transaction build association
|
|
543
|
-
* Links an address to a transaction build for address-based queries
|
|
544
|
-
* @param tx CAP transaction
|
|
545
|
-
* @param addr bech32 address
|
|
546
|
-
* @param buildId transaction build UUID
|
|
547
|
-
* @return {Promise<void>}
|
|
548
|
-
*/
|
|
444
|
+
/** Link an address to a transaction build for address-based queries. */
|
|
549
445
|
async indexAddressTransactionBuilds(tx, addr, buildId) {
|
|
550
446
|
logger.debug(`indexAddressTransactionBuilds: linking address ${addr} to build ${buildId}`);
|
|
551
447
|
const addressTransactionBuildEntity = (0, mappers_1.mapAddressTransactionBuild)(addr, buildId);
|
|
552
448
|
await tx.run(UPSERT.into(CardanoTransactionService_1.AddressTransactionBuilds).entries(addressTransactionBuildEntity));
|
|
553
449
|
logger.debug(`indexAddressTransactionBuilds: linked address ${addr} to build ${buildId}`);
|
|
554
450
|
}
|
|
555
|
-
/**
|
|
556
|
-
* Index & return metadata for a single transaction (Metadata)
|
|
557
|
-
* @param tx CAP transaction
|
|
558
|
-
* @param txHash transaction hash
|
|
559
|
-
* @param metadata raw metadata object (label -> JSONValue)
|
|
560
|
-
* @return {Promise<TransactionMetadata[]>} array of transaction metadata rows
|
|
561
|
-
*/
|
|
451
|
+
/** Index the metadata rows of a transaction. */
|
|
562
452
|
async indexTransactionMetadata(tx, tx_hash) {
|
|
563
453
|
const metadata = await this.client.getTransactionMetadata(tx_hash);
|
|
564
454
|
const rows = (0, mappers_1.mapTransactionMetadata)(metadata);
|
|
@@ -567,23 +457,14 @@ class CardanoIndexer {
|
|
|
567
457
|
}
|
|
568
458
|
return rows;
|
|
569
459
|
}
|
|
570
|
-
/**
|
|
571
|
-
* Index & return the network information data
|
|
572
|
-
* @param tx CAP transaction object
|
|
573
|
-
* @returns {Promise<NetworkInformation>} network information entity data
|
|
574
|
-
*/
|
|
460
|
+
/** Index the network information. */
|
|
575
461
|
async indexNetworkInformation(tx) {
|
|
576
462
|
const netInfo = await this.client.getNetworkInformation();
|
|
577
463
|
const netEntity = (0, mappers_1.mapNetworkInfo)(netInfo, this.client.max_age_ms, this.client.network);
|
|
578
464
|
await tx.run(UPSERT.into(CardanoODataService_1.NetworkInformation).entries(netEntity));
|
|
579
465
|
return netEntity;
|
|
580
466
|
}
|
|
581
|
-
/**
|
|
582
|
-
* Index & return the block information data
|
|
583
|
-
* @param tx CAP transaction object
|
|
584
|
-
* @param blockHash block hash (hex)
|
|
585
|
-
* @returns {Promise<Block>} block entity data
|
|
586
|
-
*/
|
|
467
|
+
/** Index a block by hash, with best-effort epoch enrichment. */
|
|
587
468
|
async indexBlock(tx, blockHash) {
|
|
588
469
|
const blockInfo = await this.client.getBlock(blockHash);
|
|
589
470
|
let epoch;
|
|
@@ -598,28 +479,13 @@ class CardanoIndexer {
|
|
|
598
479
|
return blockEntity;
|
|
599
480
|
}
|
|
600
481
|
/**
|
|
601
|
-
* Bulk-index a whole block and
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
* accumulated across the block's txs and UPSERTed once per table (few statements).
|
|
605
|
-
*
|
|
606
|
-
* All writes run inside the caller's CAP transaction (`tx`), so a block is persisted
|
|
607
|
-
* atomically — a failure mid-block rolls the whole block back, keeping the cursor and
|
|
608
|
-
* the data consistent.
|
|
609
|
-
*
|
|
610
|
-
* Inputs from the Ogmios chain-sync path arrive as bare references (no address/amount);
|
|
611
|
-
* resolveInputs() backfills them from this block's own outputs and previously-indexed
|
|
612
|
-
* outputs before mapping. Blockfrost/Koios inputs already carry address/amount and are
|
|
613
|
-
* left untouched.
|
|
614
|
-
*
|
|
615
|
-
* @param tx CAP transaction (one per block, committed by the crawler)
|
|
616
|
-
* @param blockData block header/summary from the crawler source
|
|
617
|
-
* @param txs the block's full transaction list (in block order)
|
|
482
|
+
* Bulk-index a whole block and its transactions in one pass for the crawler: no per-hash
|
|
483
|
+
* re-fetch, one UPSERT per table, all inside the caller's transaction so the block persists
|
|
484
|
+
* atomically. Bare chain-sync inputs are backfilled by resolveInputs() first.
|
|
618
485
|
*/
|
|
619
486
|
async indexBlockFull(tx, blockData, txs) {
|
|
620
|
-
//
|
|
621
|
-
//
|
|
622
|
-
// if the caller skipped it, resolve now (memoized) and accept the in-tx fetch.
|
|
487
|
+
// Epoch from the prefetched memo; if the caller skipped prefetchCrawlEpoch, resolve now
|
|
488
|
+
// (memoized) and accept the in-tx fetch.
|
|
623
489
|
let epoch;
|
|
624
490
|
if (blockData.epoch != null) {
|
|
625
491
|
await this.prefetchCrawlEpoch(blockData.epoch);
|
|
@@ -636,18 +502,16 @@ class CardanoIndexer {
|
|
|
636
502
|
await this.resolveInputs(tx, txs);
|
|
637
503
|
this.applyCollateralFees(blockData, txs);
|
|
638
504
|
await tx.run(UPSERT.into(CardanoODataService_1.Block).entries((0, mappers_1.mapBlock)(blockData, epoch)));
|
|
639
|
-
//
|
|
640
|
-
//
|
|
641
|
-
// of this plugin by the db-level hook in srv/utils/db-sanitize.ts, not per call site.
|
|
505
|
+
// One bulk UPSERT per table. NUL safety for PostgreSQL is enforced by the db-level hook in
|
|
506
|
+
// srv/utils/db-sanitize.ts, not per call site.
|
|
642
507
|
const txRows = txs.map(t => (0, mappers_1.mapTransaction)(t));
|
|
643
508
|
const inputRows = txs.flatMap(t => (0, mappers_1.mapTransactionInputs)(t.hash, t.inputs ?? []));
|
|
644
509
|
const inputAssetRows = txs.flatMap(t => (0, mappers_1.mapTransactionInputAssets)(t.hash, t.inputs ?? []));
|
|
645
510
|
const outputRows = txs.flatMap(t => (0, mappers_1.mapTransactionOutputs)(t.hash, t.outputs ?? []));
|
|
646
511
|
const outputAssetRows = txs.flatMap(t => (0, mappers_1.mapTransactionOutputAssets)(t.hash, t.outputs ?? []));
|
|
647
512
|
const metadataRows = txs.flatMap(t => (0, mappers_1.mapTransactionMetadata)(t.metadata ?? []));
|
|
648
|
-
// Certificates + withdrawals are
|
|
649
|
-
//
|
|
650
|
-
// (tx, stakeAddress), so a re-crawl is idempotent and a reorg removes them with their tx.
|
|
513
|
+
// Certificates + withdrawals are keyed (tx, certIndex, kind) / (tx, stakeAddress), so a
|
|
514
|
+
// re-crawl is idempotent and a reorg removes them with their tx.
|
|
651
515
|
const certificateRows = this.crawlCertificates
|
|
652
516
|
? txs.flatMap(t => (0, mappers_1.mapTransactionCertificates)(t.hash, t.certificates ?? []))
|
|
653
517
|
: [];
|
|
@@ -693,9 +557,7 @@ class CardanoIndexer {
|
|
|
693
557
|
}
|
|
694
558
|
if (assetHistoryRows.length)
|
|
695
559
|
await tx.run(UPSERT.into(CardanoODataService_1.AssetHistory).entries(assetHistoryRows));
|
|
696
|
-
// Catalogue last
|
|
697
|
-
// native assets costs nothing here. Collecting the units is skipped entirely when the
|
|
698
|
-
// catalogue is off — this runs once per block.
|
|
560
|
+
// Catalogue last; collecting the units is skipped entirely when the catalogue is off.
|
|
699
561
|
const newAssets = this.crawlAssetCatalogue === 'off'
|
|
700
562
|
? 0
|
|
701
563
|
: await this.ensureAssetRows(tx, this.collectBlockUnits(txs, assetHistoryRows));
|
|
@@ -703,16 +565,8 @@ class CardanoIndexer {
|
|
|
703
565
|
`${assetHistoryRows.length} mint/burn, ${newAssets} new assets`);
|
|
704
566
|
}
|
|
705
567
|
/**
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
* tx's output in the same block), then batch-reads previously-indexed outputs from the
|
|
709
|
-
* DB. Inputs that already carry an address (Blockfrost/Koios) are skipped.
|
|
710
|
-
*/
|
|
711
|
-
/**
|
|
712
|
-
* `crawler.certificates` is on but the block's transactions carry no `certificates` field at
|
|
713
|
-
* all — the source does not report them (Blockfrost: a per-tx enumeration would be six extra
|
|
714
|
-
* calls per transaction). `[]` means "none", undefined means "unreported"; only the latter is
|
|
715
|
-
* worth a warning, and only once — the crawl itself is unaffected.
|
|
568
|
+
* Warn once when `crawler.certificates` is on but the source reports none (`certificates`
|
|
569
|
+
* undefined, as with Blockfrost). `[]` means "none" and is not a warning.
|
|
716
570
|
*/
|
|
717
571
|
warnIfCertificatesUnreported(txs) {
|
|
718
572
|
if (this.certificatesUnreportedWarned || !txs.length)
|
|
@@ -724,6 +578,10 @@ class CardanoIndexer {
|
|
|
724
578
|
'(Blockfrost pagination) — TransactionCertificates/TransactionWithdrawals stay empty until ' +
|
|
725
579
|
'the crawl runs on Ogmios chain-sync or Koios');
|
|
726
580
|
}
|
|
581
|
+
/**
|
|
582
|
+
* Backfill address/amount of bare chain-sync inputs: from this block's own outputs first,
|
|
583
|
+
* then earlier-indexed outputs from the DB. Inputs that already carry an address are skipped.
|
|
584
|
+
*/
|
|
727
585
|
async resolveInputs(tx, txs) {
|
|
728
586
|
// 1. In-memory index of this block's outputs (txHash#outputIndex -> {address, amount})
|
|
729
587
|
const blockOutputs = new Map();
|
|
@@ -751,9 +609,8 @@ class CardanoIndexer {
|
|
|
751
609
|
}
|
|
752
610
|
if (!unresolved.length)
|
|
753
611
|
return;
|
|
754
|
-
// 3. Batch-read prior-block outputs from the DB
|
|
755
|
-
//
|
|
756
|
-
// discipline as the crawler's reorg deletes)
|
|
612
|
+
// 3. Batch-read prior-block outputs from the DB, chunked so a dense block's input set
|
|
613
|
+
// never exceeds a driver's bind-variable cap
|
|
757
614
|
const sourceHashes = [...new Set(unresolved.map(u => u.input.txHash))];
|
|
758
615
|
const addrByKey = new Map();
|
|
759
616
|
const amtByKey = new Map();
|
|
@@ -782,24 +639,9 @@ class CardanoIndexer {
|
|
|
782
639
|
}
|
|
783
640
|
}
|
|
784
641
|
/**
|
|
785
|
-
* Settle the fee of phase-2-invalid transactions
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* collateral instead, i.e. the collateral inputs minus the collateral return. The Ogmios
|
|
789
|
-
* mapper already uses the body's `total_collateral` when it declares one; what is left are
|
|
790
|
-
* the transactions without it, and those need the collateral inputs that resolveInputs()
|
|
791
|
-
* has just filled in.
|
|
792
|
-
*
|
|
793
|
-
* A collateral input the crawler cannot resolve — spent from an output produced before the
|
|
794
|
-
* crawl start, so no row exists locally — would make the sum silently too small. The
|
|
795
|
-
* declared fee is kept in that case and the transaction is logged: a value that is wrong in
|
|
796
|
-
* a known, named way beats one that looks derived but is short by an unknown amount.
|
|
797
|
-
*
|
|
798
|
-
* Applies to every backend that reports phase-2 validity — the chain-sync path (`spends`)
|
|
799
|
-
* and Blockfrost (`valid_contract`), whose declared `fees` are likewise never collected on a
|
|
800
|
-
* failed script phase, and Koios (`valid_contract` + collateral inputs/output on `/tx_info`).
|
|
801
|
-
* A source without the field carries `spendsCollaterals` as undefined and passes through
|
|
802
|
-
* untouched.
|
|
642
|
+
* Settle the fee of phase-2-invalid transactions (collateral inputs minus collateral return)
|
|
643
|
+
* and the block total. The declared fee is kept when the mapper already set it via
|
|
644
|
+
* `total_collateral` or a collateral input is not indexed locally (the sum would be short).
|
|
803
645
|
*/
|
|
804
646
|
applyCollateralFees(blockData, txs) {
|
|
805
647
|
const lovelaceOf = (amount) => BigInt(amount?.find(a => a.unit === 'lovelace')?.quantity ?? '0');
|
|
@@ -835,24 +677,9 @@ class CardanoIndexer {
|
|
|
835
677
|
}
|
|
836
678
|
}
|
|
837
679
|
/**
|
|
838
|
-
* Mint/burn rows for a
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
* Two sources, in this order:
|
|
842
|
-
* 1. `t.mint` — the ledger's own mint field, reported natively by Ogmios (`mint`) and
|
|
843
|
-
* Koios (`assets_minted`). Authoritative: it needs no resolved inputs and states the
|
|
844
|
-
* net per unit directly.
|
|
845
|
-
* 2. Σ outputs − Σ inputs per unit, for backends without that field (Blockfrost), whose
|
|
846
|
-
* inputs all carry their full `amount` so the delta is exact.
|
|
847
|
-
*
|
|
848
|
-
* The delta path excludes what the ledger does not consume or produce: reference inputs are
|
|
849
|
-
* read, never spent, and collateral only moves when the script phase failed — which applies
|
|
850
|
-
* no mint at all, so those transactions are skipped outright. Both exclusions rest on
|
|
851
|
-
* `isReference` / `isCollateral` / `spendsCollaterals`, which every backend that can reach
|
|
852
|
-
* this branch has to set — Blockfrost does since rc.12. A transaction with even one
|
|
853
|
-
* unresolvable consumed input (an output created before the crawl start, so no local row) is
|
|
854
|
-
* skipped and logged rather than reported with a delta that is short by an unknown amount —
|
|
855
|
-
* the same discipline as applyCollateralFees() above.
|
|
680
|
+
* Mint/burn rows for a block from data in hand: the ledger's mint field when the source
|
|
681
|
+
* reports it (Ogmios, Koios), else Σ outputs − Σ inputs per unit, excluding reference and
|
|
682
|
+
* collateral inputs. A tx with an unresolvable consumed input is skipped and logged.
|
|
856
683
|
*/
|
|
857
684
|
buildAssetHistoryRows(blockData, txs) {
|
|
858
685
|
const entries = [];
|
|
@@ -911,21 +738,10 @@ class CardanoIndexer {
|
|
|
911
738
|
return (0, mappers_1.mapAssetHistory)(entries);
|
|
912
739
|
}
|
|
913
740
|
/**
|
|
914
|
-
* Keep the `Assets` catalogue complete for every unit the crawl meets,
|
|
915
|
-
*
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
* therefore carries the fixed epoch-zero stamp (`BARE_ASSET_STAMP`), which no wall-clock slice
|
|
919
|
-
* from mapAsset() can ever alias: the write cannot overwrite enriched registry data, and it
|
|
920
|
-
* stays a single idempotent row per unit. That makes UPSERT safe — and safe is what it has to
|
|
921
|
-
* be, because this runs inside the crawler's block transaction, where a unique-key violation
|
|
922
|
-
* from a lazy-path write racing us would take the whole block down with it (and on PostgreSQL
|
|
923
|
-
* poison the transaction beyond any catch).
|
|
924
|
-
*
|
|
925
|
-
* The existence check is then only an optimization — it keeps a settled catalogue from
|
|
926
|
-
* rewriting every unit of every block. It runs against the DB-LEVEL entity on purpose: the
|
|
927
|
-
* service projection carries the temporal filter (`validFrom < $valid.to AND validTo >
|
|
928
|
-
* $valid.from`), which hides precisely the born-expired rows this check is looking for.
|
|
741
|
+
* Keep the `Assets` catalogue complete for every unit the crawl meets, without provider calls.
|
|
742
|
+
* `Assets` is temporal, key `(validFrom, unit)`: the bare row's fixed epoch-zero stamp never
|
|
743
|
+
* aliases an enriched slice, so the UPSERT is safe inside the block transaction. The existence
|
|
744
|
+
* check uses the DB-level entity: the service projection's temporal filter hides such rows.
|
|
929
745
|
*/
|
|
930
746
|
async ensureAssetRows(tx, units) {
|
|
931
747
|
if (this.crawlAssetCatalogue === 'off' || !units.size)
|
|
@@ -947,13 +763,11 @@ class CardanoIndexer {
|
|
|
947
763
|
if (!missing.length)
|
|
948
764
|
return 0;
|
|
949
765
|
const rows = missing.map(mappers_1.mapBareAsset).filter((r) => r !== null);
|
|
950
|
-
// Chunked like the lookup
|
|
951
|
-
// and one statement per 500 rows keeps every driver's bind-variable cap out of reach.
|
|
766
|
+
// Chunked like the lookup: a mint-storm block can carry thousands of fresh units.
|
|
952
767
|
for (const rowChunk of (0, collections_1.chunk)(rows, collections_1.IN_CHUNK)) {
|
|
953
768
|
await tx.run(UPSERT.into(cardano_1.Assets).entries(rowChunk));
|
|
954
769
|
}
|
|
955
|
-
// Memoize
|
|
956
|
-
// that a malformed unit is unmappable on every block would cost a SELECT each time.
|
|
770
|
+
// Memoize also the units mapBareAsset rejected, so they cost no SELECT per block.
|
|
957
771
|
for (const unit of missing)
|
|
958
772
|
this.noteAssetSeen(unit);
|
|
959
773
|
if (this.crawlAssetCatalogue === 'enrich' && rows.length) {
|
|
@@ -967,9 +781,8 @@ class CardanoIndexer {
|
|
|
967
781
|
return rows.length;
|
|
968
782
|
}
|
|
969
783
|
/**
|
|
970
|
-
* Remember a unit as present in the catalogue. Insertion-ordered
|
|
971
|
-
*
|
|
972
|
-
* hot policies stay memoized. Losing an entry costs one SELECT, never a wrong write.
|
|
784
|
+
* Remember a unit as present in the catalogue. Insertion-ordered eviction keeps a long
|
|
785
|
+
* backfill's memory flat; losing an entry costs one SELECT, never a wrong write.
|
|
973
786
|
*/
|
|
974
787
|
noteAssetSeen(unit) {
|
|
975
788
|
if (this.assetMemo.has(unit))
|
|
@@ -982,19 +795,9 @@ class CardanoIndexer {
|
|
|
982
795
|
this.assetMemo.add(unit);
|
|
983
796
|
}
|
|
984
797
|
/**
|
|
985
|
-
* Snapshot every
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
* block's write transaction: a few thousand rows would inflate an otherwise small atomic
|
|
989
|
-
* write, and a snapshot failure would fail the block and burn its persist retries.
|
|
990
|
-
*
|
|
991
|
-
* Writes two things per entity: the dated snapshot row (authoritative, never expires) and a
|
|
992
|
-
* refresh of the live temporal row, so `Pools` / `Dreps` also stop being empty on a crawled
|
|
993
|
-
* instance. Needs an enumerating backend (Koios); without one it is a logged no-op.
|
|
994
|
-
*
|
|
995
|
-
* @param epoch the epoch the snapshot is taken for
|
|
996
|
-
* @param at slot and block time of the block that triggered the boundary
|
|
997
|
-
* @returns counts actually written, for the caller's log
|
|
798
|
+
* Snapshot every pool and DRep for an epoch in its OWN transaction (after the block commit):
|
|
799
|
+
* dated snapshot rows plus a refresh of the live `Pools` / `Dreps` rows. Needs Koios, else a no-op.
|
|
800
|
+
* @returns counts written
|
|
998
801
|
*/
|
|
999
802
|
async snapshotEpoch(epoch, at) {
|
|
1000
803
|
const backend = this.client.getEnumeratingBackend();
|
|
@@ -1045,24 +848,14 @@ class CardanoIndexer {
|
|
|
1045
848
|
units.add(row.unit);
|
|
1046
849
|
return units;
|
|
1047
850
|
}
|
|
1048
|
-
/**
|
|
1049
|
-
* Index & return the epoch information data
|
|
1050
|
-
* @param tx CAP transaction object
|
|
1051
|
-
* @param epochNumber epoch number
|
|
1052
|
-
* @returns {Promise<Epoch>} epoch entity data
|
|
1053
|
-
*/
|
|
851
|
+
/** Index an epoch by number. */
|
|
1054
852
|
async indexEpoch(tx, epochNumber) {
|
|
1055
853
|
const epochInfo = await this.client.getEpoch(epochNumber);
|
|
1056
854
|
const epochEntity = (0, mappers_1.mapEpoch)(epochInfo);
|
|
1057
855
|
await tx.run(UPSERT.into(CardanoODataService_1.Epoch).entries([epochEntity]));
|
|
1058
856
|
return epochEntity;
|
|
1059
857
|
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Index & return the account information data
|
|
1062
|
-
* @param tx CAP transaction object
|
|
1063
|
-
* @param stakeAddress stake address (bech32)
|
|
1064
|
-
* @returns {Promise<Account>} account entity data
|
|
1065
|
-
*/
|
|
858
|
+
/** Index an account by stake address, plus its addresses when it has any. */
|
|
1066
859
|
async indexAccount(tx, stakeAddress) {
|
|
1067
860
|
const accountInfo = await this.client.getAccount(stakeAddress);
|
|
1068
861
|
const accountEntity = (0, mappers_1.mapAccount)(accountInfo, this.client.max_age_ms);
|
|
@@ -1073,36 +866,21 @@ class CardanoIndexer {
|
|
|
1073
866
|
}
|
|
1074
867
|
return accountEntity;
|
|
1075
868
|
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Index & return the drep information data
|
|
1078
|
-
* @param tx CAP transaction object
|
|
1079
|
-
* @param drepId drep id (bech32)
|
|
1080
|
-
* @returns {Promise<Drep>} drep entity data
|
|
1081
|
-
*/
|
|
869
|
+
/** Index a DRep by bech32 id. */
|
|
1082
870
|
async indexDrep(tx, drepId) {
|
|
1083
871
|
const drepInfo = await this.client.getDrep(drepId);
|
|
1084
872
|
const drepEntity = (0, mappers_1.mapDrep)(drepInfo, this.client.max_age_ms);
|
|
1085
873
|
await tx.run(UPSERT.into(CardanoODataService_1.Dreps).entries(drepEntity));
|
|
1086
874
|
return drepEntity;
|
|
1087
875
|
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Index & return the pool information data
|
|
1090
|
-
* @param tx CAP transaction object
|
|
1091
|
-
* @param poolId pool id (hex)
|
|
1092
|
-
* @returns {Promise<Pool>} pool entity data
|
|
1093
|
-
*/
|
|
876
|
+
/** Index a pool by id. */
|
|
1094
877
|
async indexPool(tx, poolId) {
|
|
1095
878
|
const poolInfo = await this.client.getPool(poolId);
|
|
1096
879
|
const poolEntity = (0, mappers_1.mapPool)(poolInfo, this.client.max_age_ms);
|
|
1097
880
|
await tx.run(UPSERT.into(CardanoODataService_1.Pools).entries(poolEntity));
|
|
1098
881
|
return poolEntity;
|
|
1099
882
|
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Index & return the asset information data
|
|
1102
|
-
* @param tx CAP transaction object
|
|
1103
|
-
* @param unit asset unit (policyId + assetNameHex)
|
|
1104
|
-
* @returns {Promise<Asset>} asset entity data
|
|
1105
|
-
*/
|
|
883
|
+
/** Index an asset by unit (policyId + assetNameHex). */
|
|
1106
884
|
async indexAsset(tx, unit) {
|
|
1107
885
|
const assetInfo = await this.client.getAssetInfo(unit);
|
|
1108
886
|
const assetEntity = (0, mappers_1.mapAsset)(assetInfo, this.client.max_age_ms);
|
|
@@ -1110,14 +888,8 @@ class CardanoIndexer {
|
|
|
1110
888
|
return assetEntity;
|
|
1111
889
|
}
|
|
1112
890
|
/**
|
|
1113
|
-
* Index
|
|
1114
|
-
*
|
|
1115
|
-
* UPSERTs entries by (unit, txHash) — events are immutable, so re-fetching
|
|
1116
|
-
* just refreshes the cap of recent entries; older cached entries persist.
|
|
1117
|
-
* @param tx CAP transaction object
|
|
1118
|
-
* @param unit asset unit (policyId + assetNameHex)
|
|
1119
|
-
* @param limit max number of recent events to fetch (default 100)
|
|
1120
|
-
* @returns {Promise<AssetHistory[]>} list of mint/burn event entity rows
|
|
891
|
+
* Index mint/burn history for an asset, always fresh. Rows are keyed (unit, txHash), so a
|
|
892
|
+
* refetch refreshes the recent cap and older cached entries persist.
|
|
1121
893
|
*/
|
|
1122
894
|
async indexAssetHistory(tx, unit, limit = 100) {
|
|
1123
895
|
const events = await this.client.getAssetHistory(unit, limit);
|
|
@@ -1127,14 +899,7 @@ class CardanoIndexer {
|
|
|
1127
899
|
await tx.run(UPSERT.into(CardanoODataService_1.AssetHistory).entries(rows));
|
|
1128
900
|
return rows;
|
|
1129
901
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
* Common method: build a transaction, persist build result with inputs/outputs/address associations.
|
|
1132
|
-
* All four public indexBuild*Result methods delegate to this to eliminate duplication.
|
|
1133
|
-
* @param tx CAP transaction object
|
|
1134
|
-
* @param buildreq transaction build request data
|
|
1135
|
-
* @param buildFn the specific builder method to call
|
|
1136
|
-
* @returns {Promise<TransactionBuild>} transaction build entity data
|
|
1137
|
-
*/
|
|
902
|
+
/** Build a transaction and persist the build result with inputs/outputs/address association. */
|
|
1138
903
|
async _indexBuildResult(tx, buildreq, buildFn) {
|
|
1139
904
|
const protocolParams = await this.indexProtocolParameters(tx);
|
|
1140
905
|
const txbuildResult = await buildFn(buildreq, protocolParams);
|
|
@@ -1168,52 +933,36 @@ class CardanoIndexer {
|
|
|
1168
933
|
async indexPlutusSpendBuildResult(tx, buildreq) {
|
|
1169
934
|
return this._indexBuildResult(tx, buildreq, (req, params) => this.txBuilder.buildPlutusSpendTransaction(req, params));
|
|
1170
935
|
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Index & return the protocol parameters data
|
|
1173
|
-
* @param tx CAP transaction object
|
|
1174
|
-
* @returns {Promise<LedgerProtocolParameter>} protocol parameters entity data
|
|
1175
|
-
*/
|
|
936
|
+
/** Protocol parameters, served from the DB row within a 5-minute TTL. */
|
|
1176
937
|
async indexProtocolParameters(tx) {
|
|
1177
938
|
const network = this.client.network;
|
|
1178
939
|
const now = Date.now();
|
|
1179
|
-
|
|
1180
|
-
const PROTOCOL_PARAMS_TTL_MS = 5 * 60 * 1000; // 5 minutes — matches client cache TTL
|
|
940
|
+
const PROTOCOL_PARAMS_TTL_MS = 5 * 60 * 1000; // matches the client cache TTL
|
|
1181
941
|
if (now - this.lastParamsFetchTime < PROTOCOL_PARAMS_TTL_MS) {
|
|
1182
|
-
// (network, epoch) is the
|
|
1183
|
-
// order by epoch desc to return the LATEST instead of an arbitrary row.
|
|
942
|
+
// (network, epoch) is the key; order by epoch desc to get the latest row
|
|
1184
943
|
const existing = await tx.run(SELECT.one.from(CardanoODataService_1.LedgerProtocolParameter).where({ network }).orderBy('epoch desc'));
|
|
1185
944
|
if (existing)
|
|
1186
945
|
return existing;
|
|
1187
946
|
}
|
|
1188
|
-
// Fetch from provider (client has 5-min in-memory TTL cache, so this is cheap)
|
|
1189
947
|
const protocolParamsInfo = await this.client.getProtocolParameters();
|
|
1190
948
|
const protocolParams = (0, mappers_1.mapProtocolParameters)(protocolParamsInfo);
|
|
1191
949
|
await tx.run(UPSERT.into(CardanoODataService_1.LedgerProtocolParameter).entries(protocolParams));
|
|
1192
950
|
this.lastParamsFetchTime = now;
|
|
1193
951
|
return protocolParams;
|
|
1194
952
|
}
|
|
1195
|
-
/**
|
|
1196
|
-
* Persist a transaction submission with optional build association
|
|
1197
|
-
* Handles: TransactionSubmission insert, optional Build status update
|
|
1198
|
-
* @param tx CAP transaction object
|
|
1199
|
-
* @param params submission parameters
|
|
1200
|
-
* @returns {Promise<TransactionSubmission>} persisted transaction submission entity
|
|
1201
|
-
*/
|
|
953
|
+
/** Persist a transaction submission and flag the build as submitted when linked. */
|
|
1202
954
|
async persistTransactionSubmission(tx, params) {
|
|
1203
955
|
const { signedTxCbor, txHash, buildId } = params;
|
|
1204
|
-
// Map submission data
|
|
1205
956
|
const indexSubmission = (0, mappers_1.mapTransactionSubmission)(signedTxCbor, txHash);
|
|
1206
|
-
//
|
|
957
|
+
// status 'pending' until the second phase of the submit flow confirms
|
|
1207
958
|
const submissionRecord = {
|
|
1208
959
|
...indexSubmission,
|
|
1209
960
|
build_id: buildId || null,
|
|
1210
961
|
backendResponse: 'Submitted successfully',
|
|
1211
962
|
status: 'pending',
|
|
1212
963
|
};
|
|
1213
|
-
// Persist submission
|
|
1214
964
|
await tx.run(INSERT.into(CardanoTransactionService_1.TransactionSubmissions).entries(submissionRecord));
|
|
1215
965
|
logger.debug({ submissionId: submissionRecord.id, txHash }, 'Persisted submission record');
|
|
1216
|
-
// Update build status if buildId provided
|
|
1217
966
|
if (buildId) {
|
|
1218
967
|
await tx.run(UPDATE.entity(CardanoTransactionService_1.TransactionBuilds)
|
|
1219
968
|
.set({ wasSubmitted: true })
|
|
@@ -1222,14 +971,7 @@ class CardanoIndexer {
|
|
|
1222
971
|
}
|
|
1223
972
|
return submissionRecord;
|
|
1224
973
|
}
|
|
1225
|
-
/**
|
|
1226
|
-
* Update the status of a transaction submission
|
|
1227
|
-
* Used for the two-phase submit flow: pending → submitted (or failed)
|
|
1228
|
-
* @param tx CAP transaction object
|
|
1229
|
-
* @param submissionId the submission to update
|
|
1230
|
-
* @param status new status value
|
|
1231
|
-
* @param errorMessage optional error message for failed status
|
|
1232
|
-
*/
|
|
974
|
+
/** Update a submission's status (two-phase submit: pending → submitted or failed). */
|
|
1233
975
|
async updateSubmissionStatus(tx, submissionId, status, errorMessage) {
|
|
1234
976
|
const updateData = { status };
|
|
1235
977
|
if (errorMessage) {
|
|
@@ -1240,15 +982,9 @@ class CardanoIndexer {
|
|
|
1240
982
|
.where({ id: submissionId }));
|
|
1241
983
|
logger.debug({ submissionId, status }, 'Updated submission status');
|
|
1242
984
|
}
|
|
1243
|
-
/**
|
|
1244
|
-
* Persist a new signing request
|
|
1245
|
-
* @param tx CAP transaction object
|
|
1246
|
-
* @param params signing request parameters from external signer module
|
|
1247
|
-
* @returns persisted signing request record
|
|
1248
|
-
*/
|
|
985
|
+
/** Persist a new signing request and link it to the build's sender address. */
|
|
1249
986
|
async persistSigningRequest(tx, params) {
|
|
1250
987
|
const { buildId, signingPayload } = params;
|
|
1251
|
-
// Create signing request record
|
|
1252
988
|
const signingRequestRecord = {
|
|
1253
989
|
id: signingPayload.signingRequestId,
|
|
1254
990
|
build_id: buildId,
|
|
@@ -1261,26 +997,17 @@ class CardanoIndexer {
|
|
|
1261
997
|
cardanoCliCommand: signingPayload.signingInstructions.cardanoCliCommand,
|
|
1262
998
|
cip30TxCbor: signingPayload.signingInstructions.cip30SigningRequest?.txCbor,
|
|
1263
999
|
};
|
|
1264
|
-
// Persist to database
|
|
1265
1000
|
await tx.run(INSERT.into(CardanoSignService_1.SigningRequests).entries(signingRequestRecord));
|
|
1266
1001
|
logger.debug({ signingRequestId: signingRequestRecord.id, buildId }, 'Persisted signing request');
|
|
1267
|
-
// Index address-signing request association
|
|
1268
1002
|
const build = await tx.run(SELECT.one.from(CardanoTransactionService_1.TransactionBuilds).where({ id: buildId }));
|
|
1269
1003
|
if (build?.senderAddress) {
|
|
1270
1004
|
await this.indexAddressSigningRequests(tx, build.senderAddress, signingRequestRecord.id);
|
|
1271
1005
|
}
|
|
1272
1006
|
return signingRequestRecord;
|
|
1273
1007
|
}
|
|
1274
|
-
/**
|
|
1275
|
-
* Persist a signature verification with signing request status update
|
|
1276
|
-
* Handles: SignatureVerification insert, SigningRequest status update
|
|
1277
|
-
* @param tx CAP transaction object
|
|
1278
|
-
* @param params verification parameters
|
|
1279
|
-
* @returns persisted signature verification record
|
|
1280
|
-
*/
|
|
1008
|
+
/** Persist a signature verification and update the signing request status. */
|
|
1281
1009
|
async persistSignatureVerification(tx, params) {
|
|
1282
1010
|
const { signingRequestId, signedTxCbor, verificationResult, signerType, signerInfo } = params;
|
|
1283
|
-
// Create verification record
|
|
1284
1011
|
const verificationRecord = {
|
|
1285
1012
|
id: cds_1.default.utils.uuid(),
|
|
1286
1013
|
signingRequest_id: signingRequestId,
|
|
@@ -1293,10 +1020,8 @@ class CardanoIndexer {
|
|
|
1293
1020
|
warnings: JSON.stringify(verificationResult.warnings),
|
|
1294
1021
|
verifiedAt: new Date().toISOString(),
|
|
1295
1022
|
};
|
|
1296
|
-
// Persist verification
|
|
1297
1023
|
await tx.run(INSERT.into(CardanoSignService_1.SignatureVerifications).entries(verificationRecord));
|
|
1298
1024
|
logger.debug({ verificationId: verificationRecord.id }, 'Persisted signature verification record');
|
|
1299
|
-
// Update signing request status
|
|
1300
1025
|
const newStatus = verificationResult.isValid ? 'verified' : 'failed';
|
|
1301
1026
|
await tx.run(UPDATE.entity(CardanoSignService_1.SigningRequests)
|
|
1302
1027
|
.set({
|
|
@@ -1310,16 +1035,9 @@ class CardanoIndexer {
|
|
|
1310
1035
|
logger.debug({ signingRequestId, newStatus }, 'Updated signing request status');
|
|
1311
1036
|
return verificationRecord;
|
|
1312
1037
|
}
|
|
1313
|
-
/**
|
|
1314
|
-
* Index a verified transaction submission with all related records
|
|
1315
|
-
* Handles persistence of: SignatureVerification, TransactionSubmission, SigningRequest update, Build update
|
|
1316
|
-
* @param tx CAP transaction object
|
|
1317
|
-
* @param params submission parameters
|
|
1318
|
-
* @returns {Promise<TransactionSubmission>} transaction submission entity data
|
|
1319
|
-
*/
|
|
1038
|
+
/** Persist a verified submission: verification, submission, signing request and build updates. */
|
|
1320
1039
|
async indexVerifiedTransactionSubmission(tx, params) {
|
|
1321
1040
|
const { signingRequestId, buildId, fullSignedTxCbor, txHash, verificationResult, signerType, signerInfo } = params;
|
|
1322
|
-
// Step 1: Create and persist verification record
|
|
1323
1041
|
const verificationRecord = {
|
|
1324
1042
|
id: cds_1.default.utils.uuid(),
|
|
1325
1043
|
signingRequest_id: signingRequestId,
|
|
@@ -1334,7 +1052,6 @@ class CardanoIndexer {
|
|
|
1334
1052
|
};
|
|
1335
1053
|
await tx.run(INSERT.into(CardanoSignService_1.SignatureVerifications).entries(verificationRecord));
|
|
1336
1054
|
logger.debug({ verificationId: verificationRecord.id }, 'Persisted signature verification record');
|
|
1337
|
-
// Step 2: Create and persist submission record
|
|
1338
1055
|
const indexSubmission = (0, mappers_1.mapTransactionSubmission)(fullSignedTxCbor, txHash);
|
|
1339
1056
|
const submissionRecord = {
|
|
1340
1057
|
...indexSubmission,
|
|
@@ -1344,7 +1061,6 @@ class CardanoIndexer {
|
|
|
1344
1061
|
};
|
|
1345
1062
|
await tx.run(INSERT.into(CardanoTransactionService_1.TransactionSubmissions).entries(submissionRecord));
|
|
1346
1063
|
logger.debug({ submissionId: submissionRecord.id }, 'Persisted submission record');
|
|
1347
|
-
// Step 3: Update signing request metadata and status
|
|
1348
1064
|
const now = new Date().toISOString();
|
|
1349
1065
|
await tx.run(UPDATE.entity(CardanoSignService_1.SigningRequests)
|
|
1350
1066
|
.set({
|
|
@@ -1357,29 +1073,20 @@ class CardanoIndexer {
|
|
|
1357
1073
|
})
|
|
1358
1074
|
.where({ id: signingRequestId }));
|
|
1359
1075
|
logger.debug({ signingRequestId }, 'Updated signing request status to submitted');
|
|
1360
|
-
// Step 4: Update build status
|
|
1361
1076
|
await tx.run(UPDATE.entity(CardanoTransactionService_1.TransactionBuilds)
|
|
1362
1077
|
.set({ wasSubmitted: true })
|
|
1363
1078
|
.where({ id: buildId }));
|
|
1364
1079
|
logger.debug({ buildId }, 'Updated build wasSubmitted flag');
|
|
1365
1080
|
return submissionRecord;
|
|
1366
1081
|
}
|
|
1367
|
-
/**
|
|
1368
|
-
* Index & return the latest epoch information data
|
|
1369
|
-
* @param tx CAP transaction object
|
|
1370
|
-
* @returns {Promise<Epoch>} epoch entity data
|
|
1371
|
-
*/
|
|
1082
|
+
/** Index the latest epoch. */
|
|
1372
1083
|
async indexLatestEpoch(tx) {
|
|
1373
1084
|
const epochInfo = await this.client.getLatestEpoch();
|
|
1374
1085
|
const epochEntity = (0, mappers_1.mapEpoch)(epochInfo);
|
|
1375
1086
|
await tx.run(UPSERT.into(CardanoODataService_1.Epoch).entries([epochEntity]));
|
|
1376
1087
|
return epochEntity;
|
|
1377
1088
|
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Index & return the latest block information data
|
|
1380
|
-
* @param tx CAP transaction object
|
|
1381
|
-
* @returns {Promise<Block>} block entity data
|
|
1382
|
-
*/
|
|
1089
|
+
/** Index the latest block, with best-effort epoch enrichment. */
|
|
1383
1090
|
async indexLatestBlock(tx) {
|
|
1384
1091
|
const blockInfo = await this.client.getLatestBlock();
|
|
1385
1092
|
let epoch;
|
|
@@ -1399,30 +1106,20 @@ class CardanoIndexer {
|
|
|
1399
1106
|
/** Max addresses to index concurrently (avoid overloading backends) */
|
|
1400
1107
|
static ADDR_CONCURRENCY = 5;
|
|
1401
1108
|
/**
|
|
1402
|
-
* Ensure a set of transactions
|
|
1403
|
-
*
|
|
1404
|
-
* 2. Check which hashes already exist in DB
|
|
1405
|
-
* 3. Batch-fetch missing transactions from backend
|
|
1406
|
-
* 4. UPSERT all entities (Transactions, Inputs, Outputs, Assets, Metadata)
|
|
1407
|
-
*
|
|
1408
|
-
* @param tx CAP transaction (cds.tx)
|
|
1409
|
-
* @param txHashes array of transaction hashes to ensure
|
|
1410
|
-
* @returns Map of txHash → provider Transaction (all requested, from DB fetch or backend)
|
|
1109
|
+
* Ensure a set of transactions is indexed: DB check, batch fetch of the missing ones, UPSERT.
|
|
1110
|
+
* @returns provider transactions for the hashes that had to be fetched
|
|
1411
1111
|
*/
|
|
1412
1112
|
async ensureTransactionsIndexed(tx, txHashes) {
|
|
1413
1113
|
const unique = [...new Set(txHashes)];
|
|
1414
1114
|
if (unique.length === 0)
|
|
1415
1115
|
return new Map();
|
|
1416
|
-
// DB check — which hashes are already indexed?
|
|
1417
1116
|
const existingRows = await tx.run(SELECT.from(CardanoODataService_1.Transactions).columns('hash').where({ hash: { in: unique } }));
|
|
1418
1117
|
const existingSet = new Set(existingRows.map((r) => r.hash));
|
|
1419
1118
|
const missing = unique.filter(h => !existingSet.has(h));
|
|
1420
1119
|
logger.debug(`ensureTransactionsIndexed: ${unique.length} unique, ${existingSet.size} cached, ${missing.length} to fetch`);
|
|
1421
|
-
// Batch-fetch missing from backend
|
|
1422
1120
|
let fetched = new Map();
|
|
1423
1121
|
if (missing.length > 0) {
|
|
1424
1122
|
fetched = await this.client.getTransactionsBatch(missing);
|
|
1425
|
-
// UPSERT all fetched transactions + child entities
|
|
1426
1123
|
for (const [, providerTx] of fetched) {
|
|
1427
1124
|
const txRow = (0, mappers_1.mapTransaction)(providerTx);
|
|
1428
1125
|
await tx.run(UPSERT.into(CardanoODataService_1.Transactions).entries(txRow));
|
|
@@ -1453,12 +1150,7 @@ class CardanoIndexer {
|
|
|
1453
1150
|
//-----------------------------------------------------------------------------
|
|
1454
1151
|
// Private Helpers
|
|
1455
1152
|
//-----------------------------------------------------------------------------
|
|
1456
|
-
/**
|
|
1457
|
-
* Index multiple addresses with concurrency-limited parallelism.
|
|
1458
|
-
* Processes addresses in chunks to avoid overwhelming backends.
|
|
1459
|
-
* @param tx CAP transaction object
|
|
1460
|
-
* @param bech32List array of bech32 addresses
|
|
1461
|
-
*/
|
|
1153
|
+
/** Index addresses with bounded concurrency. */
|
|
1462
1154
|
async _ensureAddresses(tx, bech32List) {
|
|
1463
1155
|
const concurrency = CardanoIndexer.ADDR_CONCURRENCY;
|
|
1464
1156
|
for (let i = 0; i < bech32List.length; i += concurrency) {
|