@eclesia/indexer-engine 2.12.0 → 2.14.0

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.
@@ -27,6 +27,11 @@ const DEFAULT_PROMETHEUS_PORT = 9090;
27
27
  */
28
28
  const DEFAULT_POLLING_INTERVAL_MS = 5e3;
29
29
  /**
30
+ * Timeout for connecting to the Tendermint RPC in milliseconds
31
+ * If connection is not established within this time, it will be aborted
32
+ */
33
+ const CONNECT_TIMEOUT_MS = 1e4;
34
+ /**
30
35
  * Timeout for RPC calls in milliseconds
31
36
  * If a call takes longer than this, it will be rejected
32
37
  */
@@ -64,6 +69,7 @@ const PAGINATION_LIMITS = {
64
69
  const GENESIS_BATCH_SIZE = 1e3;
65
70
 
66
71
  //#endregion
72
+ exports.CONNECT_TIMEOUT_MS = CONNECT_TIMEOUT_MS;
67
73
  exports.DB_CLIENT_RECYCLE_COUNT = DB_CLIENT_RECYCLE_COUNT;
68
74
  exports.DEFAULT_BATCH_SIZE = DEFAULT_BATCH_SIZE;
69
75
  exports.DEFAULT_HEALTH_CHECK_PORT = DEFAULT_HEALTH_CHECK_PORT;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Configuration constants for the Eclesia indexer\n * These values control performance, timeouts, and connection management\n */\n\n/**\n * Number of blocks to prefetch and keep in the processing queue\n * Higher values increase memory usage but improve throughput\n * Recommended range: 300-1000 depending on block size and available memory\n */\nexport const DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Default start height for indexing when no previous height is found\n */\nexport const DEFAULT_START_HEIGHT = 1;\n\n/**\n * Default port for health check HTTP server\n */\nexport const DEFAULT_HEALTH_CHECK_PORT = 8888;\n\n/**\n * Default port for Prometheus metrics server\n */\nexport const DEFAULT_PROMETHEUS_PORT = 9090;\n\n/**\n * Default polling interval in milliseconds when using polling mode instead of WebSocket\n */\nexport const DEFAULT_POLLING_INTERVAL_MS = 5000;\n\n/**\n * Timeout for RPC calls in milliseconds\n * If a call takes longer than this, it will be rejected\n */\nexport const RPC_TIMEOUT_MS = 20000;\n\n/**\n * Timeout for block queue dequeue operations in milliseconds\n * If no block is available within this time, an error will be thrown\n */\nexport const QUEUE_DEQUEUE_TIMEOUT_MS = 30000;\n\n/**\n * Number of successful transactions before recycling the database client\n * Prevents long-running connection issues and stale connections\n */\nexport const DB_CLIENT_RECYCLE_COUNT = 1500;\n\n/**\n * Block intervals for periodic event emission\n * Used for operations that should run at regular block intervals\n */\nexport const PERIODIC_INTERVALS = {\n /** Emit periodic event every 50 blocks */\n SMALL: 50,\n /** Emit periodic event every 100 blocks */\n MEDIUM: 100,\n /** Emit periodic event every 1000 blocks - used for performance logging */\n LARGE: 1000,\n} as const;\n\n/**\n * Pagination limits for blockchain queries\n */\nexport const PAGINATION_LIMITS = {\n /** Default limit for validator queries */\n VALIDATORS: 1000n,\n /** Default limit for delegation queries */\n DELEGATIONS: 250n,\n} as const;\n\n/**\n * Batch size for streaming genesis file processing\n * Number of entries to process at once from genesis JSON\n */\nexport const GENESIS_BATCH_SIZE = 1000;\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,qBAAqB;;;;AAKlC,MAAa,uBAAuB;;;;AAKpC,MAAa,4BAA4B;;;;AAKzC,MAAa,0BAA0B;;;;AAKvC,MAAa,8BAA8B;;;;;AAM3C,MAAa,iBAAiB;;;;;AAM9B,MAAa,2BAA2B;;;;;AAMxC,MAAa,0BAA0B;;;;;AAMvC,MAAa,qBAAqB;CAEhC,OAAO;CAEP,QAAQ;CAER,OAAO;CACR;;;;AAKD,MAAa,oBAAoB;CAE/B,YAAY;CAEZ,aAAa;CACd;;;;;AAMD,MAAa,qBAAqB"}
1
+ {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Configuration constants for the Eclesia indexer\n * These values control performance, timeouts, and connection management\n */\n\n/**\n * Number of blocks to prefetch and keep in the processing queue\n * Higher values increase memory usage but improve throughput\n * Recommended range: 300-1000 depending on block size and available memory\n */\nexport const DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Default start height for indexing when no previous height is found\n */\nexport const DEFAULT_START_HEIGHT = 1;\n\n/**\n * Default port for health check HTTP server\n */\nexport const DEFAULT_HEALTH_CHECK_PORT = 8888;\n\n/**\n * Default port for Prometheus metrics server\n */\nexport const DEFAULT_PROMETHEUS_PORT = 9090;\n\n/**\n * Default polling interval in milliseconds when using polling mode instead of WebSocket\n */\nexport const DEFAULT_POLLING_INTERVAL_MS = 5000;\n\n/**\n * Timeout for connecting to the Tendermint RPC in milliseconds\n * If connection is not established within this time, it will be aborted\n */\nexport const CONNECT_TIMEOUT_MS = 10000;\n\n/**\n * Timeout for RPC calls in milliseconds\n * If a call takes longer than this, it will be rejected\n */\nexport const RPC_TIMEOUT_MS = 20000;\n\n/**\n * Timeout for block queue dequeue operations in milliseconds\n * If no block is available within this time, an error will be thrown\n */\nexport const QUEUE_DEQUEUE_TIMEOUT_MS = 30000;\n\n/**\n * Number of successful transactions before recycling the database client\n * Prevents long-running connection issues and stale connections\n */\nexport const DB_CLIENT_RECYCLE_COUNT = 1500;\n\n/**\n * Block intervals for periodic event emission\n * Used for operations that should run at regular block intervals\n */\nexport const PERIODIC_INTERVALS = {\n /** Emit periodic event every 50 blocks */\n SMALL: 50,\n /** Emit periodic event every 100 blocks */\n MEDIUM: 100,\n /** Emit periodic event every 1000 blocks - used for performance logging */\n LARGE: 1000,\n} as const;\n\n/**\n * Pagination limits for blockchain queries\n */\nexport const PAGINATION_LIMITS = {\n /** Default limit for validator queries */\n VALIDATORS: 1000n,\n /** Default limit for delegation queries */\n DELEGATIONS: 250n,\n} as const;\n\n/**\n * Batch size for streaming genesis file processing\n * Number of entries to process at once from genesis JSON\n */\nexport const GENESIS_BATCH_SIZE = 1000;\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,qBAAqB;;;;AAKlC,MAAa,uBAAuB;;;;AAKpC,MAAa,4BAA4B;;;;AAKzC,MAAa,0BAA0B;;;;AAKvC,MAAa,8BAA8B;;;;;AAM3C,MAAa,qBAAqB;;;;;AAMlC,MAAa,iBAAiB;;;;;AAM9B,MAAa,2BAA2B;;;;;AAMxC,MAAa,0BAA0B;;;;;AAMvC,MAAa,qBAAqB;CAEhC,OAAO;CAEP,QAAQ;CAER,OAAO;CACR;;;;AAKD,MAAa,oBAAoB;CAE/B,YAAY;CAEZ,aAAa;CACd;;;;;AAMD,MAAa,qBAAqB"}
@@ -25,6 +25,11 @@ declare const DEFAULT_PROMETHEUS_PORT = 9090;
25
25
  * Default polling interval in milliseconds when using polling mode instead of WebSocket
26
26
  */
27
27
  declare const DEFAULT_POLLING_INTERVAL_MS = 5000;
28
+ /**
29
+ * Timeout for connecting to the Tendermint RPC in milliseconds
30
+ * If connection is not established within this time, it will be aborted
31
+ */
32
+ declare const CONNECT_TIMEOUT_MS = 10000;
28
33
  /**
29
34
  * Timeout for RPC calls in milliseconds
30
35
  * If a call takes longer than this, it will be rejected
@@ -67,5 +72,5 @@ declare const PAGINATION_LIMITS: {
67
72
  */
68
73
  declare const GENESIS_BATCH_SIZE = 1000;
69
74
  //#endregion
70
- export { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS };
75
+ export { CONNECT_TIMEOUT_MS, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS };
71
76
  //# sourceMappingURL=constants.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","names":[],"sources":["../src/constants.ts"],"sourcesContent":[],"mappings":";;AAUA;AAKA;AAKA;AAKA;AAKA;AAMA;AAMA;AAMA;AAMa,cA5CA,kBAAA,GAmDH,GAAA;AAKV;AAWA;;cA9Da,oBAAA;;;;cAKA,yBAAA;;;;cAKA,uBAAA;;;;cAKA,2BAAA;;;;;cAMA,cAAA;;;;;cAMA,wBAAA;;;;;cAMA,uBAAA;;;;;cAMA;;;;;;;;;;;cAYA;;;;;;;;;;cAWA,kBAAA"}
1
+ {"version":3,"file":"constants.d.cts","names":[],"sources":["../src/constants.ts"],"sourcesContent":[],"mappings":";;AAUA;AAKA;AAKA;AAKA;AAKA;AAMA;AAMA;AAMA;AAMa,cA5CA,kBAAA,GA4CuB,GAAA;AAMpC;AAYA;AAWA;cApEa,oBAAA;;;;cAKA,yBAAA;;;;cAKA,uBAAA;;;;cAKA,2BAAA;;;;;cAMA,kBAAA;;;;;cAMA,cAAA;;;;;cAMA,wBAAA;;;;;cAMA,uBAAA;;;;;cAMA;;;;;;;;;;;cAYA;;;;;;;;;;cAWA,kBAAA"}
@@ -25,6 +25,11 @@ declare const DEFAULT_PROMETHEUS_PORT = 9090;
25
25
  * Default polling interval in milliseconds when using polling mode instead of WebSocket
26
26
  */
27
27
  declare const DEFAULT_POLLING_INTERVAL_MS = 5000;
28
+ /**
29
+ * Timeout for connecting to the Tendermint RPC in milliseconds
30
+ * If connection is not established within this time, it will be aborted
31
+ */
32
+ declare const CONNECT_TIMEOUT_MS = 10000;
28
33
  /**
29
34
  * Timeout for RPC calls in milliseconds
30
35
  * If a call takes longer than this, it will be rejected
@@ -67,5 +72,5 @@ declare const PAGINATION_LIMITS: {
67
72
  */
68
73
  declare const GENESIS_BATCH_SIZE = 1000;
69
74
  //#endregion
70
- export { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS };
75
+ export { CONNECT_TIMEOUT_MS, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS };
71
76
  //# sourceMappingURL=constants.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"sourcesContent":[],"mappings":";;AAUA;AAKA;AAKA;AAKA;AAKA;AAMA;AAMA;AAMA;AAMa,cA5CA,kBAAA,GAmDH,GAAA;AAKV;AAWA;;cA9Da,oBAAA;;;;cAKA,yBAAA;;;;cAKA,uBAAA;;;;cAKA,2BAAA;;;;;cAMA,cAAA;;;;;cAMA,wBAAA;;;;;cAMA,uBAAA;;;;;cAMA;;;;;;;;;;;cAYA;;;;;;;;;;cAWA,kBAAA"}
1
+ {"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"sourcesContent":[],"mappings":";;AAUA;AAKA;AAKA;AAKA;AAKA;AAMA;AAMA;AAMA;AAMa,cA5CA,kBAAA,GA4CuB,GAAA;AAMpC;AAYA;AAWA;cApEa,oBAAA;;;;cAKA,yBAAA;;;;cAKA,uBAAA;;;;cAKA,2BAAA;;;;;cAMA,kBAAA;;;;;cAMA,cAAA;;;;;cAMA,wBAAA;;;;;cAMA,uBAAA;;;;;cAMA;;;;;;;;;;;cAYA;;;;;;;;;;cAWA,kBAAA"}
@@ -26,6 +26,11 @@ const DEFAULT_PROMETHEUS_PORT = 9090;
26
26
  */
27
27
  const DEFAULT_POLLING_INTERVAL_MS = 5e3;
28
28
  /**
29
+ * Timeout for connecting to the Tendermint RPC in milliseconds
30
+ * If connection is not established within this time, it will be aborted
31
+ */
32
+ const CONNECT_TIMEOUT_MS = 1e4;
33
+ /**
29
34
  * Timeout for RPC calls in milliseconds
30
35
  * If a call takes longer than this, it will be rejected
31
36
  */
@@ -63,5 +68,5 @@ const PAGINATION_LIMITS = {
63
68
  const GENESIS_BATCH_SIZE = 1e3;
64
69
 
65
70
  //#endregion
66
- export { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS };
71
+ export { CONNECT_TIMEOUT_MS, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS };
67
72
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Configuration constants for the Eclesia indexer\n * These values control performance, timeouts, and connection management\n */\n\n/**\n * Number of blocks to prefetch and keep in the processing queue\n * Higher values increase memory usage but improve throughput\n * Recommended range: 300-1000 depending on block size and available memory\n */\nexport const DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Default start height for indexing when no previous height is found\n */\nexport const DEFAULT_START_HEIGHT = 1;\n\n/**\n * Default port for health check HTTP server\n */\nexport const DEFAULT_HEALTH_CHECK_PORT = 8888;\n\n/**\n * Default port for Prometheus metrics server\n */\nexport const DEFAULT_PROMETHEUS_PORT = 9090;\n\n/**\n * Default polling interval in milliseconds when using polling mode instead of WebSocket\n */\nexport const DEFAULT_POLLING_INTERVAL_MS = 5000;\n\n/**\n * Timeout for RPC calls in milliseconds\n * If a call takes longer than this, it will be rejected\n */\nexport const RPC_TIMEOUT_MS = 20000;\n\n/**\n * Timeout for block queue dequeue operations in milliseconds\n * If no block is available within this time, an error will be thrown\n */\nexport const QUEUE_DEQUEUE_TIMEOUT_MS = 30000;\n\n/**\n * Number of successful transactions before recycling the database client\n * Prevents long-running connection issues and stale connections\n */\nexport const DB_CLIENT_RECYCLE_COUNT = 1500;\n\n/**\n * Block intervals for periodic event emission\n * Used for operations that should run at regular block intervals\n */\nexport const PERIODIC_INTERVALS = {\n /** Emit periodic event every 50 blocks */\n SMALL: 50,\n /** Emit periodic event every 100 blocks */\n MEDIUM: 100,\n /** Emit periodic event every 1000 blocks - used for performance logging */\n LARGE: 1000,\n} as const;\n\n/**\n * Pagination limits for blockchain queries\n */\nexport const PAGINATION_LIMITS = {\n /** Default limit for validator queries */\n VALIDATORS: 1000n,\n /** Default limit for delegation queries */\n DELEGATIONS: 250n,\n} as const;\n\n/**\n * Batch size for streaming genesis file processing\n * Number of entries to process at once from genesis JSON\n */\nexport const GENESIS_BATCH_SIZE = 1000;\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qBAAqB;;;;AAKlC,MAAa,uBAAuB;;;;AAKpC,MAAa,4BAA4B;;;;AAKzC,MAAa,0BAA0B;;;;AAKvC,MAAa,8BAA8B;;;;;AAM3C,MAAa,iBAAiB;;;;;AAM9B,MAAa,2BAA2B;;;;;AAMxC,MAAa,0BAA0B;;;;;AAMvC,MAAa,qBAAqB;CAEhC,OAAO;CAEP,QAAQ;CAER,OAAO;CACR;;;;AAKD,MAAa,oBAAoB;CAE/B,YAAY;CAEZ,aAAa;CACd;;;;;AAMD,MAAa,qBAAqB"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Configuration constants for the Eclesia indexer\n * These values control performance, timeouts, and connection management\n */\n\n/**\n * Number of blocks to prefetch and keep in the processing queue\n * Higher values increase memory usage but improve throughput\n * Recommended range: 300-1000 depending on block size and available memory\n */\nexport const DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Default start height for indexing when no previous height is found\n */\nexport const DEFAULT_START_HEIGHT = 1;\n\n/**\n * Default port for health check HTTP server\n */\nexport const DEFAULT_HEALTH_CHECK_PORT = 8888;\n\n/**\n * Default port for Prometheus metrics server\n */\nexport const DEFAULT_PROMETHEUS_PORT = 9090;\n\n/**\n * Default polling interval in milliseconds when using polling mode instead of WebSocket\n */\nexport const DEFAULT_POLLING_INTERVAL_MS = 5000;\n\n/**\n * Timeout for connecting to the Tendermint RPC in milliseconds\n * If connection is not established within this time, it will be aborted\n */\nexport const CONNECT_TIMEOUT_MS = 10000;\n\n/**\n * Timeout for RPC calls in milliseconds\n * If a call takes longer than this, it will be rejected\n */\nexport const RPC_TIMEOUT_MS = 20000;\n\n/**\n * Timeout for block queue dequeue operations in milliseconds\n * If no block is available within this time, an error will be thrown\n */\nexport const QUEUE_DEQUEUE_TIMEOUT_MS = 30000;\n\n/**\n * Number of successful transactions before recycling the database client\n * Prevents long-running connection issues and stale connections\n */\nexport const DB_CLIENT_RECYCLE_COUNT = 1500;\n\n/**\n * Block intervals for periodic event emission\n * Used for operations that should run at regular block intervals\n */\nexport const PERIODIC_INTERVALS = {\n /** Emit periodic event every 50 blocks */\n SMALL: 50,\n /** Emit periodic event every 100 blocks */\n MEDIUM: 100,\n /** Emit periodic event every 1000 blocks - used for performance logging */\n LARGE: 1000,\n} as const;\n\n/**\n * Pagination limits for blockchain queries\n */\nexport const PAGINATION_LIMITS = {\n /** Default limit for validator queries */\n VALIDATORS: 1000n,\n /** Default limit for delegation queries */\n DELEGATIONS: 250n,\n} as const;\n\n/**\n * Batch size for streaming genesis file processing\n * Number of entries to process at once from genesis JSON\n */\nexport const GENESIS_BATCH_SIZE = 1000;\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qBAAqB;;;;AAKlC,MAAa,uBAAuB;;;;AAKpC,MAAa,4BAA4B;;;;AAKzC,MAAa,0BAA0B;;;;AAKvC,MAAa,8BAA8B;;;;;AAM3C,MAAa,qBAAqB;;;;;AAMlC,MAAa,iBAAiB;;;;;AAM9B,MAAa,2BAA2B;;;;;AAMxC,MAAa,0BAA0B;;;;;AAMvC,MAAa,qBAAqB;CAEhC,OAAO;CAEP,QAAQ;CAER,OAAO;CACR;;;;AAKD,MAAa,oBAAoB;CAE/B,YAAY;CAEZ,aAAa;CACd;;;;;AAMD,MAAa,qBAAqB"}
package/dist/index.cjs CHANGED
@@ -10,6 +10,7 @@ const require_index$7 = require('./mocks/index.cjs');
10
10
  const require_index$8 = require('./types/index.cjs');
11
11
 
12
12
  exports.BlockProcessingError = require_index$1.BlockProcessingError;
13
+ exports.CONNECT_TIMEOUT_MS = require_constants.CONNECT_TIMEOUT_MS;
13
14
  exports.CircularBuffer = require_index$3.CircularBuffer;
14
15
  exports.ConfigurationError = require_index$1.ConfigurationError;
15
16
  exports.DB_CLIENT_RECYCLE_COUNT = require_constants.DB_CLIENT_RECYCLE_COUNT;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.cjs";
1
+ import { CONNECT_TIMEOUT_MS, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.cjs";
2
2
  import { IndexerMetrics } from "./metrics/index.cjs";
3
3
  import { EcleciaIndexer, defaultIndexerConfig } from "./indexer/index.cjs";
4
4
  import { CircularBuffer, PromiseQueue } from "./promise-queue/index.cjs";
@@ -8,4 +8,4 @@ import { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError,
8
8
  import { index_d_exports } from "./mocks/index.cjs";
9
9
  import { index_d_exports as index_d_exports$2 } from "./utils/index.cjs";
10
10
  import { index_d_exports as index_d_exports$3 } from "./validation/index.cjs";
11
- export { BlockProcessingError, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, index_d_exports as Mocks, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, index_d_exports$1 as Types, index_d_exports$2 as Utils, index_d_exports$3 as Validation, defaultIndexerConfig };
11
+ export { BlockProcessingError, CONNECT_TIMEOUT_MS, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, index_d_exports as Mocks, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, index_d_exports$1 as Types, index_d_exports$2 as Utils, index_d_exports$3 as Validation, defaultIndexerConfig };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.mjs";
1
+ import { CONNECT_TIMEOUT_MS, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.mjs";
2
2
  import { IndexerMetrics } from "./metrics/index.mjs";
3
3
  import { EcleciaIndexer, defaultIndexerConfig } from "./indexer/index.mjs";
4
4
  import { CircularBuffer, PromiseQueue } from "./promise-queue/index.mjs";
@@ -8,4 +8,4 @@ import { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError,
8
8
  import { index_d_exports } from "./mocks/index.mjs";
9
9
  import { index_d_exports as index_d_exports$2 } from "./utils/index.mjs";
10
10
  import { index_d_exports as index_d_exports$3 } from "./validation/index.mjs";
11
- export { BlockProcessingError, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, index_d_exports as Mocks, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, index_d_exports$1 as Types, index_d_exports$2 as Utils, index_d_exports$3 as Validation, defaultIndexerConfig };
11
+ export { BlockProcessingError, CONNECT_TIMEOUT_MS, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, index_d_exports as Mocks, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, index_d_exports$1 as Types, index_d_exports$2 as Utils, index_d_exports$3 as Validation, defaultIndexerConfig };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.mjs";
1
+ import { CONNECT_TIMEOUT_MS, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.mjs";
2
2
  import { EclesiaEmitter } from "./emitter/index.mjs";
3
3
  import { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError, IndexerError, ModuleError, RPCError } from "./errors/index.mjs";
4
4
  import { IndexerMetrics } from "./metrics/index.mjs";
@@ -9,4 +9,4 @@ import { EcleciaIndexer, defaultIndexerConfig } from "./indexer/index.mjs";
9
9
  import { mocks_exports } from "./mocks/index.mjs";
10
10
  import { types_exports } from "./types/index.mjs";
11
11
 
12
- export { BlockProcessingError, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, mocks_exports as Mocks, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, types_exports as Types, utils_exports as Utils, validation_exports as Validation, defaultIndexerConfig };
12
+ export { BlockProcessingError, CONNECT_TIMEOUT_MS, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_PROMETHEUS_PORT, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, mocks_exports as Mocks, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, types_exports as Types, utils_exports as Utils, validation_exports as Validation, defaultIndexerConfig };
@@ -1,11 +1,12 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_constants = require('../constants.cjs');
3
3
  const require_index = require('../emitter/index.cjs');
4
- const require_index$1 = require('../metrics/index.cjs');
5
- const require_index$2 = require('../promise-queue/index.cjs');
4
+ const require_index$1 = require('../errors/index.cjs');
5
+ const require_index$2 = require('../metrics/index.cjs');
6
+ const require_index$3 = require('../promise-queue/index.cjs');
6
7
  const require_text = require('../utils/text.cjs');
7
8
  require('../utils/index.cjs');
8
- const require_index$4 = require('../validation/index.cjs');
9
+ const require_index$5 = require('../validation/index.cjs');
9
10
  let crypto = require("crypto");
10
11
  let fs = require("fs");
11
12
  fs = require_rolldown_runtime.__toESM(fs);
@@ -95,13 +96,13 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
95
96
  */
96
97
  constructor(config) {
97
98
  super();
98
- require_index$4.validateUrl(config.rpcUrl, "rpcUrl");
99
- require_index$4.validatePositiveInteger(config.batchSize, "batchSize");
100
- if (config.genesisPath) require_index$4.validateFilePath(config.genesisPath, "genesisPath");
101
- if (config.healthCheckPort !== void 0) require_index$4.validatePort(config.healthCheckPort, "healthCheckPort");
102
- if (config.prometheusPort !== void 0) require_index$4.validatePort(config.prometheusPort, "prometheusPort");
103
- if (config.startHeight !== void 0) require_index$4.validatePositiveInteger(config.startHeight, "startHeight");
104
- if (config.pollingInterval !== void 0) require_index$4.validatePositiveInteger(config.pollingInterval, "pollingInterval");
99
+ require_index$5.validateUrl(config.rpcUrl, "rpcUrl");
100
+ require_index$5.validatePositiveInteger(config.batchSize, "batchSize");
101
+ if (config.genesisPath) require_index$5.validateFilePath(config.genesisPath, "genesisPath");
102
+ if (config.healthCheckPort !== void 0) require_index$5.validatePort(config.healthCheckPort, "healthCheckPort");
103
+ if (config.prometheusPort !== void 0) require_index$5.validatePort(config.prometheusPort, "prometheusPort");
104
+ if (config.startHeight !== void 0) require_index$5.validatePositiveInteger(config.startHeight, "startHeight");
105
+ if (config.pollingInterval !== void 0) require_index$5.validatePositiveInteger(config.pollingInterval, "pollingInterval");
105
106
  this.config = {
106
107
  ...defaultIndexerConfig,
107
108
  ...config
@@ -126,8 +127,8 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
126
127
  this.prometheus?.recordError("rpc");
127
128
  this.log.error("Error enqueueing block data: " + e);
128
129
  };
129
- if (this.config.minimal) this.blockQueue = new require_index$2.CircularBuffer(this.config.batchSize, queueErrorHandler);
130
- else this.blockQueue = new require_index$2.CircularBuffer(this.config.batchSize, queueErrorHandler);
130
+ if (this.config.minimal) this.blockQueue = new require_index$3.CircularBuffer(this.config.batchSize, queueErrorHandler);
131
+ else this.blockQueue = new require_index$3.CircularBuffer(this.config.batchSize, queueErrorHandler);
131
132
  this.on("_unhandled", (msg) => {
132
133
  if (msg.uuid) {
133
134
  this.log.verbose("Unhandled event: " + msg.type);
@@ -138,7 +139,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
138
139
  }
139
140
  });
140
141
  if (this.config.enablePrometheus) {
141
- this.prometheus = new require_index$1.IndexerMetrics();
142
+ this.prometheus = new require_index$2.IndexerMetrics();
142
143
  this.prometheusServer = (0, fastify.default)({ logger: false });
143
144
  this.prometheusServer.get("/metrics", async (_req, res) => {
144
145
  res.header("Content-Type", this.prometheus.registry.contentType);
@@ -199,9 +200,12 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
199
200
  this.blockClient.disconnect();
200
201
  this.log.verbose("Disconnected from RPC");
201
202
  }
202
- this.client = await (0, __cosmjs_tendermint_rpc.connectComet)(this.config.rpcUrl);
203
+ const connectTimeoutPromise = new Promise((resolve, reject) => {
204
+ setTimeout(reject, require_constants.CONNECT_TIMEOUT_MS, []);
205
+ });
206
+ this.client = await Promise.race([(0, __cosmjs_tendermint_rpc.connectComet)(this.config.rpcUrl), connectTimeoutPromise]);
203
207
  this.log.info("Connected to RPC for ad hoc queries");
204
- this.blockClient = await (0, __cosmjs_tendermint_rpc.connectComet)(this.config.rpcUrl);
208
+ this.blockClient = await Promise.race([(0, __cosmjs_tendermint_rpc.connectComet)(this.config.rpcUrl), connectTimeoutPromise]);
205
209
  this.log.info("Connected to RPC for block & validator info");
206
210
  return true;
207
211
  } catch (error) {
@@ -211,15 +215,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
211
215
  return false;
212
216
  }
213
217
  }
214
- stop() {
215
- this.started = false;
216
- }
217
- async start() {
218
- this.started = true;
219
- if (this.blockQueue) {
220
- this.blockQueue.clear();
221
- this.log.verbose("Starting, clearing block queue");
222
- }
218
+ async initialize() {
223
219
  if (!this.initialized) {
224
220
  try {
225
221
  if (this.config.init) await this.config.init();
@@ -239,15 +235,32 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
239
235
  }
240
236
  this.initialized = true;
241
237
  }
238
+ }
239
+ stop() {
240
+ this.started = false;
241
+ }
242
+ clearBlockQueue() {
243
+ if (this.blockQueue) {
244
+ this.blockQueue.clear();
245
+ this.log.verbose("Starting, clearing block queue");
246
+ }
247
+ }
248
+ async setupBlockListening() {
249
+ if (!await this.connect()) {
250
+ this.setStatus("FAILED");
251
+ throw new require_index$1.RPCError("Failed to connect to RPC");
252
+ }
242
253
  try {
243
- await this.connect();
244
254
  if (!this.config.usePolling && this.subscription) {
245
255
  this.subscription.removeListener(this.blockListener);
246
256
  this.subscription = null;
247
257
  this.log.verbose("Removed existing block listener and subscription");
248
258
  }
249
259
  if (!this.config.usePolling) this.subscription = this.client.subscribeNewBlock ? this.client.subscribeNewBlock() : null;
250
- this.latestHeight = (await this.client.status()).syncInfo.latestBlockHeight;
260
+ const statusPromise = new Promise((resolve, reject) => {
261
+ setTimeout(reject, require_constants.RPC_TIMEOUT_MS, false);
262
+ });
263
+ this.latestHeight = (await Promise.race([this.client.status(), statusPromise])).syncInfo.latestBlockHeight;
251
264
  this.log.info("Current chain height: " + this.latestHeight);
252
265
  this.heightToProcess = await this.config.getNextHeight();
253
266
  if (this.config.usePolling) this.pollForBlock();
@@ -262,6 +275,12 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
262
275
  this.setStatus("FAILED");
263
276
  throw e;
264
277
  }
278
+ }
279
+ async start() {
280
+ this.started = true;
281
+ this.clearBlockQueue();
282
+ await this.initialize();
283
+ await this.setupBlockListening();
265
284
  this.log.debug("Starting main processing loop");
266
285
  this.tryToRecover = false;
267
286
  this.fetcher().catch((e) => {
@@ -269,12 +288,9 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
269
288
  this.prometheus?.recordError("rpc");
270
289
  throw new Error("Error in fetching service: " + e);
271
290
  });
272
- const hrTime = process.hrtime();
273
- let ms = hrTime[0] * 1e6 + hrTime[1] / 1e3;
274
- while (this.blockQueue.size() > 0 && !this.tryToRecover && this.started && (this.config.endHeight === void 0 || this.heightToProcess <= this.config.endHeight)) {
275
- if (this.config.enablePrometheus) this.prometheus.updateRetryCount(this.retryCount);
291
+ while (this.started && !this.tryToRecover && (this.config.endHeight === void 0 || this.heightToProcess <= this.config.endHeight) && this.blockQueue.size() > 0) {
276
292
  try {
277
- if (this.tryToRecover) throw new Error("Exiting processing loop. Attempting to recover indexer");
293
+ this.prometheus?.updateRetryCount(this.retryCount);
278
294
  await this.config.beginTransaction();
279
295
  this.log.silly("Started db tx");
280
296
  let height, timestamp;
@@ -284,10 +300,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
284
300
  });
285
301
  const toProcess = await Promise.race([this.blockQueue.dequeue(), timeoutPromise]);
286
302
  this.log.silly("Retrieved block data");
287
- if (!toProcess || !toProcess[0] || !toProcess[1]) {
288
- this.prometheus?.recordError("rpc");
289
- throw new Error("Could not fetch block");
290
- }
303
+ if (!toProcess || !toProcess[0] || !toProcess[1]) throw new require_index$1.RPCError("Could not fetch block(minimal)");
291
304
  height = toProcess[0].block.header.height;
292
305
  timestamp = (0, __cosmjs_tendermint_rpc.toRfc3339WithNanoseconds)(toProcess[0].block.header.time);
293
306
  await this.processBlock(toProcess[0], toProcess[1]);
@@ -297,34 +310,23 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
297
310
  });
298
311
  const toProcess = await Promise.race([this.blockQueue.dequeue(), timeoutPromise]);
299
312
  this.log.silly("Retrieved block data");
300
- if (!toProcess || !toProcess[0] || !toProcess[1] || !toProcess[2]) {
301
- this.prometheus?.recordError("rpc");
302
- throw new Error("Could not fetch block");
303
- }
313
+ if (!toProcess || !toProcess[0] || !toProcess[1] || !toProcess[2]) throw new require_index$1.RPCError("Could not fetch block(full)");
304
314
  this.log.silly("Decoded block");
305
315
  height = toProcess[0].block.header.height;
306
316
  timestamp = (0, __cosmjs_tendermint_rpc.toRfc3339WithNanoseconds)(toProcess[0].block.header.time);
307
317
  await this.processBlock(toProcess[0], toProcess[1], cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsResponse.decode(toProcess[2]).validators);
308
318
  }
309
- if (height % require_constants.PERIODIC_INTERVALS.LARGE == 0) {
310
- const hrTime$1 = process.hrtime();
311
- const newms = hrTime$1[0] * 1e6 + hrTime$1[1] / 1e3;
312
- const duration = newms - ms;
313
- ms = newms;
314
- const rate = 1e9 / duration;
315
- this.log.info("Processing:" + rate.toFixed(2) + "blocks/sec");
316
- await this.asyncEmit("periodic/1000", {
317
- value: null,
318
- height,
319
- timestamp
320
- });
321
- }
322
- if (height % require_constants.PERIODIC_INTERVALS.MEDIUM == 0) await this.asyncEmit("periodic/100", {
319
+ if (height % require_constants.PERIODIC_INTERVALS.LARGE == 0) await this.asyncEmit("periodic/large", {
320
+ value: null,
321
+ height,
322
+ timestamp
323
+ });
324
+ if (height % require_constants.PERIODIC_INTERVALS.MEDIUM == 0) await this.asyncEmit("periodic/medium", {
323
325
  value: null,
324
326
  height,
325
327
  timestamp
326
328
  });
327
- if (height % require_constants.PERIODIC_INTERVALS.SMALL == 0) await this.asyncEmit("periodic/50", {
329
+ if (height % require_constants.PERIODIC_INTERVALS.SMALL == 0) await this.asyncEmit("periodic/small", {
328
330
  value: null,
329
331
  height,
330
332
  timestamp
@@ -349,12 +351,18 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
349
351
  this.retryCount = 0;
350
352
  this.setStatus("OK");
351
353
  }
354
+ if (!this.started) {
355
+ this.log.info("Indexer manually stopped.");
356
+ return;
357
+ }
352
358
  if (this.config.endHeight !== void 0 && this.heightToProcess >= this.config.endHeight) {
353
359
  this.log.info("Reached configured end height. Stopping indexer.");
354
360
  this.stop();
361
+ return;
355
362
  }
356
- if (this.started) if (this.retryCount < 3) {
363
+ if (this.retryCount < 3) {
357
364
  this.log.debug("Indexer retryCount: " + this.retryCount);
365
+ this.retryCount++;
358
366
  this.log.info("Indexer is restarting");
359
367
  setTimeout(() => this.start(), this.retryCount * 5e3);
360
368
  } else {
@@ -387,10 +395,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
387
395
  return prom;
388
396
  };
389
397
  async processBlock(block, block_results, validators) {
390
- let processStart = [0, 0];
391
- if (this.config.logLevel == "silly") processStart = process.hrtime();
392
- let endTimer;
393
- if (this.config.enablePrometheus) endTimer = this.prometheus.timeBlockProcessing();
398
+ const endTimer = this.prometheus?.timeBlockProcessing();
394
399
  const height = block.block.header.height;
395
400
  this.heightToProcess = height;
396
401
  this.log.debug("Processing block: %d", height);
@@ -497,28 +502,23 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
497
502
  }
498
503
  }
499
504
  this.log.silly("Modules handled msg events");
500
- if (this.config.enablePrometheus) this.prometheus.recordTransactions(block.block.txs.length);
505
+ this.prometheus?.recordTransactions(block.block.txs.length);
501
506
  await this.asyncEmit("end_block", {
502
507
  value: endBlockEvents,
503
508
  height,
504
509
  timestamp
505
510
  });
506
511
  this.log.silly("Modules handled end_block events");
507
- if (this.config.logLevel == "silly") {
508
- const processEnd = process.hrtime(processStart);
509
- const processTime = processEnd[0] * 1e3 + processEnd[1] / 1e6;
510
- this.log.silly("Processed block %d in %d ms", height, processTime.toFixed(2));
511
- }
512
- if (this.config.enablePrometheus) endTimer();
513
- if (this.config.enablePrometheus) this.prometheus.updateBlockMetrics(height, this.latestHeight, this.blockQueue.size());
512
+ endTimer?.();
513
+ this.prometheus?.updateBlockMetrics(height, this.latestHeight, this.blockQueue.size());
514
514
  }
515
515
  async fetcher() {
516
516
  for (let i = this.heightToProcess; i <= this.latestHeight; i++) {
517
- this.log.debug("Fetching: " + i);
518
517
  if (this.tryToRecover) {
519
518
  this.log.verbose("Exiting fetcher loop. Attempting to recover indexer");
520
519
  break;
521
520
  }
521
+ this.log.debug("Fetching: " + i);
522
522
  try {
523
523
  if (this.isMinimal(this.blockQueue)) {
524
524
  const timeoutPromise = new Promise((resolve, reject) => {
@@ -526,6 +526,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
526
526
  });
527
527
  const toIndex = Promise.race([Promise.all([this.blockClient.block(i), this.blockClient.blockResults(i)]), timeoutPromise]).catch((e) => {
528
528
  this.log.error("Error fetching block: " + i + " : " + e);
529
+ this.prometheus?.recordError("rpc");
529
530
  this.tryToRecover = true;
530
531
  return Promise.resolve([]);
531
532
  });
@@ -547,15 +548,15 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
547
548
  });
548
549
  this.blockQueue.enqueue(toIndex);
549
550
  }
550
- await this.blockQueue.continue();
551
- if (this.tryToRecover) {
552
- this.retryCount++;
553
- throw new Error("RPC not responding");
554
- }
555
551
  } catch (e) {
556
552
  this.log.error("Fetching error: " + e);
557
553
  break;
558
554
  }
555
+ await this.blockQueue.continue();
556
+ if (this.tryToRecover) {
557
+ this.log.verbose("Exiting fetcher loop. Attempting to recover indexer");
558
+ break;
559
+ }
559
560
  }
560
561
  if (!this.tryToRecover) {
561
562
  this.blockQueue.setSynced();