envio 2.29.2 → 2.30.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.
- package/evm.schema.json +18 -0
- package/package.json +5 -5
- package/src/Address.res +23 -0
- package/src/Address.res.js +14 -0
- package/src/Batch.res +103 -90
- package/src/Batch.res.js +81 -101
- package/src/FetchState.res +73 -129
- package/src/FetchState.res.js +87 -149
- package/src/Hasura.res +178 -124
- package/src/Hasura.res.js +115 -54
- package/src/Persistence.res +1 -13
- package/src/Persistence.res.js +1 -7
- package/src/PgStorage.res +0 -7
- package/src/PgStorage.res.js +1 -5
- package/src/Utils.res +10 -0
- package/src/Utils.res.js +5 -0
- package/src/bindings/Ethers.res +35 -11
- package/src/bindings/Ethers.res.js +21 -1
- package/src/bindings/PromClient.res +10 -0
- package/src/db/InternalTable.res +1 -59
- package/src/db/InternalTable.res.js +2 -34
- package/src/sources/HyperSyncClient.res +8 -2
- package/src/sources/HyperSyncClient.res.js +3 -2
- package/src/sources/HyperSyncSource.res +8 -1
- package/src/sources/HyperSyncSource.res.js +7 -2
- package/src/sources/RpcSource.res +153 -3
- package/src/sources/RpcSource.res.js +195 -73
package/src/FetchState.res.js
CHANGED
|
@@ -14,30 +14,8 @@ var Caml_int32 = require("rescript/lib/js/caml_int32.js");
|
|
|
14
14
|
var Prometheus = require("./Prometheus.res.js");
|
|
15
15
|
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
16
16
|
var Belt_Result = require("rescript/lib/js/belt_Result.js");
|
|
17
|
-
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
18
17
|
var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
|
|
19
18
|
|
|
20
|
-
function copy(fetchState) {
|
|
21
|
-
return {
|
|
22
|
-
partitions: fetchState.partitions,
|
|
23
|
-
nextPartitionIndex: fetchState.nextPartitionIndex,
|
|
24
|
-
startBlock: fetchState.startBlock,
|
|
25
|
-
endBlock: fetchState.endBlock,
|
|
26
|
-
maxAddrInPartition: fetchState.maxAddrInPartition,
|
|
27
|
-
normalSelection: fetchState.normalSelection,
|
|
28
|
-
indexingContracts: fetchState.indexingContracts,
|
|
29
|
-
contractConfigs: fetchState.contractConfigs,
|
|
30
|
-
dcsToStore: fetchState.dcsToStore,
|
|
31
|
-
chainId: fetchState.chainId,
|
|
32
|
-
latestFullyFetchedBlock: fetchState.latestFullyFetchedBlock,
|
|
33
|
-
latestOnBlockBlockNumber: fetchState.latestOnBlockBlockNumber,
|
|
34
|
-
blockLag: fetchState.blockLag,
|
|
35
|
-
queue: fetchState.queue.slice(0),
|
|
36
|
-
targetBufferSize: fetchState.targetBufferSize,
|
|
37
|
-
onBlockConfigs: fetchState.onBlockConfigs
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
19
|
function mergeIntoPartition(p, target, maxAddrInPartition) {
|
|
42
20
|
if (!p.selection.dependsOnAddresses) {
|
|
43
21
|
return [
|
|
@@ -137,9 +115,9 @@ function bufferBlock(param) {
|
|
|
137
115
|
}
|
|
138
116
|
|
|
139
117
|
function compareBufferItem(a, b) {
|
|
140
|
-
var blockDiff =
|
|
118
|
+
var blockDiff = a.blockNumber - b.blockNumber | 0;
|
|
141
119
|
if (blockDiff === 0) {
|
|
142
|
-
return
|
|
120
|
+
return a.logIndex - b.logIndex | 0;
|
|
143
121
|
} else {
|
|
144
122
|
return blockDiff;
|
|
145
123
|
}
|
|
@@ -149,7 +127,7 @@ function updateInternal(fetchState, partitionsOpt, nextPartitionIndexOpt, indexi
|
|
|
149
127
|
var partitions = partitionsOpt !== undefined ? partitionsOpt : fetchState.partitions;
|
|
150
128
|
var nextPartitionIndex = nextPartitionIndexOpt !== undefined ? nextPartitionIndexOpt : fetchState.nextPartitionIndex;
|
|
151
129
|
var indexingContracts = indexingContractsOpt !== undefined ? indexingContractsOpt : fetchState.indexingContracts;
|
|
152
|
-
var dcsToStore = dcsToStoreOpt !== undefined ?
|
|
130
|
+
var dcsToStore = dcsToStoreOpt !== undefined ? dcsToStoreOpt : fetchState.dcsToStore;
|
|
153
131
|
var blockLag = blockLagOpt !== undefined ? blockLagOpt : fetchState.blockLag;
|
|
154
132
|
var firstPartition = partitions[0];
|
|
155
133
|
var latestFullyFetchedBlock = firstPartition.latestFetchedBlock;
|
|
@@ -166,12 +144,10 @@ function updateInternal(fetchState, partitionsOpt, nextPartitionIndexOpt, indexi
|
|
|
166
144
|
var latestOnBlockBlockNumber;
|
|
167
145
|
if (onBlockConfigs.length !== 0) {
|
|
168
146
|
var mutItems$1 = mutItemsRef;
|
|
169
|
-
var item = (
|
|
170
|
-
mutItems$1 !== undefined ? mutItems$1 : fetchState.queue
|
|
171
|
-
).at(-fetchState.targetBufferSize | 0);
|
|
147
|
+
var item = Belt_Array.get(mutItems$1 !== undefined ? mutItems$1 : fetchState.buffer, fetchState.targetBufferSize - 1 | 0);
|
|
172
148
|
var maxBlockNumber = item !== undefined ? item.blockNumber : latestFullyFetchedBlock$1.blockNumber;
|
|
173
149
|
var mutItems$2 = mutItemsRef;
|
|
174
|
-
var mutItems$3 = mutItems$2 !== undefined ? mutItems$2 : fetchState.
|
|
150
|
+
var mutItems$3 = mutItems$2 !== undefined ? mutItems$2 : fetchState.buffer.slice(0);
|
|
175
151
|
mutItemsRef = mutItems$3;
|
|
176
152
|
var newItemsCounter = 0;
|
|
177
153
|
var latestOnBlockBlockNumber$1 = fetchState.latestOnBlockBlockNumber;
|
|
@@ -210,7 +186,7 @@ function updateInternal(fetchState, partitionsOpt, nextPartitionIndexOpt, indexi
|
|
|
210
186
|
var updatedFetchState_normalSelection = fetchState.normalSelection;
|
|
211
187
|
var updatedFetchState_contractConfigs = fetchState.contractConfigs;
|
|
212
188
|
var updatedFetchState_chainId = fetchState.chainId;
|
|
213
|
-
var
|
|
189
|
+
var updatedFetchState_buffer = mutItems$4 !== undefined ? mutItems$4.sort(compareBufferItem) : fetchState.buffer;
|
|
214
190
|
var updatedFetchState_targetBufferSize = fetchState.targetBufferSize;
|
|
215
191
|
var updatedFetchState_onBlockConfigs = fetchState.onBlockConfigs;
|
|
216
192
|
var updatedFetchState = {
|
|
@@ -227,12 +203,12 @@ function updateInternal(fetchState, partitionsOpt, nextPartitionIndexOpt, indexi
|
|
|
227
203
|
latestFullyFetchedBlock: latestFullyFetchedBlock$1,
|
|
228
204
|
latestOnBlockBlockNumber: latestOnBlockBlockNumber,
|
|
229
205
|
blockLag: blockLag,
|
|
230
|
-
|
|
206
|
+
buffer: updatedFetchState_buffer,
|
|
231
207
|
targetBufferSize: updatedFetchState_targetBufferSize,
|
|
232
208
|
onBlockConfigs: updatedFetchState_onBlockConfigs
|
|
233
209
|
};
|
|
234
210
|
Prometheus.IndexingPartitions.set(partitions.length, fetchState.chainId);
|
|
235
|
-
Prometheus.IndexingBufferSize.set(
|
|
211
|
+
Prometheus.IndexingBufferSize.set(updatedFetchState_buffer.length, fetchState.chainId);
|
|
236
212
|
Prometheus.IndexingBufferBlockNumber.set(latestOnBlockBlockNumber < latestFullyFetchedBlock$1.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock$1.blockNumber, fetchState.chainId);
|
|
237
213
|
return updatedFetchState;
|
|
238
214
|
}
|
|
@@ -404,7 +380,7 @@ function registerDynamicContracts(fetchState, dynamicContracts) {
|
|
|
404
380
|
}
|
|
405
381
|
Prometheus.IndexingAddresses.set(Object.keys(fetchState.indexingContracts).length + dcsToStore.length | 0, fetchState.chainId);
|
|
406
382
|
var existingDcs = fetchState.dcsToStore;
|
|
407
|
-
return updateInternal(fetchState, fetchState.partitions.concat(newPartitions), fetchState.nextPartitionIndex + newPartitions.length | 0, Object.assign(registeringContracts, indexingContracts),
|
|
383
|
+
return updateInternal(fetchState, fetchState.partitions.concat(newPartitions), fetchState.nextPartitionIndex + newPartitions.length | 0, Object.assign(registeringContracts, indexingContracts), existingDcs.length !== 0 ? Belt_Array.concat(existingDcs, dcsToStore) : dcsToStore, undefined, undefined);
|
|
408
384
|
}
|
|
409
385
|
|
|
410
386
|
var UnexpectedPartitionNotFound = /* @__PURE__ */Caml_exceptions.create("FetchState.UnexpectedPartitionNotFound");
|
|
@@ -481,7 +457,7 @@ function handleQueryResult(fetchState, query, latestFetchedBlock, newItems) {
|
|
|
481
457
|
};
|
|
482
458
|
}
|
|
483
459
|
return Belt_Result.map(tmp, (function (partitions) {
|
|
484
|
-
return updateInternal(fetchState, partitions, undefined, undefined, undefined, newItems.length !== 0 ? Belt_Array.concat(fetchState.
|
|
460
|
+
return updateInternal(fetchState, partitions, undefined, undefined, undefined, newItems.length !== 0 ? Belt_Array.concat(fetchState.buffer, newItems) : undefined, undefined);
|
|
485
461
|
}));
|
|
486
462
|
}
|
|
487
463
|
|
|
@@ -569,7 +545,6 @@ function isFullPartition(p, maxAddrInPartition) {
|
|
|
569
545
|
}
|
|
570
546
|
|
|
571
547
|
function getNextQuery(param, concurrencyLimit, currentBlockHeight, stateId) {
|
|
572
|
-
var queue = param.queue;
|
|
573
548
|
var blockLag = param.blockLag;
|
|
574
549
|
var indexingContracts = param.indexingContracts;
|
|
575
550
|
var maxAddrInPartition = param.maxAddrInPartition;
|
|
@@ -630,14 +605,8 @@ function getNextQuery(param, concurrencyLimit, currentBlockHeight, stateId) {
|
|
|
630
605
|
|
|
631
606
|
}
|
|
632
607
|
}
|
|
633
|
-
var
|
|
634
|
-
var maxQueryBlockNumber;
|
|
635
|
-
if (targetBlockIdx < 0) {
|
|
636
|
-
maxQueryBlockNumber = currentBlockHeight;
|
|
637
|
-
} else {
|
|
638
|
-
var item = Belt_Array.get(queue, targetBlockIdx);
|
|
639
|
-
maxQueryBlockNumber = item !== undefined && item.blockNumber < currentBlockHeight ? item.blockNumber : currentBlockHeight;
|
|
640
|
-
}
|
|
608
|
+
var item = Belt_Array.get(param.buffer, param.targetBufferSize - 1 | 0);
|
|
609
|
+
var maxQueryBlockNumber = item !== undefined && item.blockNumber < currentBlockHeight ? item.blockNumber : currentBlockHeight;
|
|
641
610
|
var queries = [];
|
|
642
611
|
var registerPartitionQuery = function (p, mergeTarget) {
|
|
643
612
|
if (!(!checkIsFetchingPartition(p) && p.latestFetchedBlock.blockNumber < maxQueryBlockNumber)) {
|
|
@@ -704,52 +673,61 @@ function getNextQuery(param, concurrencyLimit, currentBlockHeight, stateId) {
|
|
|
704
673
|
}
|
|
705
674
|
}
|
|
706
675
|
|
|
707
|
-
function
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
676
|
+
function getTimestampAt(fetchState, index) {
|
|
677
|
+
var match = Belt_Array.get(fetchState.buffer, index);
|
|
678
|
+
if (match !== undefined) {
|
|
679
|
+
if (match.kind === 0) {
|
|
680
|
+
return match.timestamp;
|
|
681
|
+
} else {
|
|
682
|
+
return Js_exn.raiseError("Block handlers are not supported for ordered multichain mode.");
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
686
|
+
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
687
|
+
return (
|
|
688
|
+
latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? ({
|
|
689
|
+
blockNumber: latestOnBlockBlockNumber,
|
|
690
|
+
blockTimestamp: 0
|
|
691
|
+
}) : latestFullyFetchedBlock
|
|
692
|
+
).blockTimestamp;
|
|
712
693
|
}
|
|
713
694
|
|
|
714
|
-
function
|
|
715
|
-
var
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
719
|
-
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
720
|
-
if (item.blockNumber <= (
|
|
721
|
-
latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock.blockNumber
|
|
722
|
-
)) {
|
|
723
|
-
return {
|
|
724
|
-
TAG: "Item",
|
|
725
|
-
_0: {
|
|
726
|
-
item: item,
|
|
727
|
-
popItemOffQueue: (function () {
|
|
728
|
-
queue.pop();
|
|
729
|
-
})
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
var latestOnBlockBlockNumber$1 = fetchState.latestOnBlockBlockNumber;
|
|
734
|
-
var latestFullyFetchedBlock$1 = fetchState.latestFullyFetchedBlock;
|
|
735
|
-
return {
|
|
736
|
-
TAG: "NoItem",
|
|
737
|
-
latestFetchedBlock: latestOnBlockBlockNumber$1 < latestFullyFetchedBlock$1.blockNumber ? ({
|
|
738
|
-
blockNumber: latestOnBlockBlockNumber$1,
|
|
739
|
-
blockTimestamp: 0
|
|
740
|
-
}) : latestFullyFetchedBlock$1
|
|
741
|
-
};
|
|
742
|
-
} else {
|
|
743
|
-
var latestOnBlockBlockNumber$2 = fetchState.latestOnBlockBlockNumber;
|
|
744
|
-
var latestFullyFetchedBlock$2 = fetchState.latestFullyFetchedBlock;
|
|
745
|
-
return {
|
|
746
|
-
TAG: "NoItem",
|
|
747
|
-
latestFetchedBlock: latestOnBlockBlockNumber$2 < latestFullyFetchedBlock$2.blockNumber ? ({
|
|
748
|
-
blockNumber: latestOnBlockBlockNumber$2,
|
|
749
|
-
blockTimestamp: 0
|
|
750
|
-
}) : latestFullyFetchedBlock$2
|
|
751
|
-
};
|
|
695
|
+
function hasReadyItem(fetchState) {
|
|
696
|
+
var item = Belt_Array.get(fetchState.buffer, 0);
|
|
697
|
+
if (item === undefined) {
|
|
698
|
+
return false;
|
|
752
699
|
}
|
|
700
|
+
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
701
|
+
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
702
|
+
return item.blockNumber <= (
|
|
703
|
+
latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock.blockNumber
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function getReadyItemsCount(fetchState, targetSize, fromItem) {
|
|
708
|
+
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
709
|
+
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
710
|
+
var readyBlockNumber = latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock.blockNumber;
|
|
711
|
+
var acc = 0;
|
|
712
|
+
var isFinished = false;
|
|
713
|
+
while(!isFinished) {
|
|
714
|
+
var item = Belt_Array.get(fetchState.buffer, fromItem + acc | 0);
|
|
715
|
+
if (item !== undefined) {
|
|
716
|
+
var itemBlockNumber = item.blockNumber;
|
|
717
|
+
if (itemBlockNumber <= readyBlockNumber) {
|
|
718
|
+
acc = acc + 1 | 0;
|
|
719
|
+
if (acc === targetSize) {
|
|
720
|
+
readyBlockNumber = itemBlockNumber;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
} else {
|
|
724
|
+
isFinished = true;
|
|
725
|
+
}
|
|
726
|
+
} else {
|
|
727
|
+
isFinished = true;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
return acc;
|
|
753
731
|
}
|
|
754
732
|
|
|
755
733
|
function make(startBlock, endBlock, eventConfigs, contracts, maxAddrInPartition, chainId, targetBufferSize, progressBlockNumberOpt, onBlockConfigsOpt, blockLagOpt) {
|
|
@@ -857,23 +835,23 @@ function make(startBlock, endBlock, eventConfigs, contracts, maxAddrInPartition,
|
|
|
857
835
|
normalSelection: normalSelection,
|
|
858
836
|
indexingContracts: indexingContracts,
|
|
859
837
|
contractConfigs: contractConfigs,
|
|
860
|
-
dcsToStore:
|
|
838
|
+
dcsToStore: [],
|
|
861
839
|
chainId: chainId,
|
|
862
840
|
latestFullyFetchedBlock: latestFetchedBlock,
|
|
863
841
|
latestOnBlockBlockNumber: progressBlockNumber,
|
|
864
842
|
blockLag: blockLag,
|
|
865
|
-
|
|
843
|
+
buffer: [],
|
|
866
844
|
targetBufferSize: targetBufferSize,
|
|
867
845
|
onBlockConfigs: onBlockConfigs
|
|
868
846
|
};
|
|
869
847
|
}
|
|
870
848
|
|
|
871
849
|
function bufferSize(param) {
|
|
872
|
-
return param.
|
|
850
|
+
return param.buffer.length;
|
|
873
851
|
}
|
|
874
852
|
|
|
875
|
-
function pruneQueueFromFirstChangeEvent(
|
|
876
|
-
return Belt_Array.keep(
|
|
853
|
+
function pruneQueueFromFirstChangeEvent(buffer, firstChangeEvent) {
|
|
854
|
+
return Belt_Array.keep(buffer, (function (item) {
|
|
877
855
|
var tmp;
|
|
878
856
|
tmp = item.kind === 0 ? [
|
|
879
857
|
item.blockNumber,
|
|
@@ -949,16 +927,7 @@ function rollback(fetchState, firstChangeEvent) {
|
|
|
949
927
|
var partitions = Belt_Array.keepMap(fetchState.partitions, (function (p) {
|
|
950
928
|
return rollbackPartition(p, firstChangeEvent, addressesToRemove);
|
|
951
929
|
}));
|
|
952
|
-
var
|
|
953
|
-
var tmp;
|
|
954
|
-
if (dcsToStore !== undefined) {
|
|
955
|
-
var filtered = dcsToStore.filter(function (dc) {
|
|
956
|
-
return !addressesToRemove.has(dc.address);
|
|
957
|
-
});
|
|
958
|
-
tmp = filtered.length !== 0 ? filtered : undefined;
|
|
959
|
-
} else {
|
|
960
|
-
tmp = undefined;
|
|
961
|
-
}
|
|
930
|
+
var empty = fetchState.dcsToStore;
|
|
962
931
|
return updateInternal({
|
|
963
932
|
partitions: fetchState.partitions,
|
|
964
933
|
nextPartitionIndex: fetchState.nextPartitionIndex,
|
|
@@ -973,10 +942,12 @@ function rollback(fetchState, firstChangeEvent) {
|
|
|
973
942
|
latestFullyFetchedBlock: fetchState.latestFullyFetchedBlock,
|
|
974
943
|
latestOnBlockBlockNumber: firstChangeEvent.blockNumber - 1 | 0,
|
|
975
944
|
blockLag: fetchState.blockLag,
|
|
976
|
-
|
|
945
|
+
buffer: fetchState.buffer,
|
|
977
946
|
targetBufferSize: fetchState.targetBufferSize,
|
|
978
947
|
onBlockConfigs: fetchState.onBlockConfigs
|
|
979
|
-
}, partitions, undefined, indexingContracts,
|
|
948
|
+
}, partitions, undefined, indexingContracts, empty.length !== 0 ? empty.filter(function (dc) {
|
|
949
|
+
return !addressesToRemove.has(dc.address);
|
|
950
|
+
}) : empty, pruneQueueFromFirstChangeEvent(fetchState.buffer, firstChangeEvent), undefined);
|
|
980
951
|
}
|
|
981
952
|
|
|
982
953
|
function isActivelyIndexing(fetchState) {
|
|
@@ -1005,14 +976,14 @@ function isReadyToEnterReorgThreshold(fetchState, currentBlockHeight) {
|
|
|
1005
976
|
if (currentBlockHeight !== 0 && (
|
|
1006
977
|
endBlock !== undefined && bufferBlockNumber >= endBlock ? true : bufferBlockNumber >= (currentBlockHeight - blockLag | 0)
|
|
1007
978
|
)) {
|
|
1008
|
-
return Utils.$$Array.isEmpty(fetchState.
|
|
979
|
+
return Utils.$$Array.isEmpty(fetchState.buffer);
|
|
1009
980
|
} else {
|
|
1010
981
|
return false;
|
|
1011
982
|
}
|
|
1012
983
|
}
|
|
1013
984
|
|
|
1014
|
-
function
|
|
1015
|
-
var item =
|
|
985
|
+
function hasFullBatch(fetchState, batchSizeTarget) {
|
|
986
|
+
var item = Belt_Array.get(fetchState.buffer, batchSizeTarget - 1 | 0);
|
|
1016
987
|
if (item === undefined) {
|
|
1017
988
|
return false;
|
|
1018
989
|
}
|
|
@@ -1023,23 +994,10 @@ function hasBatchItem(fetchState) {
|
|
|
1023
994
|
);
|
|
1024
995
|
}
|
|
1025
996
|
|
|
1026
|
-
function
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
return false;
|
|
1031
|
-
}
|
|
1032
|
-
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
1033
|
-
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
1034
|
-
return queue[targetBlockIdx].blockNumber <= (
|
|
1035
|
-
latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock.blockNumber
|
|
1036
|
-
);
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
function filterAndSortForUnorderedBatch(fetchStates, maxBatchSize) {
|
|
1040
|
-
return Belt_Array.keepU(fetchStates, hasBatchItem).sort(function (a, b) {
|
|
1041
|
-
var match = hasFullBatch(a, maxBatchSize);
|
|
1042
|
-
var match$1 = hasFullBatch(b, maxBatchSize);
|
|
997
|
+
function filterAndSortForUnorderedBatch(fetchStates, batchSizeTarget) {
|
|
998
|
+
return Belt_Array.keepU(fetchStates, hasReadyItem).sort(function (a, b) {
|
|
999
|
+
var match = hasFullBatch(a, batchSizeTarget);
|
|
1000
|
+
var match$1 = hasFullBatch(b, batchSizeTarget);
|
|
1043
1001
|
if (match) {
|
|
1044
1002
|
if (!match$1) {
|
|
1045
1003
|
return -1;
|
|
@@ -1048,8 +1006,8 @@ function filterAndSortForUnorderedBatch(fetchStates, maxBatchSize) {
|
|
|
1048
1006
|
} else if (match$1) {
|
|
1049
1007
|
return 1;
|
|
1050
1008
|
}
|
|
1051
|
-
var match$2 =
|
|
1052
|
-
var match$3 =
|
|
1009
|
+
var match$2 = a.buffer[0];
|
|
1010
|
+
var match$3 = b.buffer[0];
|
|
1053
1011
|
if (match$2.kind === 0 && match$3.kind === 0) {
|
|
1054
1012
|
return match$2.timestamp - match$3.timestamp | 0;
|
|
1055
1013
|
} else {
|
|
@@ -1062,7 +1020,7 @@ function getProgressBlockNumber(fetchState) {
|
|
|
1062
1020
|
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
1063
1021
|
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
1064
1022
|
var bufferBlockNumber = latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock.blockNumber;
|
|
1065
|
-
var item =
|
|
1023
|
+
var item = Belt_Array.get(fetchState.buffer, 0);
|
|
1066
1024
|
if (item !== undefined && bufferBlockNumber >= item.blockNumber) {
|
|
1067
1025
|
return item.blockNumber - 1 | 0;
|
|
1068
1026
|
} else {
|
|
@@ -1070,28 +1028,8 @@ function getProgressBlockNumber(fetchState) {
|
|
|
1070
1028
|
}
|
|
1071
1029
|
}
|
|
1072
1030
|
|
|
1073
|
-
function getProgressNextBlockLogIndex(fetchState) {
|
|
1074
|
-
var match = Utils.$$Array.last(fetchState.queue);
|
|
1075
|
-
if (match === undefined) {
|
|
1076
|
-
return ;
|
|
1077
|
-
}
|
|
1078
|
-
if (match.kind !== 0) {
|
|
1079
|
-
return ;
|
|
1080
|
-
}
|
|
1081
|
-
var logIndex = match.logIndex;
|
|
1082
|
-
var latestOnBlockBlockNumber = fetchState.latestOnBlockBlockNumber;
|
|
1083
|
-
var latestFullyFetchedBlock = fetchState.latestFullyFetchedBlock;
|
|
1084
|
-
if ((
|
|
1085
|
-
latestOnBlockBlockNumber < latestFullyFetchedBlock.blockNumber ? latestOnBlockBlockNumber : latestFullyFetchedBlock.blockNumber
|
|
1086
|
-
) >= match.blockNumber && logIndex > 0) {
|
|
1087
|
-
return logIndex - 1 | 0;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
1031
|
var blockItemLogIndex = 16777216;
|
|
1093
1032
|
|
|
1094
|
-
exports.copy = copy;
|
|
1095
1033
|
exports.mergeIntoPartition = mergeIntoPartition;
|
|
1096
1034
|
exports.bufferBlockNumber = bufferBlockNumber;
|
|
1097
1035
|
exports.bufferBlock = bufferBlock;
|
|
@@ -1110,8 +1048,9 @@ exports.addressesByContractNameCount = addressesByContractNameCount;
|
|
|
1110
1048
|
exports.addressesByContractNameGetAll = addressesByContractNameGetAll;
|
|
1111
1049
|
exports.isFullPartition = isFullPartition;
|
|
1112
1050
|
exports.getNextQuery = getNextQuery;
|
|
1113
|
-
exports.
|
|
1114
|
-
exports.
|
|
1051
|
+
exports.getTimestampAt = getTimestampAt;
|
|
1052
|
+
exports.hasReadyItem = hasReadyItem;
|
|
1053
|
+
exports.getReadyItemsCount = getReadyItemsCount;
|
|
1115
1054
|
exports.make = make;
|
|
1116
1055
|
exports.bufferSize = bufferSize;
|
|
1117
1056
|
exports.pruneQueueFromFirstChangeEvent = pruneQueueFromFirstChangeEvent;
|
|
@@ -1121,5 +1060,4 @@ exports.isActivelyIndexing = isActivelyIndexing;
|
|
|
1121
1060
|
exports.isReadyToEnterReorgThreshold = isReadyToEnterReorgThreshold;
|
|
1122
1061
|
exports.filterAndSortForUnorderedBatch = filterAndSortForUnorderedBatch;
|
|
1123
1062
|
exports.getProgressBlockNumber = getProgressBlockNumber;
|
|
1124
|
-
exports.getProgressNextBlockLogIndex = getProgressNextBlockLogIndex;
|
|
1125
1063
|
/* Utils Not a pure module */
|