envio 2.31.0 → 2.31.1-rc.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/package.json +5 -5
- package/src/ReorgDetection.res +39 -69
- package/src/ReorgDetection.res.js +30 -53
- package/src/sources/RpcSource.res +38 -30
- package/src/sources/RpcSource.res.js +24 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "v2.31.
|
|
3
|
+
"version": "v2.31.1-rc.1",
|
|
4
4
|
"description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
|
|
5
5
|
"bin": "./bin.js",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://envio.dev",
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"envio-linux-x64": "v2.31.
|
|
29
|
-
"envio-linux-arm64": "v2.31.
|
|
30
|
-
"envio-darwin-x64": "v2.31.
|
|
31
|
-
"envio-darwin-arm64": "v2.31.
|
|
28
|
+
"envio-linux-x64": "v2.31.1-rc.1",
|
|
29
|
+
"envio-linux-arm64": "v2.31.1-rc.1",
|
|
30
|
+
"envio-darwin-x64": "v2.31.1-rc.1",
|
|
31
|
+
"envio-darwin-arm64": "v2.31.1-rc.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@envio-dev/hypersync-client": "0.6.6",
|
package/src/ReorgDetection.res
CHANGED
|
@@ -37,8 +37,6 @@ let reorgDetectedToLogParams = (reorgDetected: reorgDetected, ~shouldRollbackOnR
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
type reorgResult = NoReorg | ReorgDetected(reorgDetected)
|
|
40
|
-
type validBlockError = NotFound | AlreadyReorgedHashes
|
|
41
|
-
type validBlockResult = result<blockDataWithTimestamp, validBlockError>
|
|
42
40
|
|
|
43
41
|
type t = {
|
|
44
42
|
// Whether to rollback on reorg
|
|
@@ -186,83 +184,44 @@ let registerReorgGuard = (
|
|
|
186
184
|
}
|
|
187
185
|
|
|
188
186
|
/**
|
|
189
|
-
Returns the latest block
|
|
190
|
-
If it doesn't exist in the reorg threshold it returns
|
|
187
|
+
Returns the latest block number which matches block number and hashes in the provided array
|
|
188
|
+
If it doesn't exist in the reorg threshold it returns NotFound
|
|
191
189
|
*/
|
|
192
190
|
let getLatestValidScannedBlock = (
|
|
193
|
-
|
|
191
|
+
reorgDetection: t,
|
|
194
192
|
~blockNumbersAndHashes: array<blockDataWithTimestamp>,
|
|
195
|
-
~currentBlockHeight,
|
|
196
|
-
~skipReorgDuplicationCheck=false,
|
|
197
193
|
) => {
|
|
198
194
|
let verifiedDataByBlockNumber = Js.Dict.empty()
|
|
199
195
|
for idx in 0 to blockNumbersAndHashes->Array.length - 1 {
|
|
200
196
|
let blockData = blockNumbersAndHashes->Array.getUnsafe(idx)
|
|
201
197
|
verifiedDataByBlockNumber->Js.Dict.set(blockData.blockNumber->Int.toString, blockData)
|
|
202
198
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
we can skip the reorg duplication check if we're sure that the block hashes query
|
|
215
|
-
is not coming from a different instance. (let's say we tried several times)
|
|
216
|
-
*/
|
|
217
|
-
let isAlreadyReorgedResponse = skipReorgDuplicationCheck
|
|
218
|
-
? false
|
|
219
|
-
: switch self.detectedReorgBlock {
|
|
220
|
-
| Some(detectedReorgBlock) =>
|
|
221
|
-
switch verifiedDataByBlockNumber->Utils.Dict.dangerouslyGetNonOption(
|
|
222
|
-
detectedReorgBlock.blockNumber->Int.toString,
|
|
223
|
-
) {
|
|
224
|
-
| Some(verifiedBlockData) => verifiedBlockData.blockHash === detectedReorgBlock.blockHash
|
|
225
|
-
| None => false
|
|
226
|
-
}
|
|
227
|
-
| None => false
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if isAlreadyReorgedResponse {
|
|
231
|
-
Error(AlreadyReorgedHashes)
|
|
232
|
-
} else {
|
|
233
|
-
let dataByBlockNumber = self->getDataByBlockNumberCopyInThreshold(~currentBlockHeight)
|
|
234
|
-
// Js engine automatically orders numeric object keys
|
|
235
|
-
let ascBlockNumberKeys = dataByBlockNumber->Js.Dict.keys
|
|
236
|
-
|
|
237
|
-
let getPrevScannedBlock = idx =>
|
|
238
|
-
switch ascBlockNumberKeys
|
|
239
|
-
->Belt.Array.get(idx - 1)
|
|
240
|
-
->Option.flatMap(key => {
|
|
241
|
-
// We should already validate that the block number is verified at the point
|
|
242
|
-
verifiedDataByBlockNumber->Utils.Dict.dangerouslyGetNonOption(key)
|
|
243
|
-
}) {
|
|
244
|
-
| Some(data) => Ok(data)
|
|
245
|
-
| None => Error(NotFound)
|
|
199
|
+
// Js engine automatically orders numeric object keys
|
|
200
|
+
let ascBlockNumberKeys = verifiedDataByBlockNumber->Js.Dict.keys
|
|
201
|
+
|
|
202
|
+
let getPrevScannedBlockNumber = idx =>
|
|
203
|
+
ascBlockNumberKeys
|
|
204
|
+
->Belt.Array.get(idx - 1)
|
|
205
|
+
->Option.flatMap(key => {
|
|
206
|
+
// We should already validate that the block number is verified at the point
|
|
207
|
+
switch verifiedDataByBlockNumber->Utils.Dict.dangerouslyGetNonOption(key) {
|
|
208
|
+
| Some(v) => Some(v.blockNumber)
|
|
209
|
+
| None => None
|
|
246
210
|
}
|
|
211
|
+
})
|
|
247
212
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
`Unexpected case. Couldn't find verified hash for block number ${blockNumberKey}`,
|
|
256
|
-
)
|
|
257
|
-
| Some(verifiedBlockData) if verifiedBlockData.blockHash === scannedBlock.blockHash =>
|
|
258
|
-
loop(idx + 1)
|
|
259
|
-
| Some(_) => getPrevScannedBlock(idx)
|
|
260
|
-
}
|
|
261
|
-
| None => getPrevScannedBlock(idx)
|
|
213
|
+
let rec loop = idx => {
|
|
214
|
+
switch ascBlockNumberKeys->Belt.Array.get(idx) {
|
|
215
|
+
| Some(blockNumberKey) =>
|
|
216
|
+
let scannedBlock = reorgDetection.dataByBlockNumber->Js.Dict.unsafeGet(blockNumberKey)
|
|
217
|
+
switch verifiedDataByBlockNumber->Js.Dict.unsafeGet(blockNumberKey) {
|
|
218
|
+
| verifiedBlockData if verifiedBlockData.blockHash === scannedBlock.blockHash => loop(idx + 1)
|
|
219
|
+
| _ => getPrevScannedBlockNumber(idx)
|
|
262
220
|
}
|
|
221
|
+
| None => getPrevScannedBlockNumber(idx)
|
|
263
222
|
}
|
|
264
|
-
loop(0)
|
|
265
223
|
}
|
|
224
|
+
loop(0)
|
|
266
225
|
}
|
|
267
226
|
|
|
268
227
|
/**
|
|
@@ -303,11 +262,22 @@ let rollbackToValidBlockNumber = (
|
|
|
303
262
|
}
|
|
304
263
|
}
|
|
305
264
|
|
|
306
|
-
let
|
|
307
|
-
let
|
|
308
|
-
|
|
265
|
+
let getThresholdBlockNumbersBelowBlock = (self: t, ~blockNumber: int, ~currentBlockHeight) => {
|
|
266
|
+
let arr = []
|
|
267
|
+
|
|
268
|
+
// Js engine automatically orders numeric object keys
|
|
269
|
+
let ascBlockNumberKeys = self.dataByBlockNumber->Js.Dict.keys
|
|
270
|
+
let thresholdBlockNumber = currentBlockHeight - self.maxReorgDepth
|
|
309
271
|
|
|
310
|
-
|
|
272
|
+
for idx in 0 to ascBlockNumberKeys->Array.length - 1 {
|
|
273
|
+
let blockNumberKey = ascBlockNumberKeys->Js.Array2.unsafe_get(idx)
|
|
274
|
+
let scannedBlock = self.dataByBlockNumber->Js.Dict.unsafeGet(blockNumberKey)
|
|
275
|
+
let isInReorgThreshold = scannedBlock.blockNumber >= thresholdBlockNumber
|
|
276
|
+
if isInReorgThreshold && scannedBlock.blockNumber < blockNumber {
|
|
277
|
+
arr->Array.push(scannedBlock.blockNumber)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
arr
|
|
311
281
|
}
|
|
312
282
|
|
|
313
283
|
let getHashByBlockNumber = (reorgDetection: t, ~blockNumber) => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Js_exn = require("rescript/lib/js/js_exn.js");
|
|
5
|
-
var Js_dict = require("rescript/lib/js/js_dict.js");
|
|
6
4
|
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
7
5
|
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
8
6
|
|
|
@@ -109,63 +107,33 @@ function registerReorgGuard(self, reorgGuard, currentBlockHeight) {
|
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
function getLatestValidScannedBlock(
|
|
113
|
-
var skipReorgDuplicationCheck = skipReorgDuplicationCheckOpt !== undefined ? skipReorgDuplicationCheckOpt : false;
|
|
110
|
+
function getLatestValidScannedBlock(reorgDetection, blockNumbersAndHashes) {
|
|
114
111
|
var verifiedDataByBlockNumber = {};
|
|
115
112
|
for(var idx = 0 ,idx_finish = blockNumbersAndHashes.length; idx < idx_finish; ++idx){
|
|
116
113
|
var blockData = blockNumbersAndHashes[idx];
|
|
117
114
|
verifiedDataByBlockNumber[String(blockData.blockNumber)] = blockData;
|
|
118
115
|
}
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
isAlreadyReorgedResponse = false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (isAlreadyReorgedResponse) {
|
|
132
|
-
return {
|
|
133
|
-
TAG: "Error",
|
|
134
|
-
_0: "AlreadyReorgedHashes"
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
var dataByBlockNumber = getDataByBlockNumberCopyInThreshold(self, currentBlockHeight);
|
|
138
|
-
var ascBlockNumberKeys = Object.keys(dataByBlockNumber);
|
|
139
|
-
var getPrevScannedBlock = function (idx) {
|
|
140
|
-
var data = Belt_Option.flatMap(Belt_Array.get(ascBlockNumberKeys, idx - 1 | 0), (function (key) {
|
|
141
|
-
return verifiedDataByBlockNumber[key];
|
|
142
|
-
}));
|
|
143
|
-
if (data !== undefined) {
|
|
144
|
-
return {
|
|
145
|
-
TAG: "Ok",
|
|
146
|
-
_0: data
|
|
147
|
-
};
|
|
148
|
-
} else {
|
|
149
|
-
return {
|
|
150
|
-
TAG: "Error",
|
|
151
|
-
_0: "NotFound"
|
|
152
|
-
};
|
|
153
|
-
}
|
|
116
|
+
var ascBlockNumberKeys = Object.keys(verifiedDataByBlockNumber);
|
|
117
|
+
var getPrevScannedBlockNumber = function (idx) {
|
|
118
|
+
return Belt_Option.flatMap(Belt_Array.get(ascBlockNumberKeys, idx - 1 | 0), (function (key) {
|
|
119
|
+
var v = verifiedDataByBlockNumber[key];
|
|
120
|
+
if (v !== undefined) {
|
|
121
|
+
return v.blockNumber;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}));
|
|
154
125
|
};
|
|
155
126
|
var _idx = 0;
|
|
156
127
|
while(true) {
|
|
157
128
|
var idx$1 = _idx;
|
|
158
129
|
var blockNumberKey = Belt_Array.get(ascBlockNumberKeys, idx$1);
|
|
159
130
|
if (blockNumberKey === undefined) {
|
|
160
|
-
return
|
|
131
|
+
return getPrevScannedBlockNumber(idx$1);
|
|
161
132
|
}
|
|
162
|
-
var scannedBlock = dataByBlockNumber[blockNumberKey];
|
|
163
|
-
var verifiedBlockData
|
|
164
|
-
if (verifiedBlockData
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
if (verifiedBlockData$1.blockHash !== scannedBlock.blockHash) {
|
|
168
|
-
return getPrevScannedBlock(idx$1);
|
|
133
|
+
var scannedBlock = reorgDetection.dataByBlockNumber[blockNumberKey];
|
|
134
|
+
var verifiedBlockData = verifiedDataByBlockNumber[blockNumberKey];
|
|
135
|
+
if (verifiedBlockData.blockHash !== scannedBlock.blockHash) {
|
|
136
|
+
return getPrevScannedBlockNumber(idx$1);
|
|
169
137
|
}
|
|
170
138
|
_idx = idx$1 + 1 | 0;
|
|
171
139
|
continue ;
|
|
@@ -202,11 +170,20 @@ function rollbackToValidBlockNumber(param, blockNumber) {
|
|
|
202
170
|
};
|
|
203
171
|
}
|
|
204
172
|
|
|
205
|
-
function
|
|
206
|
-
var
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
173
|
+
function getThresholdBlockNumbersBelowBlock(self, blockNumber, currentBlockHeight) {
|
|
174
|
+
var arr = [];
|
|
175
|
+
var ascBlockNumberKeys = Object.keys(self.dataByBlockNumber);
|
|
176
|
+
var thresholdBlockNumber = currentBlockHeight - self.maxReorgDepth | 0;
|
|
177
|
+
for(var idx = 0 ,idx_finish = ascBlockNumberKeys.length; idx < idx_finish; ++idx){
|
|
178
|
+
var blockNumberKey = ascBlockNumberKeys[idx];
|
|
179
|
+
var scannedBlock = self.dataByBlockNumber[blockNumberKey];
|
|
180
|
+
var isInReorgThreshold = scannedBlock.blockNumber >= thresholdBlockNumber;
|
|
181
|
+
if (isInReorgThreshold && scannedBlock.blockNumber < blockNumber) {
|
|
182
|
+
arr.push(scannedBlock.blockNumber);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
return arr;
|
|
210
187
|
}
|
|
211
188
|
|
|
212
189
|
function getHashByBlockNumber(reorgDetection, blockNumber) {
|
|
@@ -224,6 +201,6 @@ exports.getDataByBlockNumberCopyInThreshold = getDataByBlockNumberCopyInThreshol
|
|
|
224
201
|
exports.registerReorgGuard = registerReorgGuard;
|
|
225
202
|
exports.getLatestValidScannedBlock = getLatestValidScannedBlock;
|
|
226
203
|
exports.rollbackToValidBlockNumber = rollbackToValidBlockNumber;
|
|
227
|
-
exports.
|
|
204
|
+
exports.getThresholdBlockNumbersBelowBlock = getThresholdBlockNumbersBelowBlock;
|
|
228
205
|
exports.getHashByBlockNumber = getHashByBlockNumber;
|
|
229
206
|
/* No side effect */
|
|
@@ -522,35 +522,38 @@ let make = (
|
|
|
522
522
|
},
|
|
523
523
|
)
|
|
524
524
|
|
|
525
|
-
let
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
{
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
525
|
+
let makeBlockLoader = () =>
|
|
526
|
+
LazyLoader.make(
|
|
527
|
+
~loaderFn=blockNumber =>
|
|
528
|
+
getKnownBlockWithBackoff(
|
|
529
|
+
~provider,
|
|
530
|
+
~sourceName=name,
|
|
531
|
+
~chain,
|
|
532
|
+
~backoffMsOnFailure=1000,
|
|
533
|
+
~blockNumber,
|
|
534
|
+
~lowercaseAddresses,
|
|
535
|
+
),
|
|
536
|
+
~onError=(am, ~exn) => {
|
|
537
|
+
Logging.error({
|
|
538
|
+
"err": exn->Utils.prettifyExn,
|
|
539
|
+
"msg": `EE1100: Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in ${(am._retryDelayMillis / 1000)
|
|
540
|
+
->Belt.Int.toString} seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the "suggestedFix" in the metadata of this command`,
|
|
541
|
+
"source": name,
|
|
542
|
+
"chainId": chain->ChainMap.Chain.toChainId,
|
|
543
|
+
"metadata": {
|
|
544
|
+
{
|
|
545
|
+
"asyncTaskName": "blockLoader: fetching block data - `getBlock` rpc call",
|
|
546
|
+
"suggestedFix": "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint.",
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
})
|
|
550
|
+
},
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
let blockLoader = ref(makeBlockLoader())
|
|
551
554
|
|
|
552
555
|
let getEventBlockOrThrow = makeThrowingGetEventBlock(~getBlock=blockNumber =>
|
|
553
|
-
blockLoader->LazyLoader.get(blockNumber)
|
|
556
|
+
blockLoader.contents->LazyLoader.get(blockNumber)
|
|
554
557
|
)
|
|
555
558
|
let getEventTransactionOrThrow = makeThrowingGetEventTransaction(
|
|
556
559
|
~getTransactionFields=Ethers.JsonRpcProvider.makeGetTransactionFields(
|
|
@@ -625,7 +628,7 @@ let make = (
|
|
|
625
628
|
|
|
626
629
|
let firstBlockParentPromise =
|
|
627
630
|
fromBlock > 0
|
|
628
|
-
? blockLoader->LazyLoader.get(fromBlock - 1)->Promise.thenResolve(res => res->Some)
|
|
631
|
+
? blockLoader.contents->LazyLoader.get(fromBlock - 1)->Promise.thenResolve(res => res->Some)
|
|
629
632
|
: Promise.resolve(None)
|
|
630
633
|
|
|
631
634
|
let {getLogSelectionOrThrow} = getSelectionConfig(selection)
|
|
@@ -636,7 +639,7 @@ let make = (
|
|
|
636
639
|
~toBlock=suggestedToBlock,
|
|
637
640
|
~addresses,
|
|
638
641
|
~topicQuery,
|
|
639
|
-
~loadBlock=blockNumber => blockLoader->LazyLoader.get(blockNumber),
|
|
642
|
+
~loadBlock=blockNumber => blockLoader.contents->LazyLoader.get(blockNumber),
|
|
640
643
|
~syncConfig,
|
|
641
644
|
~provider,
|
|
642
645
|
~mutSuggestedBlockIntervals,
|
|
@@ -873,8 +876,13 @@ let make = (
|
|
|
873
876
|
}
|
|
874
877
|
|
|
875
878
|
let getBlockHashes = (~blockNumbers, ~logger as _currentlyUnusedLogger) => {
|
|
879
|
+
// Clear cache by creating a fresh LazyLoader
|
|
880
|
+
// This is important, since we call this
|
|
881
|
+
// function when a reorg is detected
|
|
882
|
+
blockLoader := makeBlockLoader()
|
|
883
|
+
|
|
876
884
|
blockNumbers
|
|
877
|
-
->Array.map(blockNum => blockLoader->LazyLoader.get(blockNum))
|
|
885
|
+
->Array.map(blockNum => blockLoader.contents->LazyLoader.get(blockNum))
|
|
878
886
|
->Promise.all
|
|
879
887
|
->Promise.thenResolve(blocks => {
|
|
880
888
|
blocks
|
|
@@ -533,22 +533,27 @@ function make(param) {
|
|
|
533
533
|
}
|
|
534
534
|
});
|
|
535
535
|
}), undefined, undefined, undefined, undefined);
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
536
|
+
var makeBlockLoader = function () {
|
|
537
|
+
return LazyLoader.make((function (blockNumber) {
|
|
538
|
+
return getKnownBlockWithBackoff(provider, name, chain, blockNumber, 1000, lowercaseAddresses);
|
|
539
|
+
}), (function (am, exn) {
|
|
540
|
+
Logging.error({
|
|
541
|
+
err: Utils.prettifyExn(exn),
|
|
542
|
+
msg: "EE1100: Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in " + String(am._retryDelayMillis / 1000 | 0) + " seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the \"suggestedFix\" in the metadata of this command",
|
|
543
|
+
source: name,
|
|
544
|
+
chainId: chain,
|
|
545
|
+
metadata: {
|
|
546
|
+
asyncTaskName: "blockLoader: fetching block data - `getBlock` rpc call",
|
|
547
|
+
suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}), undefined, undefined, undefined, undefined);
|
|
551
|
+
};
|
|
552
|
+
var blockLoader = {
|
|
553
|
+
contents: makeBlockLoader()
|
|
554
|
+
};
|
|
550
555
|
var getEventBlockOrThrow = makeThrowingGetEventBlock(function (blockNumber) {
|
|
551
|
-
return LazyLoader.get(blockLoader, blockNumber);
|
|
556
|
+
return LazyLoader.get(blockLoader.contents, blockNumber);
|
|
552
557
|
});
|
|
553
558
|
var getEventTransactionOrThrow = makeThrowingGetEventTransaction(Ethers.JsonRpcProvider.makeGetTransactionFields((function (__x) {
|
|
554
559
|
return LazyLoader.get(transactionLoader, __x);
|
|
@@ -601,13 +606,13 @@ function make(param) {
|
|
|
601
606
|
var suggestedBlockInterval = maxSuggestedBlockInterval !== undefined ? maxSuggestedBlockInterval : Belt_Option.getWithDefault(mutSuggestedBlockIntervals[partitionId], syncConfig.initialBlockInterval);
|
|
602
607
|
var toBlock$1 = toBlock !== undefined && toBlock < currentBlockHeight ? toBlock : currentBlockHeight;
|
|
603
608
|
var suggestedToBlock = Caml.int_max(Caml.int_min((fromBlock + suggestedBlockInterval | 0) - 1 | 0, toBlock$1), fromBlock);
|
|
604
|
-
var firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader, fromBlock - 1 | 0).then(function (res) {
|
|
609
|
+
var firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader.contents, fromBlock - 1 | 0).then(function (res) {
|
|
605
610
|
return res;
|
|
606
611
|
}) : Promise.resolve(undefined);
|
|
607
612
|
var match = getSelectionConfig(selection);
|
|
608
613
|
var match$1 = match.getLogSelectionOrThrow(addressesByContractName);
|
|
609
614
|
var match$2 = await getNextPage(fromBlock, suggestedToBlock, match$1.addresses, match$1.topicQuery, (function (blockNumber) {
|
|
610
|
-
return LazyLoader.get(blockLoader, blockNumber);
|
|
615
|
+
return LazyLoader.get(blockLoader.contents, blockNumber);
|
|
611
616
|
}), syncConfig, provider, mutSuggestedBlockIntervals, partitionId);
|
|
612
617
|
var latestFetchedBlock = match$2.latestFetchedBlock;
|
|
613
618
|
var logs = match$2.logs;
|
|
@@ -784,8 +789,9 @@ function make(param) {
|
|
|
784
789
|
};
|
|
785
790
|
};
|
|
786
791
|
var getBlockHashes = function (blockNumbers, _currentlyUnusedLogger) {
|
|
792
|
+
blockLoader.contents = makeBlockLoader();
|
|
787
793
|
return $$Promise.$$catch(Promise.all(Belt_Array.map(blockNumbers, (function (blockNum) {
|
|
788
|
-
return LazyLoader.get(blockLoader, blockNum);
|
|
794
|
+
return LazyLoader.get(blockLoader.contents, blockNum);
|
|
789
795
|
}))).then(function (blocks) {
|
|
790
796
|
return {
|
|
791
797
|
TAG: "Ok",
|