@eclesia/indexer-engine 2.5.12 → 2.5.14
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
|
}
|
|
@@ -190,9 +193,10 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
190
193
|
}
|
|
191
194
|
this.initialized = true;
|
|
192
195
|
}
|
|
193
|
-
this.subscription =
|
|
196
|
+
this.subscription = null;
|
|
194
197
|
try {
|
|
195
198
|
await this.connect();
|
|
199
|
+
this.subscription = this.client.subscribeNewBlock ? this.client.subscribeNewBlock() : null;
|
|
196
200
|
const status = await this.client.status();
|
|
197
201
|
this.latestHeight = status.syncInfo.latestBlockHeight;
|
|
198
202
|
this.blockQueue.clear();
|
|
@@ -224,6 +228,9 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
224
228
|
while (this.blockQueue.size() > 0) {
|
|
225
229
|
// await the dequeued promise is essentially awaiting fetched data for that block
|
|
226
230
|
try {
|
|
231
|
+
if (!this.rpcOk) {
|
|
232
|
+
throw new Error("RPC not responding");
|
|
233
|
+
}
|
|
227
234
|
// Index block inside a db transaction to ensure data consistency
|
|
228
235
|
await this.config.beginTransaction();
|
|
229
236
|
this.log.silly("Started db tx");
|
|
@@ -433,7 +440,11 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
433
440
|
const toIndex = Promise.race([Promise.all([
|
|
434
441
|
this.blockClient.block(i),
|
|
435
442
|
this.blockClient.blockResults(i)
|
|
436
|
-
]), timeoutPromise])
|
|
443
|
+
]), timeoutPromise]).catch((e) => {
|
|
444
|
+
this.log.error("Error fetching block: " + i + " : " + e);
|
|
445
|
+
this.rpcOk = false;
|
|
446
|
+
return Promise.resolve([]);
|
|
447
|
+
});
|
|
437
448
|
this.blockQueue.enqueue(toIndex);
|
|
438
449
|
}
|
|
439
450
|
else {
|
|
@@ -446,10 +457,17 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
446
457
|
this.blockClient.block(i),
|
|
447
458
|
this.blockClient.blockResults(i),
|
|
448
459
|
this.callABCI("/cosmos.staking.v1beta1.Query/Validators", vals, i, false)
|
|
449
|
-
]), timeoutPromise])
|
|
460
|
+
]), timeoutPromise]).catch((e) => {
|
|
461
|
+
this.log.error("Error fetching block: " + i + " : " + e);
|
|
462
|
+
this.rpcOk = false;
|
|
463
|
+
return Promise.resolve([]);
|
|
464
|
+
});
|
|
450
465
|
this.blockQueue.enqueue(toIndex);
|
|
451
466
|
}
|
|
452
467
|
await this.blockQueue.continue();
|
|
468
|
+
if (!this.rpcOk) {
|
|
469
|
+
throw new Error("RPC not responding");
|
|
470
|
+
}
|
|
453
471
|
}
|
|
454
472
|
catch (e) {
|
|
455
473
|
this.log.error(e);
|
|
@@ -473,11 +491,13 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
|
|
|
473
491
|
return abciq.value;
|
|
474
492
|
}
|
|
475
493
|
else {
|
|
494
|
+
this.rpcOk = false;
|
|
476
495
|
this.setStatus("FAILED");
|
|
477
496
|
throw new Error("RPC not responding. Query at: " + path);
|
|
478
497
|
}
|
|
479
498
|
}
|
|
480
499
|
catch (_e) {
|
|
500
|
+
this.rpcOk = false;
|
|
481
501
|
this.setStatus("FAILED");
|
|
482
502
|
throw new Error("RPC not responding. Query at: " + path);
|
|
483
503
|
}
|