envio 3.0.0-alpha-main-clickhouse-sink → 3.0.0-alpha.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/bin.js +5 -3
- package/evm.schema.json +23 -6
- package/fuel.schema.json +17 -5
- package/index.d.ts +0 -27
- package/index.js +9 -6
- package/package.json +11 -7
- package/rescript.json +4 -3
- package/src/{Address.res.js → Address.res.mjs} +7 -6
- package/src/{Batch.res.js → Batch.res.mjs} +19 -18
- package/src/{ChainMap.res.js → ChainMap.res.mjs} +20 -19
- package/src/{Config.res.js → Config.res.mjs} +11 -10
- package/src/Envio.gen.ts +2 -15
- package/src/Envio.res +0 -36
- package/src/{Envio.res.js → Envio.res.mjs} +5 -16
- package/src/{ErrorHandling.res.js → ErrorHandling.res.mjs} +10 -9
- package/src/EventRegister.res +7 -0
- package/src/{EventRegister.res.js → EventRegister.res.mjs} +29 -18
- package/src/EventRegister.resi +1 -0
- package/src/{EventUtils.res.js → EventUtils.res.mjs} +10 -9
- package/src/{EvmTypes.res.js → EvmTypes.res.mjs} +5 -4
- package/src/{FetchState.res.js → FetchState.res.mjs} +44 -43
- package/src/{Hasura.res.js → Hasura.res.mjs} +25 -24
- package/src/{InMemoryStore.res.js → InMemoryStore.res.mjs} +19 -18
- package/src/{InMemoryTable.res.js → InMemoryTable.res.mjs} +21 -20
- package/src/Internal.gen.ts +1 -3
- package/src/Internal.res +9 -2
- package/src/{Internal.res.js → Internal.res.mjs} +21 -11
- package/src/{LazyLoader.res.js → LazyLoader.res.mjs} +14 -13
- package/src/{LoadManager.res.js → LoadManager.res.mjs} +11 -10
- package/src/{LogSelection.res.js → LogSelection.res.mjs} +14 -13
- package/src/{Logging.res.js → Logging.res.mjs} +37 -36
- package/src/{Persistence.res.js → Persistence.res.mjs} +22 -21
- package/src/{PgStorage.res.js → PgStorage.res.mjs} +58 -57
- package/src/Platform.res +4 -5
- package/src/{Platform.res.js → Platform.res.mjs} +10 -10
- package/src/{Prometheus.res.js → Prometheus.res.mjs} +66 -65
- package/src/{ReorgDetection.res.js → ReorgDetection.res.mjs} +12 -11
- package/src/{SafeCheckpointTracking.res.js → SafeCheckpointTracking.res.mjs} +6 -5
- package/src/{Sink.res.js → Sink.res.mjs} +6 -5
- package/src/{TableIndices.res.js → TableIndices.res.mjs} +8 -7
- package/src/{Throttler.res.js → Throttler.res.mjs} +7 -6
- package/src/{Time.res.js → Time.res.mjs} +8 -7
- package/src/{TopicFilter.res.js → TopicFilter.res.mjs} +18 -17
- package/src/Utils.res +40 -0
- package/src/{Utils.res.js → Utils.res.mjs} +68 -34
- package/src/bindings/BigDecimal.gen.ts +2 -2
- package/src/bindings/BigDecimal.res +5 -5
- package/src/bindings/BigDecimal.res.d.mts +5 -0
- package/src/bindings/{BigDecimal.res.js → BigDecimal.res.mjs} +10 -9
- package/src/bindings/BigInt.gen.ts +2 -2
- package/src/bindings/BigInt.res.d.mts +5 -0
- package/src/bindings/{BigInt.res.js → BigInt.res.mjs} +25 -24
- package/src/bindings/ClickHouse.res +2 -2
- package/src/bindings/{ClickHouse.res.js → ClickHouse.res.mjs} +22 -21
- package/src/bindings/Ethers.gen.ts +2 -2
- package/src/bindings/Ethers.res.d.mts +5 -0
- package/src/bindings/{Ethers.res.js → Ethers.res.mjs} +18 -17
- package/src/bindings/{Hrtime.res.js → Hrtime.res.mjs} +13 -12
- package/src/bindings/{Lodash.res.js → Lodash.res.mjs} +4 -3
- package/src/bindings/NodeJs.res +13 -1
- package/src/bindings/NodeJs.res.mjs +48 -0
- package/src/bindings/Pino.res +6 -6
- package/src/bindings/{Pino.res.js → Pino.res.mjs} +16 -15
- package/src/bindings/Postgres.res +2 -2
- package/src/bindings/{Postgres.res.js → Postgres.res.mjs} +4 -3
- package/src/bindings/{PromClient.res.js → PromClient.res.mjs} +6 -5
- package/src/bindings/{Promise.res.js → Promise.res.mjs} +6 -5
- package/src/bindings/{SDSL.res.js → SDSL.res.mjs} +3 -2
- package/src/bindings/{Viem.res.js → Viem.res.mjs} +9 -8
- package/src/bindings/vendored-lodash-fns.js +3 -35
- package/src/db/{EntityHistory.res.js → EntityHistory.res.mjs} +21 -20
- package/src/db/InternalTable.gen.ts +2 -2
- package/src/db/InternalTable.res +0 -2
- package/src/db/{InternalTable.res.js → InternalTable.res.mjs} +19 -19
- package/src/db/{Schema.res.js → Schema.res.mjs} +10 -9
- package/src/db/{Table.res.js → Table.res.mjs} +34 -33
- package/src/sources/{EventRouter.res.js → EventRouter.res.mjs} +17 -16
- package/src/sources/{Fuel.res.js → Fuel.res.mjs} +6 -5
- package/src/sources/{HyperFuel.res.js → HyperFuel.res.mjs} +14 -13
- package/src/sources/{HyperFuelClient.res.js → HyperFuelClient.res.mjs} +7 -6
- package/src/sources/{HyperFuelSource.res.js → HyperFuelSource.res.mjs} +28 -27
- package/src/sources/{HyperSync.res.js → HyperSync.res.mjs} +21 -20
- package/src/sources/HyperSyncClient.gen.ts +1 -1
- package/src/sources/HyperSyncClient.res +78 -20
- package/src/sources/{HyperSyncClient.res.js → HyperSyncClient.res.mjs} +32 -15
- package/src/sources/{HyperSyncJsonApi.res.js → HyperSyncJsonApi.res.mjs} +10 -9
- package/src/sources/HyperSyncSource.res +77 -9
- package/src/sources/{HyperSyncSource.res.js → HyperSyncSource.res.mjs} +99 -38
- package/src/sources/{Rpc.res.js → Rpc.res.mjs} +16 -15
- package/src/sources/{RpcSource.res.js → RpcSource.res.mjs} +40 -39
- package/src/sources/Source.res +1 -1
- package/src/sources/{Source.res.js → Source.res.mjs} +4 -3
- package/src/sources/SourceManager.res +12 -1
- package/src/sources/{SourceManager.res.js → SourceManager.res.mjs} +32 -21
- package/src/sources/vendored-fuel-abi-coder.js +94 -149
- package/src/vendored/{Rest.res.js → Rest.res.mjs} +12 -11
- package/src/bindings/NodeJs.res.js +0 -35
- /package/src/{Change.res.js → Change.res.mjs} +0 -0
- /package/src/{Indexer.res.js → Indexer.res.mjs} +0 -0
- /package/src/bindings/{Express.res.js → Express.res.mjs} +0 -0
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var HyperSyncJsonApi = require("./HyperSyncJsonApi.res.js");
|
|
21
|
-
var Caml_js_exceptions = require("rescript/lib/js/caml_js_exceptions.js");
|
|
3
|
+
import * as Viem from "../bindings/Viem.res.mjs";
|
|
4
|
+
import * as Utils from "../Utils.res.mjs";
|
|
5
|
+
import * as Hrtime from "../bindings/Hrtime.res.mjs";
|
|
6
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
7
|
+
import * as Source from "./Source.res.mjs";
|
|
8
|
+
import * as Logging from "../Logging.res.mjs";
|
|
9
|
+
import * as HyperSync from "./HyperSync.res.mjs";
|
|
10
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
11
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
12
|
+
import * as EventRouter from "./EventRouter.res.mjs";
|
|
13
|
+
import * as LogSelection from "../LogSelection.res.mjs";
|
|
14
|
+
import * as ErrorHandling from "../ErrorHandling.res.mjs";
|
|
15
|
+
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
|
|
16
|
+
import * as HyperSyncClient from "./HyperSyncClient.res.mjs";
|
|
17
|
+
import * as Caml_splice_call from "rescript/lib/es6/caml_splice_call.js";
|
|
18
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
22
19
|
|
|
23
20
|
function getSelectionConfig(selection, chain) {
|
|
24
21
|
var nonOptionalBlockFieldNames = new Set();
|
|
@@ -123,7 +120,62 @@ function memoGetSelectionConfig(chain) {
|
|
|
123
120
|
};
|
|
124
121
|
}
|
|
125
122
|
|
|
126
|
-
function
|
|
123
|
+
async function makeInternal(client) {
|
|
124
|
+
return {
|
|
125
|
+
heightStream: await client.streamHeight(),
|
|
126
|
+
currentHeight: 0,
|
|
127
|
+
errMessage: undefined
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function start(state, chainId) {
|
|
132
|
+
while(true) {
|
|
133
|
+
var height = await state.heightStream.recv();
|
|
134
|
+
if (typeof height !== "object") {
|
|
135
|
+
Logging.trace({
|
|
136
|
+
msg: "HyperSync height stream is connected",
|
|
137
|
+
chainId: chainId
|
|
138
|
+
});
|
|
139
|
+
state.errMessage = undefined;
|
|
140
|
+
} else if (height.type === "Height") {
|
|
141
|
+
state.currentHeight = height.height;
|
|
142
|
+
} else {
|
|
143
|
+
var errorMsg = height.errorMsg;
|
|
144
|
+
Logging.trace({
|
|
145
|
+
msg: "HyperSync height stream is reconnecting",
|
|
146
|
+
err: errorMsg,
|
|
147
|
+
delayMillis: height.delayMillis,
|
|
148
|
+
chainId: chainId
|
|
149
|
+
});
|
|
150
|
+
state.errMessage = errorMsg;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function make(client, chainId) {
|
|
156
|
+
var state = await makeInternal(client);
|
|
157
|
+
start(state, chainId);
|
|
158
|
+
return state;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function getHeight(state) {
|
|
162
|
+
while(state.currentHeight === 0 && Belt_Option.isNone(state.errMessage)) {
|
|
163
|
+
await Utils.delay(200);
|
|
164
|
+
};
|
|
165
|
+
var errMessage = state.errMessage;
|
|
166
|
+
if (errMessage !== undefined) {
|
|
167
|
+
return Js_exn.raiseError(errMessage);
|
|
168
|
+
} else {
|
|
169
|
+
return state.currentHeight;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var HeightState = {
|
|
174
|
+
make: make,
|
|
175
|
+
getHeight: getHeight
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
function make$1(param) {
|
|
127
179
|
var lowercaseAddresses = param.lowercaseAddresses;
|
|
128
180
|
var eventRouter = param.eventRouter;
|
|
129
181
|
var shouldUseHypersyncClientDecoder = param.shouldUseHypersyncClientDecoder;
|
|
@@ -132,7 +184,7 @@ function make(param) {
|
|
|
132
184
|
var chain = param.chain;
|
|
133
185
|
var getSelectionConfig = memoGetSelectionConfig(chain);
|
|
134
186
|
var apiToken = Belt_Option.getWithDefault(param.apiToken, "3dc856dd-b0ea-494f-b27e-017b8b6b7e07");
|
|
135
|
-
var client = HyperSyncClient.make(endpointUrl, apiToken, param.clientTimeoutMillis, param.clientMaxRetries, !lowercaseAddresses);
|
|
187
|
+
var client = HyperSyncClient.make(endpointUrl, apiToken, param.clientTimeoutMillis, param.clientMaxRetries, !lowercaseAddresses, param.serializationFormat, param.enableQueryCaching, undefined, undefined, undefined);
|
|
136
188
|
var hscDecoder = {
|
|
137
189
|
contents: undefined
|
|
138
190
|
};
|
|
@@ -385,33 +437,42 @@ function make(param) {
|
|
|
385
437
|
var getBlockHashes = function (blockNumbers, logger) {
|
|
386
438
|
return HyperSync.queryBlockDataMulti(endpointUrl, apiToken, blockNumbers, logger).then(HyperSync.mapExn);
|
|
387
439
|
};
|
|
388
|
-
var
|
|
440
|
+
var heightStatePromise = make(client, chain);
|
|
389
441
|
return {
|
|
390
442
|
name: "HyperSync",
|
|
391
443
|
sourceFor: "Sync",
|
|
392
444
|
chain: chain,
|
|
393
445
|
poweredByHyperSync: true,
|
|
394
|
-
pollingInterval:
|
|
446
|
+
pollingInterval: 32,
|
|
395
447
|
getBlockHashes: getBlockHashes,
|
|
396
448
|
getHeightOrThrow: (async function () {
|
|
397
|
-
var
|
|
398
|
-
|
|
399
|
-
return
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
449
|
+
var heightState = await heightStatePromise;
|
|
450
|
+
try {
|
|
451
|
+
return await getHeight(heightState);
|
|
452
|
+
}
|
|
453
|
+
catch (raw_exn){
|
|
454
|
+
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
455
|
+
if (exn.RE_EXN_ID === Js_exn.$$Error) {
|
|
456
|
+
if (Belt_Option.getWithDefault(exn._1.message, "").includes("Your token is malformed. For more info: https://docs.envio.dev/docs/HyperSync/api-tokens.")) {
|
|
457
|
+
Logging.error("Your ENVIO_API_TOKEN is malformed. The indexer will not be able to fetch events. Update the token and restart the indexer using 'pnpm envio start'. For more info: https://docs.envio.dev/docs/HyperSync/api-tokens");
|
|
458
|
+
await new Promise((function (param, param$1) {
|
|
459
|
+
|
|
460
|
+
}));
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
throw exn;
|
|
464
|
+
}
|
|
465
|
+
throw exn;
|
|
408
466
|
}
|
|
409
467
|
}),
|
|
410
468
|
getItemsOrThrow: getItemsOrThrow
|
|
411
469
|
};
|
|
412
470
|
}
|
|
413
471
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
472
|
+
export {
|
|
473
|
+
getSelectionConfig ,
|
|
474
|
+
memoGetSelectionConfig ,
|
|
475
|
+
HeightState ,
|
|
476
|
+
make$1 as make,
|
|
477
|
+
}
|
|
478
|
+
/* Viem Not a pure module */
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import * as Viem from "viem";
|
|
4
|
+
import * as Utils from "../Utils.res.mjs";
|
|
5
|
+
import * as $$BigInt from "../bindings/BigInt.res.mjs";
|
|
6
|
+
import * as Address from "../Address.res.mjs";
|
|
7
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
8
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
9
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
11
10
|
|
|
12
11
|
function makeRpcRoute(method, paramsSchema, resultSchema) {
|
|
13
12
|
var idSchema = S$RescriptSchema.literal(1);
|
|
@@ -188,11 +187,13 @@ var GetBlockHeight = {
|
|
|
188
187
|
route: route$2
|
|
189
188
|
};
|
|
190
189
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
export {
|
|
191
|
+
makeRpcRoute ,
|
|
192
|
+
makeHexSchema ,
|
|
193
|
+
hexBigintSchema ,
|
|
194
|
+
hexIntSchema ,
|
|
195
|
+
GetLogs ,
|
|
196
|
+
GetBlockByNumber ,
|
|
197
|
+
GetBlockHeight ,
|
|
198
|
+
}
|
|
198
199
|
/* hexBigintSchema Not a pure module */
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
import * as Rpc from "./Rpc.res.mjs";
|
|
4
|
+
import * as Caml from "rescript/lib/es6/caml.js";
|
|
5
|
+
import * as Rest from "../vendored/Rest.res.mjs";
|
|
6
|
+
import * as Time from "../Time.res.mjs";
|
|
7
|
+
import * as Viem from "../bindings/Viem.res.mjs";
|
|
8
|
+
import * as Utils from "../Utils.res.mjs";
|
|
9
|
+
import * as Ethers from "../bindings/Ethers.res.mjs";
|
|
10
|
+
import * as Hrtime from "../bindings/Hrtime.res.mjs";
|
|
11
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
12
|
+
import * as Source from "./Source.res.mjs";
|
|
13
|
+
import * as Address from "../Address.res.mjs";
|
|
14
|
+
import * as Logging from "../Logging.res.mjs";
|
|
15
|
+
import * as $$Promise from "../bindings/Promise.res.mjs";
|
|
16
|
+
import * as Belt_Int from "rescript/lib/es6/belt_Int.js";
|
|
17
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
18
|
+
import * as FetchState from "../FetchState.res.mjs";
|
|
19
|
+
import * as LazyLoader from "../LazyLoader.res.mjs";
|
|
20
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
21
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
22
|
+
import * as EventRouter from "./EventRouter.res.mjs";
|
|
23
|
+
import * as LogSelection from "../LogSelection.res.mjs";
|
|
24
|
+
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
|
|
25
|
+
import * as HyperSyncClient from "./HyperSyncClient.res.mjs";
|
|
26
|
+
import * as Caml_splice_call from "rescript/lib/es6/caml_splice_call.js";
|
|
27
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
28
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
30
29
|
|
|
31
30
|
var QueryTimout = /* @__PURE__ */Caml_exceptions.create("RpcSource.QueryTimout");
|
|
32
31
|
|
|
@@ -835,16 +834,18 @@ function make(param) {
|
|
|
835
834
|
};
|
|
836
835
|
}
|
|
837
836
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
837
|
+
export {
|
|
838
|
+
QueryTimout ,
|
|
839
|
+
getKnownBlock ,
|
|
840
|
+
getKnownBlockWithBackoff ,
|
|
841
|
+
getSuggestedBlockIntervalFromExn ,
|
|
842
|
+
maxSuggestedBlockIntervalKey ,
|
|
843
|
+
getNextPage ,
|
|
844
|
+
getSelectionConfig ,
|
|
845
|
+
memoGetSelectionConfig ,
|
|
846
|
+
makeThrowingGetEventBlock ,
|
|
847
|
+
makeThrowingGetEventTransaction ,
|
|
848
|
+
sanitizeUrl ,
|
|
849
|
+
make ,
|
|
850
|
+
}
|
|
850
851
|
/* Rpc Not a pure module */
|
package/src/sources/Source.res
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
|
|
5
4
|
|
|
6
5
|
var GetItemsError = /* @__PURE__ */Caml_exceptions.create("Source.GetItemsError");
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export {
|
|
8
|
+
GetItemsError ,
|
|
9
|
+
}
|
|
9
10
|
/* No side effect */
|
|
@@ -222,11 +222,20 @@ let waitForNewBlock = async (sourceManager: t, ~currentBlockHeight) => {
|
|
|
222
222
|
)
|
|
223
223
|
logger->Logging.childTrace("Initiating check for new blocks.")
|
|
224
224
|
|
|
225
|
+
// Only include Live sources if we've actually synced some blocks
|
|
226
|
+
// (currentBlockHeight > 0 means we've fetched at least one batch)
|
|
227
|
+
// This prevents Live RPC from winning the initial height race and
|
|
228
|
+
// becoming activeSource, which would bypass HyperSync's smart block detection
|
|
229
|
+
let isInitialHeightFetch = currentBlockHeight === 0
|
|
230
|
+
|
|
225
231
|
let syncSources = []
|
|
226
232
|
let fallbackSources = []
|
|
227
233
|
sources->Utils.Set.forEach(source => {
|
|
228
234
|
if (
|
|
229
235
|
source.sourceFor === Sync ||
|
|
236
|
+
// Include Live sources only after initial sync has started
|
|
237
|
+
// Live sources are optimized for real-time indexing with lower latency
|
|
238
|
+
(source.sourceFor === Live && !isInitialHeightFetch) ||
|
|
230
239
|
// Even if the active source is a fallback, still include
|
|
231
240
|
// it to the list. So we don't wait for a timeout again
|
|
232
241
|
// if all main sync sources are still not valid
|
|
@@ -321,7 +330,9 @@ let getNextSyncSource = (
|
|
|
321
330
|
} else if (
|
|
322
331
|
switch source.sourceFor {
|
|
323
332
|
| Sync => true
|
|
324
|
-
|
|
333
|
+
// Live sources should NOT be used for historical sync rotation
|
|
334
|
+
// They are only meant for real-time indexing once synced
|
|
335
|
+
| Live | Fallback => attemptFallbacks || source === initialSource
|
|
325
336
|
}
|
|
326
337
|
) {
|
|
327
338
|
(hasActive.contents ? after : before)->Array.push(source)
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import * as Caml from "rescript/lib/es6/caml.js";
|
|
4
|
+
import * as Utils from "../Utils.res.mjs";
|
|
5
|
+
import * as Hrtime from "../bindings/Hrtime.res.mjs";
|
|
6
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
7
|
+
import * as Source from "./Source.res.mjs";
|
|
8
|
+
import * as Logging from "../Logging.res.mjs";
|
|
9
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
10
|
+
import * as FetchState from "../FetchState.res.mjs";
|
|
11
|
+
import * as Prometheus from "../Prometheus.res.mjs";
|
|
12
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
13
|
+
import * as ErrorHandling from "../ErrorHandling.res.mjs";
|
|
14
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
16
15
|
|
|
17
16
|
function getActiveSource(sourceManager) {
|
|
18
17
|
return sourceManager.activeSource;
|
|
@@ -157,10 +156,11 @@ async function waitForNewBlock(sourceManager, currentBlockHeight) {
|
|
|
157
156
|
currentBlockHeight: currentBlockHeight
|
|
158
157
|
});
|
|
159
158
|
Logging.childTrace(logger, "Initiating check for new blocks.");
|
|
159
|
+
var isInitialHeightFetch = currentBlockHeight === 0;
|
|
160
160
|
var syncSources = [];
|
|
161
161
|
var fallbackSources = [];
|
|
162
162
|
sourceManager.sources.forEach(function (source) {
|
|
163
|
-
if (source.sourceFor === "Sync" || source === sourceManager.activeSource) {
|
|
163
|
+
if (source.sourceFor === "Sync" || source.sourceFor === "Live" && !isInitialHeightFetch || source === sourceManager.activeSource) {
|
|
164
164
|
syncSources.push(source);
|
|
165
165
|
} else {
|
|
166
166
|
fallbackSources.push(source);
|
|
@@ -217,7 +217,16 @@ function getNextSyncSource(sourceManager, initialSource, currentSource, attemptF
|
|
|
217
217
|
}
|
|
218
218
|
var match = source.sourceFor;
|
|
219
219
|
var tmp;
|
|
220
|
-
|
|
220
|
+
switch (match) {
|
|
221
|
+
case "Sync" :
|
|
222
|
+
tmp = true;
|
|
223
|
+
break;
|
|
224
|
+
case "Fallback" :
|
|
225
|
+
case "Live" :
|
|
226
|
+
tmp = attemptFallbacks || source === initialSource;
|
|
227
|
+
break;
|
|
228
|
+
|
|
229
|
+
}
|
|
221
230
|
if (tmp) {
|
|
222
231
|
(
|
|
223
232
|
hasActive.contents ? after : before
|
|
@@ -391,10 +400,12 @@ async function executeQuery(sourceManager, query, currentBlockHeight) {
|
|
|
391
400
|
return responseRef;
|
|
392
401
|
}
|
|
393
402
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
403
|
+
export {
|
|
404
|
+
make ,
|
|
405
|
+
getActiveSource ,
|
|
406
|
+
fetchNext ,
|
|
407
|
+
waitForNewBlock ,
|
|
408
|
+
executeQuery ,
|
|
409
|
+
makeGetHeightRetryInterval ,
|
|
410
|
+
}
|
|
400
411
|
/* Utils Not a pure module */
|