@eclesia/indexer-engine 2.5.11 → 2.5.13
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/dist/indexer/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuC,WAAW,EAA4B,MAAM,wBAAwB,CAAC;AAkBpH,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAc,oBAAoB,EAAE,QAAQ,EAAqB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI5G,eAAO,MAAM,oBAAoB;;;;;cAKX,oBAAoB,CAAC,UAAU,CAAC;;;;;;;8BAO1B,OAAO;CAClC,CAAC;AAEF,qBAAa,cAAe,SAAQ,cAAc;IAChD,OAAO,CAAC,MAAM,CAAuB;IAErC,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,eAAe,CAAU;IAEjC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,UAAU,CAAK;IAEhB,MAAM,EAAG,WAAW,CAAC;IAErB,WAAW,EAAG,WAAW,CAAC;IAE1B,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC;IAE3B,OAAO,CAAC,SAAS,CAAiC;IAElD,OAAO,CAAC,WAAW,CAEjB;IAEF,OAAO,CAAC,YAAY,CAA6D;gBAErE,MAAM,EAAE,oBAAoB;IAyDxC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,aAAa,CAInB;IAEF,OAAO,CAAC,SAAS;IAQJ,OAAO;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuC,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AC,WAAW;YAQL,cAAc;YAyBd,cAAc;YAuBd,YAAY;CAiD3B"}
|
package/dist/indexer/index.js
CHANGED
|
@@ -42,6 +42,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
42
42
|
super();
|
|
43
43
|
this.initialized = false;
|
|
44
44
|
this.retryCount = 0;
|
|
45
|
+
this.rpcOk = true;
|
|
45
46
|
this.debugTime = null;
|
|
46
47
|
this.healthCheck = {
|
|
47
48
|
status: "CONNECTING"
|
|
@@ -157,10 +158,12 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
157
158
|
this.log.info("Connected to RPC for ad hoc queries");
|
|
158
159
|
this.blockClient = await (0, tendermint_rpc_2.connectComet)(this.config.rpcUrl);
|
|
159
160
|
this.log.info("Connected to RPC for block & validator info");
|
|
161
|
+
this.rpcOk = true;
|
|
160
162
|
return true;
|
|
161
163
|
}
|
|
162
164
|
catch (error) {
|
|
163
165
|
this.log.error(error);
|
|
166
|
+
this.rpcOk = false;
|
|
164
167
|
return false;
|
|
165
168
|
}
|
|
166
169
|
}
|
|
@@ -216,6 +219,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
216
219
|
throw e;
|
|
217
220
|
}
|
|
218
221
|
this.fetcher().catch((e) => {
|
|
222
|
+
this.setStatus("FAILED");
|
|
219
223
|
throw new Error("Error in fetching service: " + e);
|
|
220
224
|
});
|
|
221
225
|
const hrTime = process.hrtime();
|
|
@@ -223,6 +227,9 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
223
227
|
while (this.blockQueue.size() > 0) {
|
|
224
228
|
// await the dequeued promise is essentially awaiting fetched data for that block
|
|
225
229
|
try {
|
|
230
|
+
if (!this.rpcOk) {
|
|
231
|
+
throw new Error("RPC not responding");
|
|
232
|
+
}
|
|
226
233
|
// Index block inside a db transaction to ensure data consistency
|
|
227
234
|
await this.config.beginTransaction();
|
|
228
235
|
this.log.silly("Started db tx");
|
|
@@ -426,29 +433,40 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
426
433
|
this.log.debug("Fetching: " + i);
|
|
427
434
|
try {
|
|
428
435
|
if (this.isMinimal(this.blockQueue)) {
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
436
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
437
|
+
setTimeout(reject, 20000, false);
|
|
438
|
+
});
|
|
439
|
+
const toIndex = Promise.race([Promise.all([
|
|
440
|
+
this.blockClient.block(i),
|
|
441
|
+
this.blockClient.blockResults(i)
|
|
442
|
+
]), timeoutPromise]).catch((e) => {
|
|
433
443
|
this.log.error("Error fetching block: " + i + " : " + e);
|
|
444
|
+
this.rpcOk = false;
|
|
434
445
|
return Promise.resolve([]);
|
|
435
446
|
});
|
|
436
447
|
this.blockQueue.enqueue(toIndex);
|
|
437
448
|
}
|
|
438
449
|
else {
|
|
450
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
451
|
+
setTimeout(reject, 20000, false);
|
|
452
|
+
});
|
|
439
453
|
const q = query_1.QueryValidatorsRequest.fromPartial({ pagination: { limit: 1000n } });
|
|
440
454
|
const vals = query_1.QueryValidatorsRequest.encode(q).finish();
|
|
441
|
-
const toIndex = Promise.all([
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
455
|
+
const toIndex = Promise.race([Promise.all([
|
|
456
|
+
this.blockClient.block(i),
|
|
457
|
+
this.blockClient.blockResults(i),
|
|
458
|
+
this.callABCI("/cosmos.staking.v1beta1.Query/Validators", vals, i, false)
|
|
459
|
+
]), timeoutPromise]).catch((e) => {
|
|
446
460
|
this.log.error("Error fetching block: " + i + " : " + e);
|
|
461
|
+
this.rpcOk = false;
|
|
447
462
|
return Promise.resolve([]);
|
|
448
463
|
});
|
|
449
464
|
this.blockQueue.enqueue(toIndex);
|
|
450
465
|
}
|
|
451
466
|
await this.blockQueue.continue();
|
|
467
|
+
if (!this.rpcOk) {
|
|
468
|
+
throw new Error("RPC not responding");
|
|
469
|
+
}
|
|
452
470
|
}
|
|
453
471
|
catch (e) {
|
|
454
472
|
this.log.error(e);
|
|
@@ -472,11 +490,13 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
472
490
|
return abciq.value;
|
|
473
491
|
}
|
|
474
492
|
else {
|
|
493
|
+
this.rpcOk = false;
|
|
475
494
|
this.setStatus("FAILED");
|
|
476
495
|
throw new Error("RPC not responding. Query at: " + path);
|
|
477
496
|
}
|
|
478
497
|
}
|
|
479
498
|
catch (_e) {
|
|
499
|
+
this.rpcOk = false;
|
|
480
500
|
this.setStatus("FAILED");
|
|
481
501
|
throw new Error("RPC not responding. Query at: " + path);
|
|
482
502
|
}
|