envio 2.27.2 → 2.27.3
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/FetchState.res +24 -4
- package/src/FetchState.res.js +23 -5
- package/src/Utils.res +2 -0
- package/src/Utils.res.js +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "v2.27.
|
|
3
|
+
"version": "v2.27.3",
|
|
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.27.
|
|
29
|
-
"envio-linux-arm64": "v2.27.
|
|
30
|
-
"envio-darwin-x64": "v2.27.
|
|
31
|
-
"envio-darwin-arm64": "v2.27.
|
|
28
|
+
"envio-linux-x64": "v2.27.3",
|
|
29
|
+
"envio-linux-arm64": "v2.27.3",
|
|
30
|
+
"envio-darwin-x64": "v2.27.3",
|
|
31
|
+
"envio-darwin-arm64": "v2.27.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@envio-dev/hypersync-client": "0.6.5",
|
package/src/FetchState.res
CHANGED
|
@@ -258,12 +258,12 @@ let updateInternal = (
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
let
|
|
261
|
+
let bufferSize = queue->Array.length
|
|
262
262
|
Prometheus.IndexingPartitions.set(
|
|
263
263
|
~partitionsCount=partitions->Array.length,
|
|
264
264
|
~chainId=fetchState.chainId,
|
|
265
265
|
)
|
|
266
|
-
Prometheus.IndexingBufferSize.set(~bufferSize
|
|
266
|
+
Prometheus.IndexingBufferSize.set(~bufferSize, ~chainId=fetchState.chainId)
|
|
267
267
|
Prometheus.IndexingBufferBlockNumber.set(
|
|
268
268
|
~blockNumber=latestFullyFetchedBlock.blockNumber,
|
|
269
269
|
~chainId=fetchState.chainId,
|
|
@@ -1086,7 +1086,7 @@ let make = (
|
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
let
|
|
1089
|
+
let bufferSize = ({queue}: t) => queue->Array.length
|
|
1090
1090
|
|
|
1091
1091
|
/**
|
|
1092
1092
|
* Returns the latest block number fetched for the lowest fetcher queue (ie the earliest un-fetched dynamic contract)
|
|
@@ -1207,7 +1207,7 @@ let isActivelyIndexing = ({latestFullyFetchedBlock, endBlock} as fetchState: t)
|
|
|
1207
1207
|
| Some(endBlock) =>
|
|
1208
1208
|
let isPastEndblock = latestFullyFetchedBlock.blockNumber >= endBlock
|
|
1209
1209
|
if isPastEndblock {
|
|
1210
|
-
fetchState->
|
|
1210
|
+
fetchState->bufferSize > 0
|
|
1211
1211
|
} else {
|
|
1212
1212
|
true
|
|
1213
1213
|
}
|
|
@@ -1226,3 +1226,23 @@ let isReadyToEnterReorgThreshold = (
|
|
|
1226
1226
|
} &&
|
|
1227
1227
|
queue->Utils.Array.isEmpty
|
|
1228
1228
|
}
|
|
1229
|
+
|
|
1230
|
+
let filterAndSortForUnorderedBatch = {
|
|
1231
|
+
let hasBatchItem = ({queue, latestFullyFetchedBlock}: t) => {
|
|
1232
|
+
switch queue->Utils.Array.last {
|
|
1233
|
+
| Some(item) => item.blockNumber <= latestFullyFetchedBlock.blockNumber
|
|
1234
|
+
| None => false
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
let compareUnorderedBatchChainPriority = (a: t, b: t) => {
|
|
1239
|
+
// Use unsafe since we filtered out all queues without batch items
|
|
1240
|
+
(a.queue->Utils.Array.lastUnsafe).timestamp - (b.queue->Utils.Array.lastUnsafe).timestamp
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
(fetchStates: array<t>) => {
|
|
1244
|
+
fetchStates
|
|
1245
|
+
->Array.keepU(hasBatchItem)
|
|
1246
|
+
->Js.Array2.sortInPlaceWith(compareUnorderedBatchChainPriority)
|
|
1247
|
+
}
|
|
1248
|
+
}
|
package/src/FetchState.res.js
CHANGED
|
@@ -147,9 +147,9 @@ function updateInternal(fetchState, partitionsOpt, nextPartitionIndexOpt, indexi
|
|
|
147
147
|
var isFetchingAtHead = currentBlockHeight !== undefined ? (
|
|
148
148
|
latestFullyFetchedBlock$1.blockNumber >= currentBlockHeight ? true : fetchState.isFetchingAtHead && checkIsWithinSyncRange(latestFullyFetchedBlock$1, currentBlockHeight)
|
|
149
149
|
) : fetchState.isFetchingAtHead;
|
|
150
|
-
var
|
|
150
|
+
var bufferSize = queue.length;
|
|
151
151
|
Prometheus.IndexingPartitions.set(partitions.length, fetchState.chainId);
|
|
152
|
-
Prometheus.IndexingBufferSize.set(
|
|
152
|
+
Prometheus.IndexingBufferSize.set(bufferSize, fetchState.chainId);
|
|
153
153
|
Prometheus.IndexingBufferBlockNumber.set(latestFullyFetchedBlock$1.blockNumber, fetchState.chainId);
|
|
154
154
|
var item = Utils.$$Array.last(queue);
|
|
155
155
|
return {
|
|
@@ -804,7 +804,7 @@ function make(startBlock, endBlock, eventConfigs, contracts, maxAddrInPartition,
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
-
function
|
|
807
|
+
function bufferSize(param) {
|
|
808
808
|
return param.queue.length;
|
|
809
809
|
}
|
|
810
810
|
|
|
@@ -902,7 +902,7 @@ function isActivelyIndexing(fetchState) {
|
|
|
902
902
|
}
|
|
903
903
|
var isPastEndblock = fetchState.latestFullyFetchedBlock.blockNumber >= endBlock;
|
|
904
904
|
if (isPastEndblock) {
|
|
905
|
-
return
|
|
905
|
+
return bufferSize(fetchState) > 0;
|
|
906
906
|
} else {
|
|
907
907
|
return true;
|
|
908
908
|
}
|
|
@@ -921,6 +921,23 @@ function isReadyToEnterReorgThreshold(param, currentBlockHeight) {
|
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
|
|
924
|
+
function hasBatchItem(param) {
|
|
925
|
+
var item = Utils.$$Array.last(param.queue);
|
|
926
|
+
if (item !== undefined) {
|
|
927
|
+
return item.blockNumber <= param.latestFullyFetchedBlock.blockNumber;
|
|
928
|
+
} else {
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
function compareUnorderedBatchChainPriority(a, b) {
|
|
934
|
+
return Utils.$$Array.lastUnsafe(a.queue).timestamp - Utils.$$Array.lastUnsafe(b.queue).timestamp | 0;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function filterAndSortForUnorderedBatch(fetchStates) {
|
|
938
|
+
return Belt_Array.keepU(fetchStates, hasBatchItem).sort(compareUnorderedBatchChainPriority);
|
|
939
|
+
}
|
|
940
|
+
|
|
924
941
|
exports.copy = copy;
|
|
925
942
|
exports.eventItemGt = eventItemGt;
|
|
926
943
|
exports.mergeSortedEventList = mergeSortedEventList;
|
|
@@ -944,11 +961,12 @@ exports.makeNoItem = makeNoItem;
|
|
|
944
961
|
exports.qItemLt = qItemLt;
|
|
945
962
|
exports.getEarliestEvent = getEarliestEvent;
|
|
946
963
|
exports.make = make;
|
|
947
|
-
exports.
|
|
964
|
+
exports.bufferSize = bufferSize;
|
|
948
965
|
exports.getLatestFullyFetchedBlock = getLatestFullyFetchedBlock;
|
|
949
966
|
exports.pruneQueueFromFirstChangeEvent = pruneQueueFromFirstChangeEvent;
|
|
950
967
|
exports.rollbackPartition = rollbackPartition;
|
|
951
968
|
exports.rollback = rollback;
|
|
952
969
|
exports.isActivelyIndexing = isActivelyIndexing;
|
|
953
970
|
exports.isReadyToEnterReorgThreshold = isReadyToEnterReorgThreshold;
|
|
971
|
+
exports.filterAndSortForUnorderedBatch = filterAndSortForUnorderedBatch;
|
|
954
972
|
/* Utils Not a pure module */
|
package/src/Utils.res
CHANGED
|
@@ -250,6 +250,8 @@ Helper to check if a value exists in an array
|
|
|
250
250
|
|
|
251
251
|
let last = (arr: array<'a>): option<'a> => arr->Belt.Array.get(arr->Array.length - 1)
|
|
252
252
|
|
|
253
|
+
let lastUnsafe = (arr: array<'a>): 'a => arr->Belt.Array.getUnsafe(arr->Array.length - 1)
|
|
254
|
+
|
|
253
255
|
let findReverseWithIndex = (arr: array<'a>, fn: 'a => bool): option<('a, int)> => {
|
|
254
256
|
let rec loop = (index: int) => {
|
|
255
257
|
if index < 0 {
|
package/src/Utils.res.js
CHANGED
|
@@ -268,6 +268,10 @@ function last(arr) {
|
|
|
268
268
|
return Belt_Array.get(arr, arr.length - 1 | 0);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
function lastUnsafe(arr) {
|
|
272
|
+
return arr[arr.length - 1 | 0];
|
|
273
|
+
}
|
|
274
|
+
|
|
271
275
|
function findReverseWithIndex(arr, fn) {
|
|
272
276
|
var _index = arr.length - 1 | 0;
|
|
273
277
|
while(true) {
|
|
@@ -310,6 +314,7 @@ var $$Array$1 = {
|
|
|
310
314
|
awaitEach: awaitEach,
|
|
311
315
|
removeAtIndex: removeAtIndex,
|
|
312
316
|
last: last,
|
|
317
|
+
lastUnsafe: lastUnsafe,
|
|
313
318
|
findReverseWithIndex: findReverseWithIndex,
|
|
314
319
|
interleave: interleave
|
|
315
320
|
};
|