@eclesia/indexer-engine 2.9.9 → 2.10.0-next.1
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/constants.cjs +74 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +68 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.ts +68 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +64 -0
- package/dist/constants.js.map +1 -0
- package/dist/emitter/index.cjs +0 -1
- package/dist/emitter/index.cjs.map +1 -1
- package/dist/errors/index.cjs +107 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +75 -0
- package/dist/errors/index.d.cts.map +1 -0
- package/dist/errors/index.d.ts +75 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +100 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.cjs +38 -10
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/indexer/index.cjs +51 -27
- package/dist/indexer/index.cjs.map +1 -1
- package/dist/indexer/index.d.cts +1 -0
- package/dist/indexer/index.d.cts.map +1 -1
- package/dist/indexer/index.d.ts +1 -0
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js +51 -20
- package/dist/indexer/index.js.map +1 -1
- package/dist/metrics/index.cjs +146 -0
- package/dist/metrics/index.cjs.map +1 -0
- package/dist/metrics/index.d.cts +56 -0
- package/dist/metrics/index.d.cts.map +1 -0
- package/dist/metrics/index.d.ts +56 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +145 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/promise-queue/index.cjs +6 -4
- package/dist/promise-queue/index.cjs.map +1 -1
- package/dist/promise-queue/index.d.cts +6 -2
- package/dist/promise-queue/index.d.cts.map +1 -1
- package/dist/promise-queue/index.d.ts +6 -2
- package/dist/promise-queue/index.d.ts.map +1 -1
- package/dist/promise-queue/index.js +6 -4
- package/dist/promise-queue/index.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +6 -0
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/bech32.cjs +0 -1
- package/dist/utils/bech32.cjs.map +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/validation/index.cjs +150 -0
- package/dist/validation/index.cjs.map +1 -0
- package/dist/validation/index.d.cts +52 -0
- package/dist/validation/index.d.cts.map +1 -0
- package/dist/validation/index.d.ts +52 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +140 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//#region src/errors/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Custom error classes for the Eclesia indexer
|
|
4
|
+
* These provide better context and error tracking throughout the application
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base error class for all indexer errors
|
|
8
|
+
* Extends Error with additional context fields
|
|
9
|
+
*/
|
|
10
|
+
var IndexerError = class extends Error {
|
|
11
|
+
constructor(message, code = "INDEXER_ERROR", context) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.context = context;
|
|
16
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Configuration-related errors
|
|
21
|
+
* Thrown when indexer configuration is invalid or missing
|
|
22
|
+
*/
|
|
23
|
+
var ConfigurationError = class extends IndexerError {
|
|
24
|
+
constructor(message, context) {
|
|
25
|
+
super(message, "CONFIGURATION_ERROR", context);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* RPC connection and communication errors
|
|
30
|
+
* Thrown when RPC calls fail or connections are lost
|
|
31
|
+
*/
|
|
32
|
+
var RPCError = class extends IndexerError {
|
|
33
|
+
constructor(message, endpoint, height, context) {
|
|
34
|
+
super(message, "RPC_ERROR", {
|
|
35
|
+
...context,
|
|
36
|
+
endpoint,
|
|
37
|
+
height
|
|
38
|
+
});
|
|
39
|
+
this.endpoint = endpoint;
|
|
40
|
+
this.height = height;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Database operation errors
|
|
45
|
+
* Thrown when database queries or transactions fail
|
|
46
|
+
*/
|
|
47
|
+
var DatabaseError = class extends IndexerError {
|
|
48
|
+
constructor(message, operation, query, context) {
|
|
49
|
+
super(message, "DATABASE_ERROR", {
|
|
50
|
+
...context,
|
|
51
|
+
operation,
|
|
52
|
+
query
|
|
53
|
+
});
|
|
54
|
+
this.operation = operation;
|
|
55
|
+
this.query = query;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Block processing errors
|
|
60
|
+
* Thrown when block data is invalid or processing fails
|
|
61
|
+
*/
|
|
62
|
+
var BlockProcessingError = class extends IndexerError {
|
|
63
|
+
constructor(message, height, context) {
|
|
64
|
+
super(message, "BLOCK_PROCESSING_ERROR", {
|
|
65
|
+
...context,
|
|
66
|
+
height
|
|
67
|
+
});
|
|
68
|
+
this.height = height;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Module initialization errors
|
|
73
|
+
* Thrown when indexing modules fail to initialize
|
|
74
|
+
*/
|
|
75
|
+
var ModuleError = class extends IndexerError {
|
|
76
|
+
constructor(message, moduleName, context) {
|
|
77
|
+
super(message, "MODULE_ERROR", {
|
|
78
|
+
...context,
|
|
79
|
+
moduleName
|
|
80
|
+
});
|
|
81
|
+
this.moduleName = moduleName;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Genesis processing errors
|
|
86
|
+
* Thrown when genesis file parsing or processing fails
|
|
87
|
+
*/
|
|
88
|
+
var GenesisError = class extends IndexerError {
|
|
89
|
+
constructor(message, genesisPath, context) {
|
|
90
|
+
super(message, "GENESIS_ERROR", {
|
|
91
|
+
...context,
|
|
92
|
+
genesisPath
|
|
93
|
+
});
|
|
94
|
+
this.genesisPath = genesisPath;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError, IndexerError, ModuleError, RPCError };
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * Custom error classes for the Eclesia indexer\n * These provide better context and error tracking throughout the application\n */\n\n/**\n * Base error class for all indexer errors\n * Extends Error with additional context fields\n */\nexport class IndexerError extends Error {\n /** Error code for programmatic error handling */\n public readonly code: string;\n\n /** Additional context data for debugging */\n public readonly context?: Record<string, unknown>;\n\n constructor(message: string, code: string = \"INDEXER_ERROR\", context?: Record<string, unknown>) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n this.context = context;\n\n // Maintains proper stack trace for where error was thrown\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Configuration-related errors\n * Thrown when indexer configuration is invalid or missing\n */\nexport class ConfigurationError extends IndexerError {\n constructor(message: string, context?: Record<string, unknown>) {\n super(message, \"CONFIGURATION_ERROR\", context);\n }\n}\n\n/**\n * RPC connection and communication errors\n * Thrown when RPC calls fail or connections are lost\n */\nexport class RPCError extends IndexerError {\n /** The RPC endpoint that failed */\n public readonly endpoint?: string;\n\n /** The height being queried when error occurred */\n public readonly height?: number;\n\n constructor(\n message: string,\n endpoint?: string,\n height?: number,\n context?: Record<string, unknown>,\n ) {\n super(message, \"RPC_ERROR\", {\n ...context,\n endpoint,\n height,\n });\n this.endpoint = endpoint;\n this.height = height;\n }\n}\n\n/**\n * Database operation errors\n * Thrown when database queries or transactions fail\n */\nexport class DatabaseError extends IndexerError {\n /** The SQL query that failed */\n public readonly query?: string;\n\n /** The operation that failed (e.g., \"BEGIN\", \"COMMIT\", \"ROLLBACK\") */\n public readonly operation?: string;\n\n constructor(message: string, operation?: string, query?: string, context?: Record<string, unknown>) {\n super(message, \"DATABASE_ERROR\", {\n ...context,\n operation,\n query,\n });\n this.operation = operation;\n this.query = query;\n }\n}\n\n/**\n * Block processing errors\n * Thrown when block data is invalid or processing fails\n */\nexport class BlockProcessingError extends IndexerError {\n /** The height of the block that failed to process */\n public readonly height: number;\n\n constructor(message: string, height: number, context?: Record<string, unknown>) {\n super(message, \"BLOCK_PROCESSING_ERROR\", {\n ...context,\n height,\n });\n this.height = height;\n }\n}\n\n/**\n * Module initialization errors\n * Thrown when indexing modules fail to initialize\n */\nexport class ModuleError extends IndexerError {\n /** The name of the module that failed */\n public readonly moduleName: string;\n\n constructor(message: string, moduleName: string, context?: Record<string, unknown>) {\n super(message, \"MODULE_ERROR\", {\n ...context,\n moduleName,\n });\n this.moduleName = moduleName;\n }\n}\n\n/**\n * Genesis processing errors\n * Thrown when genesis file parsing or processing fails\n */\nexport class GenesisError extends IndexerError {\n /** Path to the genesis file */\n public readonly genesisPath?: string;\n\n constructor(message: string, genesisPath?: string, context?: Record<string, unknown>) {\n super(message, \"GENESIS_ERROR\", {\n ...context,\n genesisPath,\n });\n this.genesisPath = genesisPath;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAa,eAAb,cAAkC,MAAM;CAOtC,YAAY,SAAiB,OAAe,iBAAiB,SAAmC;AAC9F,QAAM,QAAQ;AACd,OAAK,OAAO,KAAK,YAAY;AAC7B,OAAK,OAAO;AACZ,OAAK,UAAU;AAGf,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;;AASrD,IAAa,qBAAb,cAAwC,aAAa;CACnD,YAAY,SAAiB,SAAmC;AAC9D,QAAM,SAAS,uBAAuB,QAAQ;;;;;;;AAQlD,IAAa,WAAb,cAA8B,aAAa;CAOzC,YACE,SACA,UACA,QACA,SACA;AACA,QAAM,SAAS,aAAa;GAC1B,GAAG;GACH;GACA;GACD,CAAC;AACF,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;;AAQlB,IAAa,gBAAb,cAAmC,aAAa;CAO9C,YAAY,SAAiB,WAAoB,OAAgB,SAAmC;AAClG,QAAM,SAAS,kBAAkB;GAC/B,GAAG;GACH;GACA;GACD,CAAC;AACF,OAAK,YAAY;AACjB,OAAK,QAAQ;;;;;;;AAQjB,IAAa,uBAAb,cAA0C,aAAa;CAIrD,YAAY,SAAiB,QAAgB,SAAmC;AAC9E,QAAM,SAAS,0BAA0B;GACvC,GAAG;GACH;GACD,CAAC;AACF,OAAK,SAAS;;;;;;;AAQlB,IAAa,cAAb,cAAiC,aAAa;CAI5C,YAAY,SAAiB,YAAoB,SAAmC;AAClF,QAAM,SAAS,gBAAgB;GAC7B,GAAG;GACH;GACD,CAAC;AACF,OAAK,aAAa;;;;;;;AAQtB,IAAa,eAAb,cAAkC,aAAa;CAI7C,YAAY,SAAiB,aAAsB,SAAmC;AACpF,QAAM,SAAS,iBAAiB;GAC9B,GAAG;GACH;GACD,CAAC;AACF,OAAK,cAAc"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,23 +1,51 @@
|
|
|
1
|
+
const require_constants = require('./constants.cjs');
|
|
1
2
|
const require_index = require('./emitter/index.cjs');
|
|
2
|
-
const require_index$1 = require('./
|
|
3
|
-
const require_index$2 = require('./
|
|
4
|
-
const require_index$3 = require('./
|
|
5
|
-
const require_index$4 = require('./
|
|
3
|
+
const require_index$1 = require('./errors/index.cjs');
|
|
4
|
+
const require_index$2 = require('./promise-queue/index.cjs');
|
|
5
|
+
const require_index$3 = require('./utils/index.cjs');
|
|
6
|
+
const require_index$4 = require('./validation/index.cjs');
|
|
7
|
+
const require_index$5 = require('./indexer/index.cjs');
|
|
8
|
+
const require_index$6 = require('./metrics/index.cjs');
|
|
9
|
+
const require_index$7 = require('./types/index.cjs');
|
|
6
10
|
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
11
|
+
exports.BlockProcessingError = require_index$1.BlockProcessingError;
|
|
12
|
+
exports.CircularBuffer = require_index$2.CircularBuffer;
|
|
13
|
+
exports.ConfigurationError = require_index$1.ConfigurationError;
|
|
14
|
+
exports.DB_CLIENT_RECYCLE_COUNT = require_constants.DB_CLIENT_RECYCLE_COUNT;
|
|
15
|
+
exports.DEFAULT_BATCH_SIZE = require_constants.DEFAULT_BATCH_SIZE;
|
|
16
|
+
exports.DEFAULT_HEALTH_CHECK_PORT = require_constants.DEFAULT_HEALTH_CHECK_PORT;
|
|
17
|
+
exports.DEFAULT_POLLING_INTERVAL_MS = require_constants.DEFAULT_POLLING_INTERVAL_MS;
|
|
18
|
+
exports.DEFAULT_START_HEIGHT = require_constants.DEFAULT_START_HEIGHT;
|
|
19
|
+
exports.DatabaseError = require_index$1.DatabaseError;
|
|
20
|
+
exports.EcleciaIndexer = require_index$5.EcleciaIndexer;
|
|
9
21
|
exports.EclesiaEmitter = require_index.EclesiaEmitter;
|
|
10
|
-
exports.
|
|
22
|
+
exports.GENESIS_BATCH_SIZE = require_constants.GENESIS_BATCH_SIZE;
|
|
23
|
+
exports.GenesisError = require_index$1.GenesisError;
|
|
24
|
+
exports.IndexerError = require_index$1.IndexerError;
|
|
25
|
+
exports.IndexerMetrics = require_index$6.IndexerMetrics;
|
|
26
|
+
exports.ModuleError = require_index$1.ModuleError;
|
|
27
|
+
exports.PAGINATION_LIMITS = require_constants.PAGINATION_LIMITS;
|
|
28
|
+
exports.PERIODIC_INTERVALS = require_constants.PERIODIC_INTERVALS;
|
|
29
|
+
exports.PromiseQueue = require_index$2.PromiseQueue;
|
|
30
|
+
exports.QUEUE_DEQUEUE_TIMEOUT_MS = require_constants.QUEUE_DEQUEUE_TIMEOUT_MS;
|
|
31
|
+
exports.RPCError = require_index$1.RPCError;
|
|
32
|
+
exports.RPC_TIMEOUT_MS = require_constants.RPC_TIMEOUT_MS;
|
|
11
33
|
Object.defineProperty(exports, 'Types', {
|
|
12
34
|
enumerable: true,
|
|
13
35
|
get: function () {
|
|
14
|
-
return require_index$
|
|
36
|
+
return require_index$7.types_exports;
|
|
15
37
|
}
|
|
16
38
|
});
|
|
17
39
|
Object.defineProperty(exports, 'Utils', {
|
|
18
40
|
enumerable: true,
|
|
19
41
|
get: function () {
|
|
20
|
-
return require_index$
|
|
42
|
+
return require_index$3.utils_exports;
|
|
21
43
|
}
|
|
22
44
|
});
|
|
23
|
-
exports
|
|
45
|
+
Object.defineProperty(exports, 'Validation', {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return require_index$4.validation_exports;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
exports.defaultIndexerConfig = require_index$5.defaultIndexerConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.cjs";
|
|
1
2
|
import { EcleciaIndexer, defaultIndexerConfig } from "./indexer/index.cjs";
|
|
2
3
|
import { CircularBuffer, PromiseQueue } from "./promise-queue/index.cjs";
|
|
3
4
|
import { index_d_exports } from "./types/index.cjs";
|
|
4
5
|
import { EclesiaEmitter } from "./emitter/index.cjs";
|
|
6
|
+
import { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError, IndexerError, ModuleError, RPCError } from "./errors/index.cjs";
|
|
7
|
+
import { IndexerMetrics } from "./metrics/index.cjs";
|
|
5
8
|
import { index_d_exports as index_d_exports$1 } from "./utils/index.cjs";
|
|
6
|
-
|
|
9
|
+
import { index_d_exports as index_d_exports$2 } from "./validation/index.cjs";
|
|
10
|
+
export { BlockProcessingError, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, index_d_exports as Types, index_d_exports$1 as Utils, index_d_exports$2 as Validation, defaultIndexerConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.js";
|
|
1
2
|
import { EcleciaIndexer, defaultIndexerConfig } from "./indexer/index.js";
|
|
2
3
|
import { CircularBuffer, PromiseQueue } from "./promise-queue/index.js";
|
|
3
4
|
import { index_d_exports } from "./types/index.js";
|
|
4
5
|
import { EclesiaEmitter } from "./emitter/index.js";
|
|
6
|
+
import { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError, IndexerError, ModuleError, RPCError } from "./errors/index.js";
|
|
7
|
+
import { IndexerMetrics } from "./metrics/index.js";
|
|
5
8
|
import { index_d_exports as index_d_exports$1 } from "./utils/index.js";
|
|
6
|
-
|
|
9
|
+
import { index_d_exports as index_d_exports$2 } from "./validation/index.js";
|
|
10
|
+
export { BlockProcessingError, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, ModuleError, PAGINATION_LIMITS, PERIODIC_INTERVALS, PromiseQueue, QUEUE_DEQUEUE_TIMEOUT_MS, RPCError, RPC_TIMEOUT_MS, index_d_exports as Types, index_d_exports$1 as Utils, index_d_exports$2 as Validation, defaultIndexerConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_START_HEIGHT, GENESIS_BATCH_SIZE, PAGINATION_LIMITS, PERIODIC_INTERVALS, QUEUE_DEQUEUE_TIMEOUT_MS, RPC_TIMEOUT_MS } from "./constants.js";
|
|
1
2
|
import { EclesiaEmitter } from "./emitter/index.js";
|
|
3
|
+
import { BlockProcessingError, ConfigurationError, DatabaseError, GenesisError, IndexerError, ModuleError, RPCError } from "./errors/index.js";
|
|
2
4
|
import { CircularBuffer, PromiseQueue } from "./promise-queue/index.js";
|
|
3
5
|
import { utils_exports } from "./utils/index.js";
|
|
6
|
+
import { validation_exports } from "./validation/index.js";
|
|
4
7
|
import { EcleciaIndexer, defaultIndexerConfig } from "./indexer/index.js";
|
|
8
|
+
import { IndexerMetrics } from "./metrics/index.js";
|
|
5
9
|
import { types_exports } from "./types/index.js";
|
|
6
10
|
|
|
7
|
-
export { CircularBuffer, EcleciaIndexer, EclesiaEmitter, PromiseQueue, types_exports as Types, utils_exports as Utils, defaultIndexerConfig };
|
|
11
|
+
export { BlockProcessingError, CircularBuffer, ConfigurationError, DB_CLIENT_RECYCLE_COUNT, DEFAULT_BATCH_SIZE, DEFAULT_HEALTH_CHECK_PORT, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_START_HEIGHT, DatabaseError, EcleciaIndexer, EclesiaEmitter, GENESIS_BATCH_SIZE, GenesisError, IndexerError, IndexerMetrics, 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 };
|
package/dist/indexer/index.cjs
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_constants = require('../constants.cjs');
|
|
2
3
|
const require_index = require('../emitter/index.cjs');
|
|
3
4
|
const require_index$1 = require('../promise-queue/index.cjs');
|
|
4
5
|
const require_text = require('../utils/text.cjs');
|
|
5
6
|
require('../utils/index.cjs');
|
|
7
|
+
const require_index$3 = require('../validation/index.cjs');
|
|
6
8
|
let crypto = require("crypto");
|
|
7
|
-
crypto = require_rolldown_runtime.__toESM(crypto);
|
|
8
9
|
let fs = require("fs");
|
|
9
10
|
fs = require_rolldown_runtime.__toESM(fs);
|
|
10
11
|
let __cosmjs_tendermint_rpc = require("@cosmjs/tendermint-rpc");
|
|
11
|
-
__cosmjs_tendermint_rpc = require_rolldown_runtime.__toESM(__cosmjs_tendermint_rpc);
|
|
12
12
|
let cosmjs_types_cosmos_authz_v1beta1_tx_js = require("cosmjs-types/cosmos/authz/v1beta1/tx.js");
|
|
13
|
-
cosmjs_types_cosmos_authz_v1beta1_tx_js = require_rolldown_runtime.__toESM(cosmjs_types_cosmos_authz_v1beta1_tx_js);
|
|
14
13
|
let cosmjs_types_cosmos_staking_v1beta1_query_js = require("cosmjs-types/cosmos/staking/v1beta1/query.js");
|
|
15
|
-
cosmjs_types_cosmos_staking_v1beta1_query_js = require_rolldown_runtime.__toESM(cosmjs_types_cosmos_staking_v1beta1_query_js);
|
|
16
14
|
let cosmjs_types_cosmos_tx_v1beta1_tx_js = require("cosmjs-types/cosmos/tx/v1beta1/tx.js");
|
|
17
|
-
cosmjs_types_cosmos_tx_v1beta1_tx_js = require_rolldown_runtime.__toESM(cosmjs_types_cosmos_tx_v1beta1_tx_js);
|
|
18
15
|
let fastify = require("fastify");
|
|
19
16
|
fastify = require_rolldown_runtime.__toESM(fastify);
|
|
20
17
|
let stream_chain = require("stream-chain");
|
|
21
|
-
stream_chain = require_rolldown_runtime.__toESM(stream_chain);
|
|
22
18
|
let stream_json = require("stream-json");
|
|
23
19
|
stream_json = require_rolldown_runtime.__toESM(stream_json);
|
|
24
20
|
let stream_json_filters_Pick_js = require("stream-json/filters/Pick.js");
|
|
@@ -30,22 +26,22 @@ stream_json_streamers_StreamValues_js = require_rolldown_runtime.__toESM(stream_
|
|
|
30
26
|
let stream_json_utils_Batch_js = require("stream-json/utils/Batch.js");
|
|
31
27
|
stream_json_utils_Batch_js = require_rolldown_runtime.__toESM(stream_json_utils_Batch_js);
|
|
32
28
|
let uuid = require("uuid");
|
|
33
|
-
uuid = require_rolldown_runtime.__toESM(uuid);
|
|
34
29
|
let winston = require("winston");
|
|
35
30
|
winston = require_rolldown_runtime.__toESM(winston);
|
|
36
31
|
|
|
37
32
|
//#region src/indexer/index.ts
|
|
38
33
|
/** Default configuration for the Eclesia indexer */
|
|
39
34
|
const defaultIndexerConfig = {
|
|
40
|
-
startHeight:
|
|
41
|
-
batchSize:
|
|
35
|
+
startHeight: require_constants.DEFAULT_START_HEIGHT,
|
|
36
|
+
batchSize: require_constants.DEFAULT_BATCH_SIZE,
|
|
42
37
|
modules: [],
|
|
43
|
-
getNextHeight: () =>
|
|
38
|
+
getNextHeight: () => require_constants.DEFAULT_START_HEIGHT,
|
|
44
39
|
logLevel: "info",
|
|
45
40
|
usePolling: false,
|
|
46
|
-
pollingInterval:
|
|
41
|
+
pollingInterval: require_constants.DEFAULT_POLLING_INTERVAL_MS,
|
|
47
42
|
shouldProcessGenesis: () => false,
|
|
48
43
|
minimal: true,
|
|
44
|
+
healthCheckPort: require_constants.DEFAULT_HEALTH_CHECK_PORT,
|
|
49
45
|
init: () => Promise.resolve(),
|
|
50
46
|
beginTransaction: () => Promise.resolve(),
|
|
51
47
|
endTransaction: (_status) => Promise.resolve()
|
|
@@ -89,12 +85,16 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
89
85
|
this.emit(type, event);
|
|
90
86
|
return prom;
|
|
91
87
|
};
|
|
88
|
+
require_index$3.validateUrl(config.rpcUrl, "rpcUrl");
|
|
89
|
+
require_index$3.validatePositiveInteger(config.batchSize, "batchSize");
|
|
90
|
+
if (config.genesisPath) require_index$3.validateFilePath(config.genesisPath, "genesisPath");
|
|
91
|
+
if (config.healthCheckPort !== void 0) require_index$3.validatePort(config.healthCheckPort, "healthCheckPort");
|
|
92
|
+
if (config.startHeight !== void 0) require_index$3.validatePositiveInteger(config.startHeight, "startHeight");
|
|
93
|
+
if (config.pollingInterval !== void 0) require_index$3.validatePositiveInteger(config.pollingInterval, "pollingInterval");
|
|
92
94
|
this.config = {
|
|
93
95
|
...defaultIndexerConfig,
|
|
94
96
|
...config
|
|
95
97
|
};
|
|
96
|
-
if (this.config.minimal) this.blockQueue = new require_index$1.CircularBuffer(this.config.batchSize);
|
|
97
|
-
else this.blockQueue = new require_index$1.CircularBuffer(this.config.batchSize);
|
|
98
98
|
const { printf } = winston.format;
|
|
99
99
|
const eclesiaFormat = printf(({ level, message, timestamp }) => {
|
|
100
100
|
return `${timestamp} [${level.toUpperCase()}]:\t${message}`;
|
|
@@ -111,6 +111,11 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
111
111
|
new winston.transports.Console({ format: winston.format.combine(winston.format.splat(), winston.format.timestamp(), eclesiaFormat, winston.format.colorize({ all: true })) })
|
|
112
112
|
]
|
|
113
113
|
});
|
|
114
|
+
const queueErrorHandler = (e) => {
|
|
115
|
+
this.log.error("Error enqueueing block data: " + e);
|
|
116
|
+
};
|
|
117
|
+
if (this.config.minimal) this.blockQueue = new require_index$1.CircularBuffer(this.config.batchSize, queueErrorHandler);
|
|
118
|
+
else this.blockQueue = new require_index$1.CircularBuffer(this.config.batchSize, queueErrorHandler);
|
|
114
119
|
this.fastify = (0, fastify.default)({ logger: false });
|
|
115
120
|
this.on("_unhandled", (msg) => {
|
|
116
121
|
if (msg.uuid) {
|
|
@@ -125,13 +130,17 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
125
130
|
const code = this.healthCheck.status == "OK" ? 200 : 503;
|
|
126
131
|
reply.code(code).send(this.healthCheck);
|
|
127
132
|
});
|
|
133
|
+
const healthPort = this.config.healthCheckPort ?? (process.env.HEALTH_CHECK_PORT ? parseInt(process.env.HEALTH_CHECK_PORT, 10) : 8080);
|
|
128
134
|
this.fastify.listen({
|
|
129
|
-
port:
|
|
135
|
+
port: healthPort,
|
|
130
136
|
host: "0.0.0.0"
|
|
131
137
|
}, (err) => {
|
|
132
138
|
if (err) {
|
|
133
139
|
this.log.error(err);
|
|
134
|
-
|
|
140
|
+
this.emit("fatal-error", {
|
|
141
|
+
error: err,
|
|
142
|
+
message: "Failed to start health check server"
|
|
143
|
+
});
|
|
135
144
|
}
|
|
136
145
|
});
|
|
137
146
|
}
|
|
@@ -217,7 +226,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
217
226
|
let height, timestamp;
|
|
218
227
|
if (this.isMinimal(this.blockQueue)) {
|
|
219
228
|
const timeoutPromise = new Promise((resolve, reject) => {
|
|
220
|
-
setTimeout(reject,
|
|
229
|
+
setTimeout(reject, require_constants.QUEUE_DEQUEUE_TIMEOUT_MS, []);
|
|
221
230
|
});
|
|
222
231
|
const toProcess = await Promise.race([this.blockQueue.dequeue(), timeoutPromise]);
|
|
223
232
|
this.log.silly("Retrieved block data");
|
|
@@ -227,7 +236,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
227
236
|
await this.processBlock(toProcess[0], toProcess[1]);
|
|
228
237
|
} else {
|
|
229
238
|
const timeoutPromise = new Promise((resolve, reject) => {
|
|
230
|
-
setTimeout(reject,
|
|
239
|
+
setTimeout(reject, require_constants.QUEUE_DEQUEUE_TIMEOUT_MS, []);
|
|
231
240
|
});
|
|
232
241
|
const toProcess = await Promise.race([this.blockQueue.dequeue(), timeoutPromise]);
|
|
233
242
|
this.log.silly("Retrieved block data");
|
|
@@ -237,7 +246,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
237
246
|
timestamp = (0, __cosmjs_tendermint_rpc.toRfc3339WithNanoseconds)(toProcess[0].block.header.time);
|
|
238
247
|
await this.processBlock(toProcess[0], toProcess[1], cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsResponse.decode(toProcess[2]).validators);
|
|
239
248
|
}
|
|
240
|
-
if (height %
|
|
249
|
+
if (height % require_constants.PERIODIC_INTERVALS.LARGE == 0) {
|
|
241
250
|
const hrTime$1 = process.hrtime();
|
|
242
251
|
const newms = hrTime$1[0] * 1e6 + hrTime$1[1] / 1e3;
|
|
243
252
|
const duration = newms - ms;
|
|
@@ -250,12 +259,12 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
250
259
|
timestamp
|
|
251
260
|
});
|
|
252
261
|
}
|
|
253
|
-
if (height %
|
|
262
|
+
if (height % require_constants.PERIODIC_INTERVALS.MEDIUM == 0) await this.asyncEmit("periodic/100", {
|
|
254
263
|
value: null,
|
|
255
264
|
height,
|
|
256
265
|
timestamp
|
|
257
266
|
});
|
|
258
|
-
if (height %
|
|
267
|
+
if (height % require_constants.PERIODIC_INTERVALS.SMALL == 0) await this.asyncEmit("periodic/50", {
|
|
259
268
|
value: null,
|
|
260
269
|
height,
|
|
261
270
|
timestamp
|
|
@@ -284,7 +293,11 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
284
293
|
setTimeout(() => this.start(), this.retryCount * 5e3);
|
|
285
294
|
} else {
|
|
286
295
|
this.log.info("Indexer failed too many times. Exiting.");
|
|
287
|
-
|
|
296
|
+
this.emit("fatal-error", {
|
|
297
|
+
error: /* @__PURE__ */ new Error("Max retry attempts exceeded"),
|
|
298
|
+
message: "Indexer failed too many times",
|
|
299
|
+
retryCount: this.retryCount
|
|
300
|
+
});
|
|
288
301
|
}
|
|
289
302
|
}
|
|
290
303
|
async processBlock(block, block_results, validators) {
|
|
@@ -417,7 +430,7 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
417
430
|
try {
|
|
418
431
|
if (this.isMinimal(this.blockQueue)) {
|
|
419
432
|
const timeoutPromise = new Promise((resolve, reject) => {
|
|
420
|
-
setTimeout(reject,
|
|
433
|
+
setTimeout(reject, require_constants.RPC_TIMEOUT_MS, false);
|
|
421
434
|
});
|
|
422
435
|
const toIndex = Promise.race([Promise.all([this.blockClient.block(i), this.blockClient.blockResults(i)]), timeoutPromise]).catch((e) => {
|
|
423
436
|
this.log.error("Error fetching block: " + i + " : " + e);
|
|
@@ -427,9 +440,9 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
427
440
|
this.blockQueue.enqueue(toIndex);
|
|
428
441
|
} else {
|
|
429
442
|
const timeoutPromise = new Promise((resolve, reject) => {
|
|
430
|
-
setTimeout(reject,
|
|
443
|
+
setTimeout(reject, require_constants.RPC_TIMEOUT_MS, false);
|
|
431
444
|
});
|
|
432
|
-
const q = cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsRequest.fromPartial({ pagination: { limit:
|
|
445
|
+
const q = cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsRequest.fromPartial({ pagination: { limit: require_constants.PAGINATION_LIMITS.VALIDATORS } });
|
|
433
446
|
const vals = cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsRequest.encode(q).finish();
|
|
434
447
|
const toIndex = Promise.race([Promise.all([
|
|
435
448
|
this.blockClient.block(i),
|
|
@@ -532,16 +545,27 @@ var EcleciaIndexer = class extends require_index.EclesiaEmitter {
|
|
|
532
545
|
try {
|
|
533
546
|
const pickers = path.split(".").map((filter) => stream_json_filters_Pick_js.default.pick({ filter }));
|
|
534
547
|
let counter = 0;
|
|
548
|
+
let chunkCounter = 0;
|
|
549
|
+
const chunkProcessor = async (data) => {
|
|
550
|
+
chunkCounter++;
|
|
551
|
+
this.log.debug(`Processing genesis chunk ${chunkCounter}`);
|
|
552
|
+
await processor(data);
|
|
553
|
+
if (chunkCounter % 5 === 0) {
|
|
554
|
+
this.log.debug(`Committing transaction after chunk ${chunkCounter}`);
|
|
555
|
+
await this.config.endTransaction(true);
|
|
556
|
+
await this.config.beginTransaction();
|
|
557
|
+
}
|
|
558
|
+
};
|
|
535
559
|
(0, stream_chain.chain)([
|
|
536
560
|
this.readGenesis(),
|
|
537
561
|
...pickers,
|
|
538
562
|
stream_json_streamers_StreamArray_js.default.streamArray(),
|
|
539
|
-
stream_json_utils_Batch_js.default.batch({ batchSize:
|
|
540
|
-
|
|
563
|
+
stream_json_utils_Batch_js.default.batch({ batchSize: require_constants.GENESIS_BATCH_SIZE }),
|
|
564
|
+
chunkProcessor
|
|
541
565
|
]).on("data", (data) => {
|
|
542
566
|
if (data && Array.isArray(data)) counter = counter + data.length;
|
|
543
567
|
}).on("end", () => {
|
|
544
|
-
this.log.info(`Processed ${counter} entries`);
|
|
568
|
+
this.log.info(`Processed ${counter} entries in ${chunkCounter} chunks`);
|
|
545
569
|
resolve(true);
|
|
546
570
|
});
|
|
547
571
|
} catch (_e) {
|