@odatano/core 2.0.0-rc.43 → 2.0.0-rc.45
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 +0 -46
- package/@cds-models/CardanoBackendService/index.d.ts +0 -10
- package/@cds-models/CardanoIndexerService/index.d.ts +36 -20
- package/@cds-models/CardanoIndexerService/index.js +4 -0
- package/@cds-models/CardanoODataService/index.d.ts +19 -47
- package/@cds-models/CardanoSignService/index.d.ts +3 -18
- package/@cds-models/CardanoTransactionService/index.d.ts +9 -31
- package/@cds-models/CardanoWorkerService/index.d.ts +3 -19
- package/@cds-models/index.d.ts +17 -0
- package/@cds-models/index.js +2 -0
- package/@cds-models/odatano/cardano/index.d.ts +1 -34
- package/README.md +6 -6
- package/db/schema.cds +29 -44
- package/db/types.cds +22 -5
- package/package.json +3 -1
- package/scripts/migrate-slot-leader.mjs +3 -11
- package/scripts/migrate-txseq.mjs +3 -12
- package/src/index.d.ts +0 -4
- package/src/index.js +3 -5
- package/src/plugin.js +4 -8
- package/srv/blockchain/asset-decimals.d.ts +7 -0
- package/srv/blockchain/asset-decimals.js +91 -0
- package/srv/blockchain/backends/blockfrost-backend.d.ts +2 -10
- package/srv/blockchain/backends/blockfrost-backend.js +15 -21
- package/srv/blockchain/backends/cardano-backend.d.ts +12 -71
- package/srv/blockchain/backends/koios-backend.d.ts +14 -147
- package/srv/blockchain/backends/koios-backend.js +40 -164
- package/srv/blockchain/backends/odatano-backend.d.ts +1 -11
- package/srv/blockchain/backends/odatano-backend.js +11 -12
- package/srv/blockchain/backends/ogmios-backend.d.ts +13 -160
- package/srv/blockchain/backends/ogmios-backend.js +48 -175
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +2 -18
- package/srv/blockchain/backends/ogmios-frame-guard.js +8 -20
- package/srv/blockchain/cardano-client.d.ts +12 -80
- package/srv/blockchain/cardano-client.js +36 -88
- package/srv/blockchain/cardano-indexer.d.ts +12 -192
- package/srv/blockchain/cardano-indexer.js +132 -222
- package/srv/blockchain/cardano-tx-builder.d.ts +1 -28
- package/srv/blockchain/cardano-tx-builder.js +17 -34
- package/srv/blockchain/circuit-breaker.d.ts +1 -13
- package/srv/blockchain/circuit-breaker.js +5 -15
- package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
- package/srv/blockchain/crawler/certificate-backfill.d.ts +0 -17
- package/srv/blockchain/crawler/certificate-backfill.js +8 -22
- package/srv/blockchain/crawler/crawler.d.ts +16 -93
- package/srv/blockchain/crawler/crawler.js +85 -160
- package/srv/blockchain/crawler/credential-backfill.d.ts +0 -9
- package/srv/blockchain/crawler/credential-backfill.js +6 -6
- package/srv/blockchain/crawler/hooks.d.ts +1 -5
- package/srv/blockchain/crawler/index.d.ts +0 -12
- package/srv/blockchain/crawler/index.js +6 -20
- package/srv/blockchain/crawler/sync-state.d.ts +6 -44
- package/srv/blockchain/crawler/sync-state.js +18 -53
- package/srv/blockchain/crawler/transaction-backfill.d.ts +0 -11
- package/srv/blockchain/crawler/transaction-backfill.js +11 -30
- package/srv/blockchain/crawler/utxo-set-import.d.ts +1 -30
- package/srv/blockchain/crawler/utxo-set-import.js +27 -53
- package/srv/blockchain/ledger-state.d.ts +10 -54
- package/srv/blockchain/ledger-state.js +11 -27
- package/srv/blockchain/pending-spends.d.ts +0 -12
- package/srv/blockchain/pending-spends.js +4 -12
- package/srv/blockchain/request-coalescer.d.ts +2 -16
- package/srv/blockchain/request-coalescer.js +2 -16
- package/srv/blockchain/signing/cose-verifier.d.ts +0 -9
- package/srv/blockchain/signing/cose-verifier.js +4 -10
- package/srv/blockchain/signing/external-signer.d.ts +1 -4
- package/srv/blockchain/signing/external-signer.js +2 -8
- package/srv/blockchain/signing/hsm-signer.d.ts +6 -18
- package/srv/blockchain/signing/hsm-signer.js +16 -28
- package/srv/blockchain/signing/signature-verifier.d.ts +1 -8
- package/srv/blockchain/signing/signature-verifier.js +9 -19
- package/srv/blockchain/signing/submission-finalizer.d.ts +10 -16
- package/srv/blockchain/signing/submission-finalizer.js +48 -19
- package/srv/blockchain/stored-chain.d.ts +1 -14
- package/srv/blockchain/stored-chain.js +3 -8
- package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -4
- package/srv/blockchain/transaction-building/buildooor-fee-patch.js +4 -9
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +7 -150
- package/srv/blockchain/transaction-building/buildooor-tx.js +91 -196
- package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -14
- package/srv/blockchain/transaction-building/caller-datums.js +3 -9
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +1 -4
- package/srv/blockchain/wallet-worker/build-request.d.ts +0 -5
- package/srv/blockchain/wallet-worker/build-request.js +6 -9
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -23
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -20
- package/srv/blockchain/wallet-worker/index.d.ts +1 -1
- package/srv/blockchain/wallet-worker/index.js +3 -5
- package/srv/blockchain/wallet-worker/job-store.d.ts +15 -65
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -10
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -12
- package/srv/blockchain/wallet-worker/signers.d.ts +3 -11
- package/srv/blockchain/wallet-worker/signers.js +3 -6
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +3 -21
- package/srv/blockchain/wallet-worker/wallet-worker.js +47 -54
- package/srv/cardano-agent-service.cds +123 -146
- package/srv/cardano-agent-service.js +2 -5
- package/srv/cardano-backend-service.cds +10 -17
- package/srv/cardano-backend-service.js +7 -12
- package/srv/cardano-indexer-service.cds +35 -37
- package/srv/cardano-indexer-service.d.ts +5 -1
- package/srv/cardano-indexer-service.js +64 -33
- package/srv/cardano-service.cds +56 -40
- package/srv/cardano-service.js +42 -69
- package/srv/cardano-sign-service.cds +14 -23
- package/srv/cardano-sign-service.js +18 -24
- package/srv/cardano-tx-service.cds +27 -29
- package/srv/cardano-tx-service.js +60 -122
- package/srv/cardano-worker-service.cds +109 -125
- package/srv/cardano-worker-service.js +21 -31
- package/srv/cbor/cip68.d.ts +13 -0
- package/srv/cbor/cip68.js +56 -0
- package/srv/cbor/index.d.ts +1 -0
- package/srv/cbor/index.js +6 -1
- package/srv/cbor/parse.d.ts +3 -18
- package/srv/cbor/parse.js +2 -7
- package/srv/cbor/plutus-data-json.d.ts +0 -4
- package/srv/server.d.ts +5 -36
- package/srv/server.js +30 -51
- package/srv/utils/agent-grants-config.d.ts +0 -18
- package/srv/utils/agent-grants-config.js +6 -13
- package/srv/utils/agent-grants.d.ts +14 -68
- package/srv/utils/agent-grants.js +42 -60
- package/srv/utils/agent-token-auth.d.ts +0 -5
- package/srv/utils/agent-token-auth.js +2 -5
- package/srv/utils/backend-request-handler.d.ts +1 -1
- package/srv/utils/collections.d.ts +1 -4
- package/srv/utils/collections.js +1 -4
- package/srv/utils/const.d.ts +0 -18
- package/srv/utils/const.js +7 -18
- package/srv/utils/crypto.js +3 -5
- package/srv/utils/db-indexes.d.ts +2 -0
- package/srv/utils/db-indexes.js +22 -9
- package/srv/utils/db-sanitize.d.ts +1 -8
- package/srv/utils/db-sanitize.js +3 -8
- package/srv/utils/epoch-slots.d.ts +1 -8
- package/srv/utils/epoch-slots.js +3 -8
- package/srv/utils/error-codes.d.ts +0 -4
- package/srv/utils/error-codes.js +2 -4
- package/srv/utils/errors.d.ts +2 -22
- package/srv/utils/errors.js +13 -27
- package/srv/utils/liveness.d.ts +0 -4
- package/srv/utils/liveness.js +2 -4
- package/srv/utils/mappers.d.ts +0 -37
- package/srv/utils/mappers.js +22 -39
- package/srv/utils/network-context.js +2 -4
- package/srv/utils/paging.d.ts +31 -0
- package/srv/utils/paging.js +43 -0
- package/srv/utils/pg-inline-json.js +3 -7
- package/srv/utils/pg-order-nulls.js +2 -5
- package/srv/utils/plutus-placeholders.d.ts +0 -13
- package/srv/utils/plutus-placeholders.js +6 -13
- package/srv/utils/rate-limiter.d.ts +0 -8
- package/srv/utils/rate-limiter.js +2 -4
- package/srv/utils/reference-script.d.ts +0 -18
- package/srv/utils/reference-script.js +8 -19
- package/srv/utils/service-events.d.ts +0 -4
- package/srv/utils/service-events.js +2 -4
- package/srv/utils/signing-helper.d.ts +1 -8
- package/srv/utils/signing-helper.js +3 -8
- package/srv/utils/tx-build-helper.d.ts +2 -32
- package/srv/utils/tx-build-helper.js +26 -40
- package/srv/utils/tx-request-parsers.d.ts +1 -25
- package/srv/utils/tx-request-parsers.js +10 -25
- package/srv/utils/tx-utils.d.ts +0 -8
- package/srv/utils/tx-utils.js +10 -13
- package/srv/utils/types.d.ts +2 -37
- package/srv/utils/validators.d.ts +0 -4
- package/srv/utils/validators.js +2 -4
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* The data a CardanoBackend needs, for another ODATANO instance that uses this one as its
|
|
5
|
-
* backend (`backends: ["odatano"]`). Every operation answers the provider shape as a JSON
|
|
6
|
-
* string (`value`), so the caller maps it exactly like a Koios or Blockfrost answer.
|
|
7
|
-
* Stored blocks and transactions come from this instance's index; everything else goes
|
|
8
|
-
* through its own backends and crawled data, as the read service does. Nothing is persisted
|
|
9
|
-
* for the caller.
|
|
10
|
-
*/
|
|
1
|
+
// Backend data for another ODATANO instance that uses this one with `backends: ["odatano"]`.
|
|
2
|
+
// Every operation returns the provider shape as a JSON string, mapped like a Koios answer.
|
|
11
3
|
@requires: 'authenticated-user'
|
|
12
4
|
service CardanoBackendService @(impl: './cardano-backend-service') {
|
|
13
5
|
|
|
@@ -16,21 +8,22 @@ service CardanoBackendService @(impl: './cardano-backend-service') {
|
|
|
16
8
|
action GetTransactionsBatch(hashes: LargeString) returns LargeString;
|
|
17
9
|
action GetTransactionMetadata(hash: String) returns LargeString;
|
|
18
10
|
action GetBlock(hash: String) returns LargeString;
|
|
19
|
-
action GetBlockByHeight(height: Integer64)
|
|
20
|
-
action GetNextBlocks(afterHash: String,
|
|
11
|
+
action GetBlockByHeight(@assert.range: [0, _] height: Integer64) returns LargeString;
|
|
12
|
+
action GetNextBlocks(afterHash: String, @assert.range: [1, 500] count: Integer,
|
|
13
|
+
@assert.range: [0, _] afterHeight: Integer64) returns LargeString;
|
|
21
14
|
action GetBlockTransactions(blockHash: String) returns LargeString;
|
|
22
15
|
action GetLatestBlock() returns LargeString;
|
|
23
16
|
action GetCurrentSlot() returns LargeString;
|
|
24
|
-
action GetEpoch(epoch: Integer)
|
|
17
|
+
action GetEpoch(@assert.range: [0, _] epoch: Integer) returns LargeString;
|
|
25
18
|
action GetLatestEpoch() returns LargeString;
|
|
26
19
|
|
|
27
20
|
// --- addresses and UTxOs ------------------------------------------------------------------
|
|
28
21
|
action GetAddress(address: String) returns LargeString;
|
|
29
22
|
action GetAddressUtxos(address: String) returns LargeString;
|
|
30
|
-
action GetAddressTransactions(address: String, limit: Integer)
|
|
31
|
-
action GetAddressTransactionHashes(address: String, limit: Integer)
|
|
23
|
+
action GetAddressTransactions(address: String, @assert.range: [1, 100] limit: Integer) returns LargeString;
|
|
24
|
+
action GetAddressTransactionHashes(address: String, @assert.range: [1, 100] limit: Integer) returns LargeString;
|
|
32
25
|
action GetCredentialUtxos(credential: String) returns LargeString;
|
|
33
|
-
action IsUtxoUnspent(txHash: String, outputIndex: Integer)
|
|
26
|
+
action IsUtxoUnspent(txHash: String, @assert.range: [0, _] outputIndex: Integer) returns LargeString;
|
|
34
27
|
action GetUnspentOutputs(refs: LargeString) returns LargeString;
|
|
35
28
|
|
|
36
29
|
// --- stake, governance, assets, network ------------------------------------------------
|
|
@@ -42,7 +35,7 @@ service CardanoBackendService @(impl: './cardano-backend-service') {
|
|
|
42
35
|
action GetDrepIds() returns LargeString;
|
|
43
36
|
action GetDreps(ids: LargeString) returns LargeString;
|
|
44
37
|
action GetAssetInfo(unit: String) returns LargeString;
|
|
45
|
-
action GetAssetHistory(unit: String, limit: Integer)
|
|
38
|
+
action GetAssetHistory(unit: String, @assert.range: [1, 100] limit: Integer) returns LargeString;
|
|
46
39
|
action GetNetworkInformation() returns LargeString;
|
|
47
40
|
action GetProtocolParameters() returns LargeString;
|
|
48
41
|
|
|
@@ -13,12 +13,8 @@ const stored_chain_1 = require("./blockchain/stored-chain");
|
|
|
13
13
|
const logger = cds_1.default.log('CardanoBackendService');
|
|
14
14
|
/** Largest list one call may ask for (hashes, refs, ids, blocks). */
|
|
15
15
|
const MAX_LIST = 500;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* CardanoBackendService: the provider shape for another ODATANO instance. Stored blocks and
|
|
19
|
-
* transactions come from the index; the rest goes through the indexer's resolvers (crawled data
|
|
20
|
-
* first, then this instance's backends). Answers are JSON strings (safeJSON keeps big integers).
|
|
21
|
-
*/
|
|
16
|
+
// Provider-shaped answers for another ODATANO instance. Stored blocks and txs come from the index.
|
|
17
|
+
// The rest goes through the indexer's resolvers. Answers are JSON strings so big integers survive.
|
|
22
18
|
module.exports = (srv) => {
|
|
23
19
|
const client = () => (0, server_1.getCardanoClient)();
|
|
24
20
|
const indexer = () => (0, server_1.getCardanoIndexer)();
|
|
@@ -38,7 +34,8 @@ module.exports = (srv) => {
|
|
|
38
34
|
(0, errors_1.rejectInvalid)(req, req.event, `Invalid ${what}`, field);
|
|
39
35
|
};
|
|
40
36
|
const both = (...checks) => (req, data) => checks.forEach(c => c(req, data));
|
|
41
|
-
|
|
37
|
+
// the model range-checks limit and count, so only the default is set here
|
|
38
|
+
const limitOf = (data, fallback) => (data.limit == null ? fallback : Number(data.limit));
|
|
42
39
|
const jsonList = (field, check, what) => (req, data) => {
|
|
43
40
|
if (data[field] == null)
|
|
44
41
|
(0, errors_1.rejectMissing)(req, req.event, field);
|
|
@@ -117,7 +114,7 @@ module.exports = (srv) => {
|
|
|
117
114
|
return paging.getBlockByHeight(Number(height));
|
|
118
115
|
}, need(v => Number.isInteger(Number(v)) && Number(v) >= 0, 'height', 'height'));
|
|
119
116
|
op('GetNextBlocks', async ({ afterHash, count, afterHeight }, db) => {
|
|
120
|
-
const n =
|
|
117
|
+
const n = count == null ? 1 : Number(count);
|
|
121
118
|
const anchor = await (0, stored_chain_1.readBlock)(db, String(afterHash));
|
|
122
119
|
if (anchor?.height != null) {
|
|
123
120
|
const next = await (0, stored_chain_1.readNextBlocks)(db, anchor.height, n);
|
|
@@ -211,10 +208,8 @@ module.exports = (srv) => {
|
|
|
211
208
|
logger.info(`submitted ${hash} for a remote instance`);
|
|
212
209
|
return hash;
|
|
213
210
|
}, cbor);
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* ledger at the latest block (Ogmios). Cached for a minute; callers page through it by id.
|
|
217
|
-
*/
|
|
211
|
+
// The full pool and DRep set, from Koios when configured, else from the Ogmios ledger.
|
|
212
|
+
// Cached for a minute. Details are read in batches of ids.
|
|
218
213
|
let enumerated = null;
|
|
219
214
|
async function enumeration() {
|
|
220
215
|
if (enumerated && Date.now() - enumerated.at < 60_000)
|
|
@@ -1,33 +1,15 @@
|
|
|
1
|
+
using { UtxoSetImportSource } from '../db/types';
|
|
1
2
|
using {odatano.cardano as db} from '../db/schema';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* Control + observability surface for the chain crawler / pre-sync engine:
|
|
7
|
-
* - read-only projections of the sync cursor and reorg audit log
|
|
8
|
-
* - status function + pause/resume actions delegating to the crawler singleton
|
|
9
|
-
*
|
|
10
|
-
* Security note: see CardanoODataService (cardano-service.cds) for the rationale on
|
|
11
|
-
* auth. pause/resume are operational actions — gate behind a dedicated Admin scope.
|
|
12
|
-
* Read-only status and audit data remain available to authenticated users.
|
|
13
|
-
*
|
|
14
|
-
* Deliberately NO service-level @requires: CAP checks a service-level requirement
|
|
15
|
-
* on every request BEFORE the operation's own annotation, so an operation-level
|
|
16
|
-
* `@requires: 'any'` can never open a single function on an otherwise
|
|
17
|
-
* authenticated service (anonymous callers get the 401 challenge first). The
|
|
18
|
-
* requirement therefore sits on each element, and getLiveness() alone is 'any'.
|
|
19
|
-
*/
|
|
20
|
-
// Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
|
|
21
|
-
// treats a service without a service-level @requires as authenticated-user under
|
|
22
|
-
// NODE_ENV=production, which would 401 the anonymous operation below despite its own
|
|
23
|
-
// 'any'. Every element carries its requirement; the service itself refuses nothing.
|
|
4
|
+
// Crawler control and status. The service itself is 'any': CAP checks the service before the
|
|
5
|
+
// operation, so anything stricter would 401 the anonymous getLiveness. Each element carries its own requirement.
|
|
24
6
|
@requires: 'any'
|
|
25
7
|
service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
26
8
|
|
|
27
9
|
@readonly
|
|
28
10
|
@requires : 'authenticated-user'
|
|
29
11
|
@title : 'Sync State'
|
|
30
|
-
@description: 'Singleton crawl cursor
|
|
12
|
+
@description: 'Singleton crawl cursor: pre-sync progress, tip lag, status, errors'
|
|
31
13
|
entity SyncState as projection on db.CardanoSyncState;
|
|
32
14
|
|
|
33
15
|
@readonly
|
|
@@ -41,15 +23,17 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
|
41
23
|
type CrawlerStatus {
|
|
42
24
|
running : Boolean;
|
|
43
25
|
syncStatus : String;
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
// degraded to it still advances the cursor — this is how an operator tells.
|
|
26
|
+
// chain-sync or pagination for the crawler in this process, null when another instance crawls.
|
|
27
|
+
// Pagination is about 50x slower but still advances the cursor, so only this field shows it.
|
|
47
28
|
source : String;
|
|
48
29
|
lastSlot : String;
|
|
49
30
|
lastHeight : String;
|
|
50
31
|
tipHeight : String;
|
|
51
32
|
syncProgress : String;
|
|
52
33
|
consecutiveErrors : Integer;
|
|
34
|
+
lastIndexedAt : Timestamp; // when the last block was committed
|
|
35
|
+
// true: the crawler holds its lease but committed no block for 10 minutes
|
|
36
|
+
stalled : Boolean;
|
|
53
37
|
// crawler-fed ledger state (crawler.utxoSet): snapshot anchor + validity
|
|
54
38
|
utxoSet : UtxoSetStatus;
|
|
55
39
|
// one-off certificate/withdrawal backfill over already crawled blocks (this process)
|
|
@@ -58,6 +42,8 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
|
58
42
|
transactionBackfill : TransactionBackfillStatus;
|
|
59
43
|
// one-off payment-credential fill of UTxO-shaped rows (this process)
|
|
60
44
|
credentialBackfill : CredentialBackfillStatus;
|
|
45
|
+
// one-off CIP-68 decimals fill of the asset catalogue (this process)
|
|
46
|
+
decimalsBackfill : DecimalsBackfillStatus;
|
|
61
47
|
// per-epoch pool/DRep/pot snapshots (crawler.epochSnapshots)
|
|
62
48
|
epochSnapshots : EpochSnapshotStatus;
|
|
63
49
|
}
|
|
@@ -119,6 +105,18 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
|
119
105
|
error : String;
|
|
120
106
|
}
|
|
121
107
|
|
|
108
|
+
@title : 'Decimals Backfill Status'
|
|
109
|
+
@description: 'Progress of the CIP-68 decimals fill started with backfillAssetDecimals; process-local, none after a restart'
|
|
110
|
+
type DecimalsBackfillStatus {
|
|
111
|
+
status : String; // none | running | done | failed
|
|
112
|
+
scanned : Integer64; // catalogue rows read
|
|
113
|
+
candidates : Integer64; // units with label 333 or 444
|
|
114
|
+
filled : Integer64; // units that received a decimals value
|
|
115
|
+
startedAt : Timestamp;
|
|
116
|
+
finishedAt : Timestamp;
|
|
117
|
+
error : String;
|
|
118
|
+
}
|
|
119
|
+
|
|
122
120
|
@title : 'Backfill Result'
|
|
123
121
|
type BackfillResult {
|
|
124
122
|
accepted : Boolean;
|
|
@@ -154,11 +152,7 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
|
154
152
|
|
|
155
153
|
@title : 'Get Crawler Status'
|
|
156
154
|
@description: 'Return the current crawler run state and sync progress'
|
|
157
|
-
/**
|
|
158
|
-
* Emitted AFTER each block is committed. Subscribe instead of polling:
|
|
159
|
-
* (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
|
|
160
|
-
* In-process (plugin mode) this needs no messaging service.
|
|
161
|
-
*/
|
|
155
|
+
/** Emitted after each block is committed. In plugin mode subscribing needs no messaging service. */
|
|
162
156
|
event blockIndexed {
|
|
163
157
|
hash : String(64);
|
|
164
158
|
slot : Integer64;
|
|
@@ -187,10 +181,8 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
|
187
181
|
network : String; // configured network
|
|
188
182
|
}
|
|
189
183
|
|
|
190
|
-
// Anonymous on purpose
|
|
191
|
-
//
|
|
192
|
-
// names, no API key state. Readiness stays with getStatus and the worker
|
|
193
|
-
// status, which remain authenticated.
|
|
184
|
+
// Anonymous on purpose, since a liveness probe carries no credentials.
|
|
185
|
+
// It probes no backend or DB and reveals no secrets. Readiness stays with the authenticated getStatus.
|
|
194
186
|
@title : 'Get Liveness'
|
|
195
187
|
@description: 'Unauthenticated liveness probe: 200 while the process answers. Docker HEALTHCHECK and upstream probes use this instead of the service document.'
|
|
196
188
|
@requires : 'any'
|
|
@@ -209,20 +201,26 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
|
|
|
209
201
|
@title : 'Import UTxO Set'
|
|
210
202
|
@description: 'One-off import of the UTxO set that anchors crawler.utxoSet. Pause the crawler first. source=ogmios acquires the set at the crawler cursor (crawl must be at the tip); source=file loads a cardano-cli query utxo --whole-utxo dump (.json, or .ndjson from jq -c to_entries[]) taken at anchorSlot/anchorHash. source=aggregates rebuilds only the sums (LedgerAddresses, LedgerAddressAssets, LedgerAccounts) from the rows an earlier import left, e.g. after its aggregate phase failed; a cursor past the anchor is set back to it. source=scripts fills the reference-script columns (utxo_referenceScriptHash, utxo_referenceScriptSize, utxo_referenceScriptType) of rows an earlier import left empty: from the same dump (filePath), or without filePath from Ogmios for the unspent rows that hold a hash but no size; the set stays active. Runs in the background; progress via getStatus().utxoSet and the log.'
|
|
211
203
|
@requires : 'Admin'
|
|
212
|
-
action importUtxoSet(source:
|
|
204
|
+
action importUtxoSet(@assert.range source: UtxoSetImportSource, filePath: String,
|
|
205
|
+
@assert.range: [0, _] anchorSlot: Integer64, anchorHash: String) returns UtxoSetImportResult;
|
|
213
206
|
|
|
214
207
|
@title : 'Backfill Certificates'
|
|
215
208
|
@description: 'Fill TransactionCertificates and TransactionWithdrawals for blocks the crawl already holds, from a second chain-sync stream (Ogmios). fromSlot defaults to the crawl start, toSlot to the cursor. Writes only those two tables; the crawler may keep running. Runs in the background; progress via getStatus().certificateBackfill.'
|
|
216
209
|
@requires : 'Admin'
|
|
217
|
-
action backfillCertificates(fromSlot: Integer64, toSlot: Integer64) returns CertificateBackfillResult;
|
|
210
|
+
action backfillCertificates(@assert.range: [0, _] fromSlot: Integer64, @assert.range: [0, _] toSlot: Integer64) returns CertificateBackfillResult;
|
|
218
211
|
|
|
219
212
|
@title : 'Backfill Transactions'
|
|
220
213
|
@description: 'Complete transactions the crawl already holds from a second chain-sync stream (Ogmios): input outpoints, the spent output datum and reference-script hash, missing input addresses, TransactionRedeemers and TransactionDatums. Fills empty fields only; a transaction whose stored inputs differ from the stream is skipped. fromSlot defaults to the crawl start, toSlot to the cursor; the crawler may keep running. Runs in the background; progress via getStatus().transactionBackfill.'
|
|
221
214
|
@requires : 'Admin'
|
|
222
|
-
action backfillTransactions(fromSlot: Integer64, toSlot: Integer64) returns CertificateBackfillResult;
|
|
215
|
+
action backfillTransactions(@assert.range: [0, _] fromSlot: Integer64, @assert.range: [0, _] toSlot: Integer64) returns CertificateBackfillResult;
|
|
223
216
|
|
|
224
217
|
@title : 'Backfill Payment Credentials'
|
|
225
218
|
@description: 'Fill utxo.paymentCredential on TransactionOutputs, TransactionInputs and LedgerUTxOs rows written before the column existed, decoded from the stored address. Walks each table once in key order; rows that carry a credential are left alone, so a second run is a no-op. No backend call; the crawler may keep running. Runs in the background; progress via getStatus().credentialBackfill.'
|
|
226
219
|
@requires : 'Admin'
|
|
227
220
|
action backfillPaymentCredentials() returns BackfillResult;
|
|
221
|
+
|
|
222
|
+
@title : 'Backfill Asset Decimals'
|
|
223
|
+
@description: 'Fill Assets.decimals from the CIP-68 reference datum for every catalogue unit with label 333 or 444: the reference NFT is followed from its mint through the crawled transactions to the output that holds it now, and the decimals of that datum are written to every slice of the unit. No backend call; the crawler may keep running; a repeat refreshes the values. Runs in the background; progress via getStatus().decimalsBackfill.'
|
|
224
|
+
@requires : 'Admin'
|
|
225
|
+
action backfillAssetDecimals() returns BackfillResult;
|
|
228
226
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SyncCursor } from './blockchain/crawler/sync-state';
|
|
2
|
+
/** No block committed for this long while the crawler holds its lease: it is stuck. */
|
|
3
|
+
export declare const CRAWLER_STALL_MS: number;
|
|
4
|
+
/** A crawler that holds the lease but has committed no block within CRAWLER_STALL_MS. */
|
|
5
|
+
export declare function isCrawlerStalled(cursor: SyncCursor | null, now?: number): boolean;
|
|
2
6
|
//# sourceMappingURL=cardano-indexer-service.d.ts.map
|
|
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CRAWLER_STALL_MS = void 0;
|
|
7
|
+
exports.isCrawlerStalled = isCrawlerStalled;
|
|
6
8
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
7
9
|
const backend_request_handler_1 = require("./utils/backend-request-handler");
|
|
8
10
|
const errors_1 = require("./utils/errors");
|
|
@@ -12,6 +14,7 @@ const utxo_set_import_1 = require("./blockchain/crawler/utxo-set-import");
|
|
|
12
14
|
const certificate_backfill_1 = require("./blockchain/crawler/certificate-backfill");
|
|
13
15
|
const transaction_backfill_1 = require("./blockchain/crawler/transaction-backfill");
|
|
14
16
|
const credential_backfill_1 = require("./blockchain/crawler/credential-backfill");
|
|
17
|
+
const asset_decimals_backfill_1 = require("./blockchain/crawler/asset-decimals-backfill");
|
|
15
18
|
const validators_1 = require("./utils/validators");
|
|
16
19
|
const server_1 = require("./server");
|
|
17
20
|
const liveness_1 = require("./utils/liveness");
|
|
@@ -34,17 +37,20 @@ let transactionBackfill = {
|
|
|
34
37
|
let credentialBackfill = {
|
|
35
38
|
status: 'none', table: null, outputs: 0, inputs: 0, ledgerUtxos: 0, startedAt: null, finishedAt: null, error: null,
|
|
36
39
|
};
|
|
40
|
+
let decimalsBackfill = {
|
|
41
|
+
status: 'none', scanned: 0, candidates: 0, filled: 0, startedAt: null, finishedAt: null, error: null,
|
|
42
|
+
};
|
|
37
43
|
/** Slot range of a backfill: defaults to crawl start .. cursor, never past the cursor. */
|
|
38
44
|
async function backfillRange(db, data) {
|
|
39
45
|
const cursor = await (0, sync_state_1.readCursor)(db);
|
|
40
46
|
if (!cursor)
|
|
41
|
-
throw new errors_1.TransactionValidationError('No crawler cursor yet
|
|
47
|
+
throw new errors_1.TransactionValidationError('No crawler cursor yet. The backfill covers crawled blocks only.');
|
|
42
48
|
const fromSlot = data.fromSlot != null ? Number(data.fromSlot) : (cursor.startSlot ?? 0);
|
|
43
49
|
const toSlot = data.toSlot != null ? Number(data.toSlot) : cursor.lastSlot;
|
|
44
50
|
if (toSlot < fromSlot)
|
|
45
51
|
throw new errors_1.TransactionValidationError(`toSlot ${toSlot} lies before fromSlot ${fromSlot}.`);
|
|
46
52
|
if (toSlot > cursor.lastSlot)
|
|
47
|
-
throw new errors_1.TransactionValidationError(`toSlot ${toSlot} is past the crawler cursor (slot ${cursor.lastSlot})
|
|
53
|
+
throw new errors_1.TransactionValidationError(`toSlot ${toSlot} is past the crawler cursor (slot ${cursor.lastSlot}). Only crawled blocks can be backfilled.`);
|
|
48
54
|
return { fromSlot, toSlot };
|
|
49
55
|
}
|
|
50
56
|
function utxoSetConfigured() {
|
|
@@ -75,14 +81,19 @@ function epochSnapshotSource() {
|
|
|
75
81
|
return null;
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
/** No block committed for this long while the crawler holds its lease: it is stuck. */
|
|
85
|
+
exports.CRAWLER_STALL_MS = 10 * 60 * 1000;
|
|
86
|
+
/** A crawler that holds the lease but has committed no block within CRAWLER_STALL_MS. */
|
|
87
|
+
function isCrawlerStalled(cursor, now = Date.now()) {
|
|
88
|
+
if (!cursor || !(0, sync_state_1.isCrawlerLeaseActive)(cursor) || !cursor.lastIndexedAt)
|
|
89
|
+
return false;
|
|
90
|
+
return now - Date.parse(cursor.lastIndexedAt) > exports.CRAWLER_STALL_MS;
|
|
91
|
+
}
|
|
92
|
+
/** CardanoIndexerService handlers. They read the crawler cursor and start or stop the crawler. */
|
|
82
93
|
module.exports = (srv) => {
|
|
83
|
-
// getLiveness
|
|
94
|
+
// getLiveness: unauthenticated probe. No handleRequest and no app context.
|
|
84
95
|
srv.on('getLiveness', async () => (0, liveness_1.buildLiveness)());
|
|
85
|
-
// getStatus
|
|
96
|
+
// getStatus: run state and sync progress. Numeric fields are strings, as CAP 10 serializes them.
|
|
86
97
|
srv.on('getStatus', async (req) => {
|
|
87
98
|
return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
|
|
88
99
|
const cursor = await (0, sync_state_1.readCursor)(db);
|
|
@@ -100,6 +111,8 @@ module.exports = (srv) => {
|
|
|
100
111
|
tipHeight: String(tipHeight),
|
|
101
112
|
syncProgress: progress.toFixed(2),
|
|
102
113
|
consecutiveErrors: cursor?.consecutiveErrors ?? 0,
|
|
114
|
+
lastIndexedAt: cursor?.lastIndexedAt ?? null,
|
|
115
|
+
stalled: isCrawlerStalled(cursor),
|
|
103
116
|
utxoSet: {
|
|
104
117
|
enabled: utxoSetConfigured(),
|
|
105
118
|
status: utxoSetImportInFlight ? 'importing' : (cursor?.utxoSet?.status ?? 'none'),
|
|
@@ -137,6 +150,7 @@ module.exports = (srv) => {
|
|
|
137
150
|
error: transactionBackfill.error,
|
|
138
151
|
},
|
|
139
152
|
credentialBackfill: { ...credentialBackfill },
|
|
153
|
+
decimalsBackfill: { ...decimalsBackfill },
|
|
140
154
|
epochSnapshots: {
|
|
141
155
|
enabled: epochSnapshotsConfigured(),
|
|
142
156
|
source: epochSnapshotSource(),
|
|
@@ -147,8 +161,8 @@ module.exports = (srv) => {
|
|
|
147
161
|
};
|
|
148
162
|
});
|
|
149
163
|
});
|
|
150
|
-
// backfillCertificates
|
|
151
|
-
// certificate and withdrawal tables
|
|
164
|
+
// backfillCertificates: a second chain-sync stream over crawled blocks.
|
|
165
|
+
// Writes only the certificate and withdrawal tables and runs detached.
|
|
152
166
|
srv.on('backfillCertificates', async (req) => {
|
|
153
167
|
const data = (req.data ?? {});
|
|
154
168
|
if (data.fromSlot != null && !Number.isInteger(Number(data.fromSlot)))
|
|
@@ -193,8 +207,8 @@ module.exports = (srv) => {
|
|
|
193
207
|
certificateBackfillStarting = false;
|
|
194
208
|
}
|
|
195
209
|
});
|
|
196
|
-
// backfillTransactions
|
|
197
|
-
// input fields
|
|
210
|
+
// backfillTransactions: a second chain-sync stream over crawled blocks.
|
|
211
|
+
// Fills empty input fields and the redeemers and runs detached.
|
|
198
212
|
srv.on('backfillTransactions', async (req) => {
|
|
199
213
|
const data = (req.data ?? {});
|
|
200
214
|
if (data.fromSlot != null && !Number.isInteger(Number(data.fromSlot)))
|
|
@@ -239,8 +253,8 @@ module.exports = (srv) => {
|
|
|
239
253
|
transactionBackfillStarting = false;
|
|
240
254
|
}
|
|
241
255
|
});
|
|
242
|
-
// backfillPaymentCredentials
|
|
243
|
-
//
|
|
256
|
+
// backfillPaymentCredentials: fills the credential from the stored address in every UTxO table.
|
|
257
|
+
// Needs no backend and runs detached. Progress is in getStatus().credentialBackfill.
|
|
244
258
|
srv.on('backfillPaymentCredentials', async (req) => {
|
|
245
259
|
if (credentialBackfill.status === 'running')
|
|
246
260
|
return (0, errors_1.rejectInvalid)(req, 'backfillPaymentCredentials', 'A payment-credential backfill is already running');
|
|
@@ -256,20 +270,37 @@ module.exports = (srv) => {
|
|
|
256
270
|
});
|
|
257
271
|
return { accepted: true, message: 'Payment-credential backfill started; poll getStatus().credentialBackfill.' };
|
|
258
272
|
});
|
|
259
|
-
//
|
|
260
|
-
// runs detached
|
|
273
|
+
// backfillAssetDecimals: reads the CIP-68 reference datum of every label 333 and 444 unit.
|
|
274
|
+
// Needs no backend and runs detached. Progress is in getStatus().decimalsBackfill.
|
|
275
|
+
srv.on('backfillAssetDecimals', async (req) => {
|
|
276
|
+
if (decimalsBackfill.status === 'running')
|
|
277
|
+
return (0, errors_1.rejectInvalid)(req, 'backfillAssetDecimals', 'An asset-decimals backfill is already running');
|
|
278
|
+
decimalsBackfill = { status: 'running', scanned: 0, candidates: 0, filled: 0, startedAt: new Date().toISOString(), finishedAt: null, error: null };
|
|
279
|
+
void (0, asset_decimals_backfill_1.backfillAssetDecimals)({
|
|
280
|
+
onProgress: (p) => { Object.assign(decimalsBackfill, p); },
|
|
281
|
+
})
|
|
282
|
+
.then((r) => { Object.assign(decimalsBackfill, r, { status: 'done', finishedAt: new Date().toISOString() }); })
|
|
283
|
+
.catch((err) => {
|
|
284
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
285
|
+
Object.assign(decimalsBackfill, { status: 'failed', finishedAt: new Date().toISOString(), error: message.slice(0, 500) });
|
|
286
|
+
logger.error(`Asset-decimals backfill failed: ${message}`);
|
|
287
|
+
});
|
|
288
|
+
return { accepted: true, message: 'Asset-decimals backfill started; poll getStatus().decimalsBackfill.' };
|
|
289
|
+
});
|
|
290
|
+
// importUtxoSet: one-off snapshot import that anchors crawler.utxoSet.
|
|
291
|
+
// Runs detached. Progress is in getStatus().utxoSet.
|
|
261
292
|
srv.on('importUtxoSet', async (req) => {
|
|
262
293
|
const data = (req.data ?? {});
|
|
263
294
|
if (data.source === 'aggregates') {
|
|
264
295
|
if ((0, crawler_1.isCrawlerRunning)())
|
|
265
|
-
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process
|
|
296
|
+
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process. Run pauseCrawler first');
|
|
266
297
|
if (utxoSetImportInFlight)
|
|
267
298
|
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'A UTxO set import is already running');
|
|
268
299
|
return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
|
|
269
300
|
const cursor = await (0, sync_state_1.readCursor)(db);
|
|
270
301
|
const { anchorSlot, anchorHash } = cursor?.utxoSet ?? {};
|
|
271
302
|
if (anchorSlot == null || !anchorHash)
|
|
272
|
-
throw new errors_1.TransactionValidationError('No imported UTxO set to rebuild the sums from
|
|
303
|
+
throw new errors_1.TransactionValidationError('No imported UTxO set to rebuild the sums from. Run importUtxoSet first.');
|
|
273
304
|
utxoSetImportInFlight = (0, utxo_set_import_1.rebuildUtxoSetAggregates)({ indexer: (0, server_1.getCardanoIndexer)() })
|
|
274
305
|
.then((r) => logger.info(`UTxO set sums rebuilt: ${r.utxos} rows at ${r.anchor.slot}/${r.anchor.hash}`))
|
|
275
306
|
.catch((err) => logger.error(`UTxO set aggregate rebuild failed: ${err instanceof Error ? err.message : String(err)}`))
|
|
@@ -284,14 +315,14 @@ module.exports = (srv) => {
|
|
|
284
315
|
}
|
|
285
316
|
if (data.source === 'scripts') {
|
|
286
317
|
if ((0, crawler_1.isCrawlerRunning)())
|
|
287
|
-
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process
|
|
318
|
+
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process. Run pauseCrawler first');
|
|
288
319
|
if (utxoSetImportInFlight)
|
|
289
320
|
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'A UTxO set import is already running');
|
|
290
321
|
return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
|
|
291
322
|
const cursor = await (0, sync_state_1.readCursor)(db);
|
|
292
323
|
const { anchorSlot, anchorHash } = cursor?.utxoSet ?? {};
|
|
293
324
|
if (anchorSlot == null || !anchorHash)
|
|
294
|
-
throw new errors_1.TransactionValidationError('No imported UTxO set to fill
|
|
325
|
+
throw new errors_1.TransactionValidationError('No imported UTxO set to fill. Run importUtxoSet first.');
|
|
295
326
|
utxoSetImportInFlight = (0, utxo_set_import_1.refreshUtxoSetReferenceScripts)({ filePath: data.filePath, client: (0, server_1.getCardanoClient)() })
|
|
296
327
|
.then((r) => logger.info(`UTxO set reference scripts filled: ${r.updated} of ${r.candidates} rows`))
|
|
297
328
|
.catch((err) => logger.error(`UTxO set reference-script fill failed: ${err instanceof Error ? err.message : String(err)}`))
|
|
@@ -304,9 +335,10 @@ module.exports = (srv) => {
|
|
|
304
335
|
};
|
|
305
336
|
});
|
|
306
337
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
338
|
+
// the model rejects an unknown source and a negative anchorSlot
|
|
339
|
+
const source = data.source;
|
|
340
|
+
if (source !== 'file' && source !== 'ogmios')
|
|
341
|
+
return (0, errors_1.rejectMissing)(req, 'importUtxoSet', 'source');
|
|
310
342
|
if (source === 'file' && !data.filePath)
|
|
311
343
|
return (0, errors_1.rejectMissing)(req, 'importUtxoSet', 'filePath');
|
|
312
344
|
const anchorGiven = data.anchorSlot != null || !!data.anchorHash;
|
|
@@ -317,22 +349,22 @@ module.exports = (srv) => {
|
|
|
317
349
|
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'anchorSlot must be an integer and anchorHash a 64-hex block hash', 'anchorHash');
|
|
318
350
|
}
|
|
319
351
|
if ((0, crawler_1.isCrawlerRunning)())
|
|
320
|
-
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process
|
|
352
|
+
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process. Run pauseCrawler first');
|
|
321
353
|
if (utxoSetImportInFlight)
|
|
322
354
|
return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'A UTxO set import is already running');
|
|
323
355
|
return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
|
|
324
356
|
const cursor = await (0, sync_state_1.readCursor)(db);
|
|
325
357
|
if (!cursor)
|
|
326
|
-
throw new errors_1.TransactionValidationError('No crawler cursor yet
|
|
358
|
+
throw new errors_1.TransactionValidationError('No crawler cursor yet. Start the crawler once before importing.');
|
|
327
359
|
if ((0, sync_state_1.isCrawlerLeaseActive)(cursor))
|
|
328
|
-
throw new errors_1.TransactionValidationError('Crawler is running (active lease)
|
|
360
|
+
throw new errors_1.TransactionValidationError('Crawler is running (active lease). Run pauseCrawler first.');
|
|
329
361
|
const anchor = anchorGiven
|
|
330
362
|
? { slot: Number(data.anchorSlot), hash: String(data.anchorHash).toLowerCase() }
|
|
331
363
|
: { slot: cursor.lastSlot, hash: cursor.lastBlockHash ?? '' };
|
|
332
364
|
if (!anchor.hash)
|
|
333
|
-
throw new errors_1.TransactionValidationError('Cursor has no block hash yet
|
|
365
|
+
throw new errors_1.TransactionValidationError('Cursor has no block hash yet. Pass anchorSlot + anchorHash.');
|
|
334
366
|
if (cursor.lastSlot > anchor.slot) {
|
|
335
|
-
throw new errors_1.TransactionValidationError(`Crawler cursor (slot ${cursor.lastSlot}) is past the anchor (slot ${anchor.slot})
|
|
367
|
+
throw new errors_1.TransactionValidationError(`Crawler cursor (slot ${cursor.lastSlot}) is past the anchor (slot ${anchor.slot}). Dump the set at or after the cursor.`);
|
|
336
368
|
}
|
|
337
369
|
utxoSetImportInFlight = (0, utxo_set_import_1.importUtxoSet)({
|
|
338
370
|
source, filePath: data.filePath, anchor,
|
|
@@ -351,7 +383,7 @@ module.exports = (srv) => {
|
|
|
351
383
|
};
|
|
352
384
|
});
|
|
353
385
|
});
|
|
354
|
-
// pauseCrawler
|
|
386
|
+
// pauseCrawler: stops the stream. The cursor is kept, so resume continues from it.
|
|
355
387
|
srv.on('pauseCrawler', async (req) => {
|
|
356
388
|
return (0, backend_request_handler_1.handleRequest)(req, async () => {
|
|
357
389
|
await (0, crawler_1.stopCrawler)(true);
|
|
@@ -359,9 +391,8 @@ module.exports = (srv) => {
|
|
|
359
391
|
return true;
|
|
360
392
|
});
|
|
361
393
|
});
|
|
362
|
-
// resumeCrawler
|
|
363
|
-
//
|
|
364
|
-
// crawler is a no-op; pauseCrawler first to apply changed config.
|
|
394
|
+
// resumeCrawler: starts from the stored cursor, only when enabled, since otherwise it would sync from genesis.
|
|
395
|
+
// A no-op on a running crawler. Pause first to apply changed config.
|
|
365
396
|
srv.on('resumeCrawler', async (req) => {
|
|
366
397
|
let config;
|
|
367
398
|
try {
|
|
@@ -372,7 +403,7 @@ module.exports = (srv) => {
|
|
|
372
403
|
return (0, errors_1.rejectInvalid)(req, 'resumeCrawler', err instanceof Error ? err.message : String(err));
|
|
373
404
|
}
|
|
374
405
|
if (!config.enabled) {
|
|
375
|
-
return (0, errors_1.rejectInvalid)(req, 'resumeCrawler', 'Crawler is not enabled
|
|
406
|
+
return (0, errors_1.rejectInvalid)(req, 'resumeCrawler', 'Crawler is not enabled. Set cds.requires.odatano-core.crawler.enabled (or CRAWLER_ENABLED=true) with a start block before resuming.');
|
|
376
407
|
}
|
|
377
408
|
return (0, backend_request_handler_1.handleRequest)(req, async () => {
|
|
378
409
|
const client = (0, server_1.getCardanoClient)();
|