envio 3.3.0-alpha.0 → 3.3.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.
@@ -14,6 +14,14 @@ function deriveEffectiveStartBlock(registrationBlock, contractStartBlock) {
14
14
  return Primitive_int.max(Primitive_int.max(registrationBlock, 0), Stdlib_Option.getOr(contractStartBlock, 0));
15
15
  }
16
16
 
17
+ function calculateEstResponseSize(p, fromBlock, toBlock, maxQueryBlockNumber) {
18
+ if (p.prevQueryRange <= 0) {
19
+ return 10000;
20
+ }
21
+ let density = p.prevRangeSize / p.prevQueryRange;
22
+ return ((Stdlib_Option.getOr(toBlock, maxQueryBlockNumber) - fromBlock | 0) + 1 | 0) * density;
23
+ }
24
+
17
25
  function getMinHistoryRange(p) {
18
26
  let match = p.prevQueryRange;
19
27
  let match$1 = p.prevPrevQueryRange;
@@ -69,6 +77,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
69
77
  mutPendingQueries: p1.mutPendingQueries,
70
78
  prevQueryRange: p1.prevQueryRange,
71
79
  prevPrevQueryRange: p1.prevPrevQueryRange,
80
+ prevRangeSize: p1.prevRangeSize,
72
81
  latestBlockRangeUpdateBlock: p1.latestBlockRangeUpdateBlock
73
82
  });
74
83
  completed.push({
@@ -81,6 +90,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
81
90
  mutPendingQueries: p2.mutPendingQueries,
82
91
  prevQueryRange: p2.prevQueryRange,
83
92
  prevPrevQueryRange: p2.prevPrevQueryRange,
93
+ prevRangeSize: p2.prevRangeSize,
84
94
  latestBlockRangeUpdateBlock: p2.latestBlockRangeUpdateBlock
85
95
  });
86
96
  let newId = nextPartitionIndexRef.contents.toString();
@@ -102,6 +112,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
102
112
  mutPendingQueries: [],
103
113
  prevQueryRange: minRange,
104
114
  prevPrevQueryRange: minRange,
115
+ prevRangeSize: 0,
105
116
  latestBlockRangeUpdateBlock: 0
106
117
  };
107
118
  } else {
@@ -115,6 +126,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
115
126
  mutPendingQueries: p1.mutPendingQueries,
116
127
  prevQueryRange: p1.prevQueryRange,
117
128
  prevPrevQueryRange: p1.prevPrevQueryRange,
129
+ prevRangeSize: p1.prevRangeSize,
118
130
  latestBlockRangeUpdateBlock: p1.latestBlockRangeUpdateBlock
119
131
  });
120
132
  continuingBase = p2;
@@ -130,6 +142,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
130
142
  mutPendingQueries: p2.mutPendingQueries,
131
143
  prevQueryRange: p2.prevQueryRange,
132
144
  prevPrevQueryRange: p2.prevPrevQueryRange,
145
+ prevRangeSize: p2.prevRangeSize,
133
146
  latestBlockRangeUpdateBlock: p2.latestBlockRangeUpdateBlock
134
147
  });
135
148
  continuingBase = p1;
@@ -153,6 +166,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
153
166
  mutPendingQueries: continuingBase.mutPendingQueries,
154
167
  prevQueryRange: continuingBase.prevQueryRange,
155
168
  prevPrevQueryRange: continuingBase.prevPrevQueryRange,
169
+ prevRangeSize: continuingBase.prevRangeSize,
156
170
  latestBlockRangeUpdateBlock: continuingBase.latestBlockRangeUpdateBlock
157
171
  });
158
172
  let restId = nextPartitionIndexRef.contents.toString();
@@ -167,6 +181,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
167
181
  mutPendingQueries: [],
168
182
  prevQueryRange: continuingBase.prevQueryRange,
169
183
  prevPrevQueryRange: continuingBase.prevPrevQueryRange,
184
+ prevRangeSize: continuingBase.prevRangeSize,
170
185
  latestBlockRangeUpdateBlock: continuingBase.latestBlockRangeUpdateBlock
171
186
  });
172
187
  return completed;
@@ -183,6 +198,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
183
198
  mutPendingQueries: continuingBase.mutPendingQueries,
184
199
  prevQueryRange: continuingBase.prevQueryRange,
185
200
  prevPrevQueryRange: continuingBase.prevPrevQueryRange,
201
+ prevRangeSize: continuingBase.prevRangeSize,
186
202
  latestBlockRangeUpdateBlock: continuingBase.latestBlockRangeUpdateBlock
187
203
  });
188
204
  return completed;
@@ -320,7 +336,7 @@ function getPendingQueryOrThrow(p, fromBlock) {
320
336
  }
321
337
  }
322
338
 
323
- function handleQueryResponse(optimizedPartitions, query, knownHeight, latestFetchedBlock) {
339
+ function handleQueryResponse(optimizedPartitions, query, knownHeight, itemsCount, latestFetchedBlock) {
324
340
  let partitionId = query.partitionId;
325
341
  let p = optimizedPartitions.entities[partitionId];
326
342
  let p$1 = p !== undefined ? p : Stdlib_JsError.throwWithMessage(`Unexpected case: Couldn't find partition ` + partitionId);
@@ -346,6 +362,7 @@ function handleQueryResponse(optimizedPartitions, query, knownHeight, latestFetc
346
362
  }
347
363
  let updatedPrevQueryRange = shouldUpdateBlockRange ? blockRange : p$1.prevQueryRange;
348
364
  let updatedPrevPrevQueryRange = shouldUpdateBlockRange ? p$1.prevQueryRange : p$1.prevPrevQueryRange;
365
+ let updatedPrevRangeSize = shouldUpdateBlockRange ? itemsCount : p$1.prevRangeSize;
349
366
  let mutPendingQueries = p$1.mutPendingQueries;
350
367
  let latestFetchedBlock$1 = p$1.latestFetchedBlock;
351
368
  while ((() => {
@@ -382,6 +399,7 @@ function handleQueryResponse(optimizedPartitions, query, knownHeight, latestFetc
382
399
  mutPendingQueries: updatedMainPartition_mutPendingQueries,
383
400
  prevQueryRange: updatedPrevQueryRange,
384
401
  prevPrevQueryRange: updatedPrevPrevQueryRange,
402
+ prevRangeSize: updatedPrevRangeSize,
385
403
  latestBlockRangeUpdateBlock: updatedMainPartition_latestBlockRangeUpdateBlock
386
404
  };
387
405
  mutEntities[p$1.id] = updatedMainPartition;
@@ -628,6 +646,7 @@ function createPartitionsFromIndexingAddresses(registeringContractsByContract, d
628
646
  mutPendingQueries: [],
629
647
  prevQueryRange: 0,
630
648
  prevPrevQueryRange: 0,
649
+ prevRangeSize: 0,
631
650
  latestBlockRangeUpdateBlock: 0
632
651
  });
633
652
  nextPartitionIndexRef = nextPartitionIndexRef + 1 | 0;
@@ -678,6 +697,7 @@ function createPartitionsFromIndexingAddresses(registeringContractsByContract, d
678
697
  mutPendingQueries: currentP.mutPendingQueries,
679
698
  prevQueryRange: currentP.prevQueryRange,
680
699
  prevPrevQueryRange: currentP.prevPrevQueryRange,
700
+ prevRangeSize: currentP.prevRangeSize,
681
701
  latestBlockRangeUpdateBlock: currentP.latestBlockRangeUpdateBlock
682
702
  });
683
703
  currentPRef = {
@@ -690,6 +710,7 @@ function createPartitionsFromIndexingAddresses(registeringContractsByContract, d
690
710
  mutPendingQueries: nextP.mutPendingQueries,
691
711
  prevQueryRange: nextP.prevQueryRange,
692
712
  prevPrevQueryRange: nextP.prevPrevQueryRange,
713
+ prevRangeSize: nextP.prevRangeSize,
693
714
  latestBlockRangeUpdateBlock: nextP.latestBlockRangeUpdateBlock
694
715
  };
695
716
  } else {
@@ -703,6 +724,7 @@ function createPartitionsFromIndexingAddresses(registeringContractsByContract, d
703
724
  mutPendingQueries: currentP.mutPendingQueries,
704
725
  prevQueryRange: currentP.prevQueryRange,
705
726
  prevPrevQueryRange: currentP.prevPrevQueryRange,
727
+ prevRangeSize: currentP.prevRangeSize,
706
728
  latestBlockRangeUpdateBlock: currentP.latestBlockRangeUpdateBlock
707
729
  };
708
730
  }
@@ -847,6 +869,7 @@ function registerDynamicContracts(fetchState, items) {
847
869
  mutPendingQueries: p.mutPendingQueries,
848
870
  prevQueryRange: p.prevQueryRange,
849
871
  prevPrevQueryRange: p.prevPrevQueryRange,
872
+ prevRangeSize: p.prevRangeSize,
850
873
  latestBlockRangeUpdateBlock: p.latestBlockRangeUpdateBlock
851
874
  };
852
875
  let addressesByContractName = {};
@@ -861,6 +884,7 @@ function registerDynamicContracts(fetchState, items) {
861
884
  mutPendingQueries: p.mutPendingQueries,
862
885
  prevQueryRange: p.prevQueryRange,
863
886
  prevPrevQueryRange: p.prevPrevQueryRange,
887
+ prevRangeSize: p.prevRangeSize,
864
888
  latestBlockRangeUpdateBlock: p.latestBlockRangeUpdateBlock
865
889
  });
866
890
  }
@@ -875,6 +899,7 @@ function registerDynamicContracts(fetchState, items) {
875
899
  mutPendingQueries: p.mutPendingQueries,
876
900
  prevQueryRange: p.prevQueryRange,
877
901
  prevPrevQueryRange: p.prevPrevQueryRange,
902
+ prevRangeSize: p.prevRangeSize,
878
903
  latestBlockRangeUpdateBlock: p.latestBlockRangeUpdateBlock
879
904
  };
880
905
  }
@@ -908,7 +933,7 @@ function handleQueryResult(fetchState, query, latestFetchedBlock, newItems) {
908
933
  return true;
909
934
  }
910
935
  });
911
- return updateInternal(fetchState, handleQueryResponse(fetchState.optimizedPartitions, query, fetchState.knownHeight, latestFetchedBlock), undefined, newItems$1.length !== 0 ? fetchState.buffer.concat(newItems$1) : undefined, undefined, undefined);
936
+ return updateInternal(fetchState, handleQueryResponse(fetchState.optimizedPartitions, query, fetchState.knownHeight, newItems$1.length, latestFetchedBlock), undefined, newItems$1.length !== 0 ? fetchState.buffer.concat(newItems$1) : undefined, undefined, undefined);
912
937
  }
913
938
 
914
939
  function startFetchingQueries(param, queries) {
@@ -922,6 +947,7 @@ function startFetchingQueries(param, queries) {
922
947
  fromBlock: q.fromBlock,
923
948
  toBlock: q.toBlock,
924
949
  isChunk: q.isChunk,
950
+ estResponseSize: q.estResponseSize,
925
951
  fetchedBlock: undefined
926
952
  };
927
953
  let inserted = false;
@@ -939,7 +965,7 @@ function startFetchingQueries(param, queries) {
939
965
  }
940
966
  }
941
967
 
942
- function pushQueriesForRange(queries, partitionId, rangeFromBlock, rangeEndBlock, maxQueryBlockNumber, maybeChunkRange, selection, addressesByContractName, indexingAddresses) {
968
+ function pushQueriesForRange(queries, partitionId, rangeFromBlock, rangeEndBlock, maxQueryBlockNumber, maybeChunkRange, partition, selection, addressesByContractName, indexingAddresses) {
943
969
  if (rangeFromBlock > maxQueryBlockNumber) {
944
970
  return;
945
971
  }
@@ -967,6 +993,9 @@ function pushQueriesForRange(queries, partitionId, rangeFromBlock, rangeEndBlock
967
993
  fromBlock: chunkFromBlock,
968
994
  toBlock: chunkToBlock,
969
995
  isChunk: true,
996
+ estResponseSize: calculateEstResponseSize(partition, chunkFromBlock, chunkToBlock, maxQueryBlockNumber),
997
+ chainId: 0,
998
+ progress: 0,
970
999
  selection: selection,
971
1000
  addressesByContractName: addressesByContractName,
972
1001
  indexingAddresses: indexingAddresses
@@ -981,6 +1010,9 @@ function pushQueriesForRange(queries, partitionId, rangeFromBlock, rangeEndBlock
981
1010
  fromBlock: rangeFromBlock,
982
1011
  toBlock: rangeEndBlock,
983
1012
  isChunk: rangeEndBlock !== undefined,
1013
+ estResponseSize: calculateEstResponseSize(partition, rangeFromBlock, rangeEndBlock, maxQueryBlockNumber),
1014
+ chainId: 0,
1015
+ progress: 0,
984
1016
  selection: selection,
985
1017
  addressesByContractName: addressesByContractName,
986
1018
  indexingAddresses: indexingAddresses
@@ -992,13 +1024,16 @@ function pushQueriesForRange(queries, partitionId, rangeFromBlock, rangeEndBlock
992
1024
  fromBlock: rangeFromBlock,
993
1025
  toBlock: rangeEndBlock,
994
1026
  isChunk: false,
1027
+ estResponseSize: calculateEstResponseSize(partition, rangeFromBlock, rangeEndBlock, maxQueryBlockNumber),
1028
+ chainId: 0,
1029
+ progress: 0,
995
1030
  selection: selection,
996
1031
  addressesByContractName: addressesByContractName,
997
1032
  indexingAddresses: indexingAddresses
998
1033
  });
999
1034
  }
1000
1035
 
1001
- function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1036
+ function getNextQuery(fetchState, budget, chainPendingBudget) {
1002
1037
  let knownHeight = fetchState.knownHeight;
1003
1038
  let blockLag = fetchState.blockLag;
1004
1039
  let indexingAddresses = fetchState.indexingAddresses;
@@ -1007,10 +1042,7 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1007
1042
  if (headBlockNumber <= 0) {
1008
1043
  return "WaitingForNewBlock";
1009
1044
  }
1010
- if (concurrencyLimit === 0) {
1011
- return "ReachedMaxConcurrency";
1012
- }
1013
- if (bufferLimit <= 0) {
1045
+ if (budget <= 0) {
1014
1046
  return "NothingToQuery";
1015
1047
  }
1016
1048
  let isOnBlockBehindTheHead = fetchState.latestOnBlockBlockNumber < headBlockNumber;
@@ -1018,7 +1050,7 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1018
1050
  let shouldWaitForNewBlock = (
1019
1051
  endBlock !== undefined ? headBlockNumber < endBlock : true
1020
1052
  ) && !isOnBlockBehindTheHead;
1021
- let item = fetchState.buffer[bufferLimit - 1 | 0];
1053
+ let item = fetchState.buffer[(budget + (chainPendingBudget | 0) | 0) - 1 | 0];
1022
1054
  let maxQueryBlockNumber = item !== undefined ? Primitive_int.min(item.blockNumber, knownHeight) : knownHeight;
1023
1055
  let queries = [];
1024
1056
  let partitionsCount = optimizedPartitions.idsInAscOrder.length;
@@ -1080,6 +1112,9 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1080
1112
  fromBlock: chunkFromBlock,
1081
1113
  toBlock: chunkToBlock,
1082
1114
  isChunk: true,
1115
+ estResponseSize: calculateEstResponseSize(p, chunkFromBlock, chunkToBlock, maxQueryBlockNumber),
1116
+ chainId: 0,
1117
+ progress: 0,
1083
1118
  selection: selection,
1084
1119
  addressesByContractName: addressesByContractName,
1085
1120
  indexingAddresses: indexingAddresses
@@ -1093,6 +1128,9 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1093
1128
  fromBlock: rangeFromBlock,
1094
1129
  toBlock: rangeEndBlock,
1095
1130
  isChunk: rangeEndBlock !== undefined,
1131
+ estResponseSize: calculateEstResponseSize(p, rangeFromBlock, rangeEndBlock, maxQueryBlockNumber),
1132
+ chainId: 0,
1133
+ progress: 0,
1096
1134
  selection: selection,
1097
1135
  addressesByContractName: addressesByContractName,
1098
1136
  indexingAddresses: indexingAddresses
@@ -1104,6 +1142,9 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1104
1142
  fromBlock: rangeFromBlock,
1105
1143
  toBlock: rangeEndBlock,
1106
1144
  isChunk: false,
1145
+ estResponseSize: calculateEstResponseSize(p, rangeFromBlock, rangeEndBlock, maxQueryBlockNumber),
1146
+ chainId: 0,
1147
+ progress: 0,
1107
1148
  selection: selection,
1108
1149
  addressesByContractName: addressesByContractName,
1109
1150
  indexingAddresses: indexingAddresses
@@ -1157,6 +1198,9 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1157
1198
  fromBlock: chunkFromBlock$1,
1158
1199
  toBlock: chunkToBlock$1,
1159
1200
  isChunk: true,
1201
+ estResponseSize: calculateEstResponseSize(p, chunkFromBlock$1, chunkToBlock$1, maxQueryBlockNumber),
1202
+ chainId: 0,
1203
+ progress: 0,
1160
1204
  selection: selection$1,
1161
1205
  addressesByContractName: addressesByContractName$1,
1162
1206
  indexingAddresses: indexingAddresses
@@ -1170,6 +1214,9 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1170
1214
  fromBlock: rangeFromBlock$1,
1171
1215
  toBlock: queryEndBlock$2,
1172
1216
  isChunk: queryEndBlock$2 !== undefined,
1217
+ estResponseSize: calculateEstResponseSize(p, rangeFromBlock$1, queryEndBlock$2, maxQueryBlockNumber),
1218
+ chainId: 0,
1219
+ progress: 0,
1173
1220
  selection: selection$1,
1174
1221
  addressesByContractName: addressesByContractName$1,
1175
1222
  indexingAddresses: indexingAddresses
@@ -1181,6 +1228,9 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1181
1228
  fromBlock: rangeFromBlock$1,
1182
1229
  toBlock: queryEndBlock$2,
1183
1230
  isChunk: false,
1231
+ estResponseSize: calculateEstResponseSize(p, rangeFromBlock$1, queryEndBlock$2, maxQueryBlockNumber),
1232
+ chainId: 0,
1233
+ progress: 0,
1184
1234
  selection: selection$1,
1185
1235
  addressesByContractName: addressesByContractName$1,
1186
1236
  indexingAddresses: indexingAddresses
@@ -1202,12 +1252,12 @@ function getNextQuery(fetchState, concurrencyLimit, bufferLimit) {
1202
1252
  } else {
1203
1253
  return "NothingToQuery";
1204
1254
  }
1255
+ } else {
1256
+ return {
1257
+ TAG: "Ready",
1258
+ _0: queries
1259
+ };
1205
1260
  }
1206
- let queries$1 = queries.length > concurrencyLimit ? (queries.sort((a, b) => Primitive_int.compare(a.fromBlock, b.fromBlock)), queries.slice(0, concurrencyLimit)) : queries;
1207
- return {
1208
- TAG: "Ready",
1209
- _0: queries$1
1210
- };
1211
1261
  }
1212
1262
 
1213
1263
  function hasReadyItem(fetchState) {
@@ -1295,6 +1345,7 @@ function make$1(startBlock, endBlock, eventConfigs, addresses, maxAddrInPartitio
1295
1345
  mutPendingQueries: [],
1296
1346
  prevQueryRange: 0,
1297
1347
  prevPrevQueryRange: 0,
1348
+ prevRangeSize: 0,
1298
1349
  latestBlockRangeUpdateBlock: 0
1299
1350
  });
1300
1351
  }
@@ -1402,6 +1453,7 @@ function rollbackPendingQueries(mutPendingQueries, targetBlockNumber) {
1402
1453
  fromBlock: pq.fromBlock,
1403
1454
  toBlock: pq.toBlock,
1404
1455
  isChunk: pq.isChunk,
1456
+ estResponseSize: pq.estResponseSize,
1405
1457
  fetchedBlock: {
1406
1458
  blockNumber: targetBlockNumber,
1407
1459
  blockTimestamp: 0
@@ -1469,6 +1521,7 @@ function rollback(fetchState, targetBlockNumber) {
1469
1521
  mutPendingQueries: rollbackPendingQueries(p.mutPendingQueries, targetBlockNumber),
1470
1522
  prevQueryRange: p.prevQueryRange,
1471
1523
  prevPrevQueryRange: p.prevPrevQueryRange,
1524
+ prevRangeSize: p.prevRangeSize,
1472
1525
  latestBlockRangeUpdateBlock: p.latestBlockRangeUpdateBlock
1473
1526
  });
1474
1527
  }
@@ -1489,6 +1542,7 @@ function rollback(fetchState, targetBlockNumber) {
1489
1542
  mutPendingQueries: rollbackPendingQueries(p.mutPendingQueries, targetBlockNumber),
1490
1543
  prevQueryRange: p.prevQueryRange,
1491
1544
  prevPrevQueryRange: p.prevPrevQueryRange,
1545
+ prevRangeSize: p.prevRangeSize,
1492
1546
  latestBlockRangeUpdateBlock: p.latestBlockRangeUpdateBlock
1493
1547
  });
1494
1548
  }
@@ -1533,6 +1587,7 @@ function resetPendingQueries(fetchState) {
1533
1587
  mutPendingQueries: kept,
1534
1588
  prevQueryRange: partition.prevQueryRange,
1535
1589
  prevPrevQueryRange: partition.prevPrevQueryRange,
1590
+ prevRangeSize: partition.prevRangeSize,
1536
1591
  latestBlockRangeUpdateBlock: partition.latestBlockRangeUpdateBlock
1537
1592
  };
1538
1593
  }
@@ -1619,6 +1674,19 @@ function getProgressPercentage(fetchState) {
1619
1674
  return progress / totalRange;
1620
1675
  }
1621
1676
 
1677
+ function getProgressPercentageAt(fetchState, blockNumber) {
1678
+ let firstEventBlock = fetchState.firstEventBlock;
1679
+ if (firstEventBlock === undefined) {
1680
+ return 0;
1681
+ }
1682
+ let totalRange = fetchState.knownHeight - firstEventBlock | 0;
1683
+ if (totalRange <= 0) {
1684
+ return 0;
1685
+ } else {
1686
+ return (blockNumber - firstEventBlock | 0) / totalRange;
1687
+ }
1688
+ }
1689
+
1622
1690
  function hasFullBatch(fetchState, batchSizeTarget) {
1623
1691
  let item = fetchState.buffer[batchSizeTarget - 1 | 0];
1624
1692
  if (item !== undefined) {
@@ -1672,12 +1740,16 @@ function updateKnownHeight(fetchState, knownHeight) {
1672
1740
  }
1673
1741
  }
1674
1742
 
1743
+ let defaultEstResponseSize = 10000;
1744
+
1675
1745
  let blockItemLogIndex = 16777216;
1676
1746
 
1677
1747
  let maxPendingChunksPerPartition = 10;
1678
1748
 
1679
1749
  export {
1680
1750
  deriveEffectiveStartBlock,
1751
+ defaultEstResponseSize,
1752
+ calculateEstResponseSize,
1681
1753
  getMinHistoryRange,
1682
1754
  getMinQueryRange,
1683
1755
  OptimizedPartitions,
@@ -1710,6 +1782,7 @@ export {
1710
1782
  isFetchingAtHead,
1711
1783
  isReadyToEnterReorgThreshold,
1712
1784
  getProgressPercentage,
1785
+ getProgressPercentageAt,
1713
1786
  sortForBatch,
1714
1787
  getProgressBlockNumberAt,
1715
1788
  updateKnownHeight,
@@ -19,12 +19,11 @@ let start = (state: IndexerState.t) => {
19
19
  launch(state, () =>
20
20
  state
21
21
  ->IndexerState.crossChainState
22
- ->CrossChainState.checkAndFetch(~fetchChain=(~chain, ~concurrencyLimit, ~bufferLimit) =>
22
+ ->CrossChainState.checkAndFetch(~dispatchChain=(~chain, ~action) =>
23
23
  ChainFetching.fetchChain(
24
24
  state,
25
25
  chain,
26
- ~concurrencyLimit,
27
- ~bufferLimit,
26
+ ~action,
28
27
  ~stateId=state->IndexerState.epoch,
29
28
  ~scheduleFetch,
30
29
  ~scheduleProcessing,
@@ -15,7 +15,7 @@ function launch(state, work) {
15
15
 
16
16
  function start(state) {
17
17
  let scheduleFetch = () => {
18
- let work = () => CrossChainState.checkAndFetch(IndexerState.crossChainState(state), (chain, concurrencyLimit, bufferLimit) => ChainFetching.fetchChain(state, chain, concurrencyLimit, bufferLimit, IndexerState.epoch(state), scheduleFetch, scheduleProcessing, scheduleRollback));
18
+ let work = () => CrossChainState.checkAndFetch(IndexerState.crossChainState(state), (chain, action) => ChainFetching.fetchChain(state, chain, action, IndexerState.epoch(state), scheduleFetch, scheduleProcessing, scheduleRollback));
19
19
  if (!IndexerState.isStopped(state)) {
20
20
  work();
21
21
  return;
@@ -116,8 +116,6 @@ let make = (
116
116
  ~chainStates: dict<ChainState.t>,
117
117
  ~isInReorgThreshold: bool,
118
118
  ~isRealtime: bool,
119
- ~maxBackfillConcurrency=Env.maxBackfillConcurrency,
120
- ~maxRealtimeConcurrency=Env.maxRealtimeConcurrency,
121
119
  ~targetBufferSize=CrossChainState.calculateTargetBufferSize(),
122
120
  ~committedCheckpointId=Internal.initialCheckpointId,
123
121
  ~isDevelopmentMode=false,
@@ -160,8 +158,6 @@ let make = (
160
158
  ~chainStates,
161
159
  ~isInReorgThreshold,
162
160
  ~isRealtime,
163
- ~maxBackfillConcurrency,
164
- ~maxRealtimeConcurrency,
165
161
  ~targetBufferSize,
166
162
  ),
167
163
  indexerStartTime: Date.make(),
@@ -194,8 +190,6 @@ let makeFromDbState = (
194
190
  ~shouldUseTui=false,
195
191
  ~exitAfterFirstEventBlock=false,
196
192
  ~reducedPollingInterval=?,
197
- ~maxBackfillConcurrency=Env.maxBackfillConcurrency,
198
- ~maxRealtimeConcurrency=Env.maxRealtimeConcurrency,
199
193
  ~targetBufferSize=CrossChainState.calculateTargetBufferSize(),
200
194
  ~onError,
201
195
  ) => {
@@ -269,8 +263,6 @@ let makeFromDbState = (
269
263
  ~chainStates,
270
264
  ~isInReorgThreshold,
271
265
  ~isRealtime,
272
- ~maxBackfillConcurrency,
273
- ~maxRealtimeConcurrency,
274
266
  ~targetBufferSize,
275
267
  ~committedCheckpointId=initialState.checkpointId,
276
268
  ~isDevelopmentMode,
@@ -53,9 +53,7 @@ function get(self, entityName) {
53
53
  }
54
54
  }
55
55
 
56
- function make$2(config, persistence, chainStates, isInReorgThreshold, isRealtime, maxBackfillConcurrencyOpt, maxRealtimeConcurrencyOpt, targetBufferSizeOpt, committedCheckpointIdOpt, isDevelopmentModeOpt, shouldUseTuiOpt, exitAfterFirstEventBlockOpt, onError) {
57
- let maxBackfillConcurrency = maxBackfillConcurrencyOpt !== undefined ? maxBackfillConcurrencyOpt : Env.maxBackfillConcurrency;
58
- let maxRealtimeConcurrency = maxRealtimeConcurrencyOpt !== undefined ? maxRealtimeConcurrencyOpt : Env.maxRealtimeConcurrency;
56
+ function make$2(config, persistence, chainStates, isInReorgThreshold, isRealtime, targetBufferSizeOpt, committedCheckpointIdOpt, isDevelopmentModeOpt, shouldUseTuiOpt, exitAfterFirstEventBlockOpt, onError) {
59
57
  let targetBufferSize = targetBufferSizeOpt !== undefined ? targetBufferSizeOpt : CrossChainState.calculateTargetBufferSize();
60
58
  let committedCheckpointId = committedCheckpointIdOpt !== undefined ? committedCheckpointIdOpt : Internal.initialCheckpointId;
61
59
  let isDevelopmentMode = isDevelopmentModeOpt !== undefined ? isDevelopmentModeOpt : false;
@@ -84,7 +82,7 @@ function make$2(config, persistence, chainStates, isInReorgThreshold, isRealtime
84
82
  chainMetaDirty: false,
85
83
  chainMetaThrottler: chainMetaThrottler,
86
84
  isProcessing: false,
87
- crossChainState: CrossChainState.make(chainStates, isInReorgThreshold, isRealtime, maxBackfillConcurrency, maxRealtimeConcurrency, targetBufferSize),
85
+ crossChainState: CrossChainState.make(chainStates, isInReorgThreshold, isRealtime, targetBufferSize),
88
86
  rollbackState: "NoRollback",
89
87
  indexerStartTime: new Date(),
90
88
  writeThrottlers: make(),
@@ -97,12 +95,10 @@ function make$2(config, persistence, chainStates, isInReorgThreshold, isRealtime
97
95
  };
98
96
  }
99
97
 
100
- function makeFromDbState(config, persistence, initialState, registrations, isDevelopmentModeOpt, shouldUseTuiOpt, exitAfterFirstEventBlockOpt, reducedPollingInterval, maxBackfillConcurrencyOpt, maxRealtimeConcurrencyOpt, targetBufferSizeOpt, onError) {
98
+ function makeFromDbState(config, persistence, initialState, registrations, isDevelopmentModeOpt, shouldUseTuiOpt, exitAfterFirstEventBlockOpt, reducedPollingInterval, targetBufferSizeOpt, onError) {
101
99
  let isDevelopmentMode = isDevelopmentModeOpt !== undefined ? isDevelopmentModeOpt : false;
102
100
  let shouldUseTui = shouldUseTuiOpt !== undefined ? shouldUseTuiOpt : false;
103
101
  let exitAfterFirstEventBlock = exitAfterFirstEventBlockOpt !== undefined ? exitAfterFirstEventBlockOpt : false;
104
- let maxBackfillConcurrency = maxBackfillConcurrencyOpt !== undefined ? maxBackfillConcurrencyOpt : Env.maxBackfillConcurrency;
105
- let maxRealtimeConcurrency = maxRealtimeConcurrencyOpt !== undefined ? maxRealtimeConcurrencyOpt : Env.maxRealtimeConcurrency;
106
102
  let targetBufferSize = targetBufferSizeOpt !== undefined ? targetBufferSizeOpt : CrossChainState.calculateTargetBufferSize();
107
103
  let isInReorgThreshold = initialState.cleanRun ? false : initialState.chains.some(chain => {
108
104
  let progressBlockNumber = chain.progressBlockNumber;
@@ -144,7 +140,7 @@ function makeFromDbState(config, persistence, initialState, registrations, isDev
144
140
  if (allChainsReady.contents) {
145
141
  Prometheus.ProgressReady.setAllReady();
146
142
  }
147
- return make$2(config, persistence, chainStates, isInReorgThreshold, isRealtime, maxBackfillConcurrency, maxRealtimeConcurrency, targetBufferSize, initialState.checkpointId, isDevelopmentMode, shouldUseTui, exitAfterFirstEventBlock, onError);
143
+ return make$2(config, persistence, chainStates, isInReorgThreshold, isRealtime, targetBufferSize, initialState.checkpointId, isDevelopmentMode, shouldUseTui, exitAfterFirstEventBlock, onError);
148
144
  }
149
145
 
150
146
  function isStale(state, stateId) {
@@ -32,8 +32,6 @@ let make: (
32
32
  ~chainStates: dict<ChainState.t>,
33
33
  ~isInReorgThreshold: bool,
34
34
  ~isRealtime: bool,
35
- ~maxBackfillConcurrency: int=?,
36
- ~maxRealtimeConcurrency: int=?,
37
35
  ~targetBufferSize: int=?,
38
36
  ~committedCheckpointId: Internal.checkpointId=?,
39
37
  ~isDevelopmentMode: bool=?,
@@ -51,8 +49,6 @@ let makeFromDbState: (
51
49
  ~shouldUseTui: bool=?,
52
50
  ~exitAfterFirstEventBlock: bool=?,
53
51
  ~reducedPollingInterval: int=?,
54
- ~maxBackfillConcurrency: int=?,
55
- ~maxRealtimeConcurrency: int=?,
56
52
  ~targetBufferSize: int=?,
57
53
  ~onError: ErrorHandling.t => unit,
58
54
  ) => t
package/src/Main.res.mjs CHANGED
@@ -615,7 +615,7 @@ async function start(persistence, resetOpt, isTestOpt, exitAfterFirstEventBlockO
615
615
  };
616
616
  }, persistence$1, isDevelopmentMode);
617
617
  }
618
- let state = IndexerState.makeFromDbState(config$2, persistence$1, Persistence.getInitializedState(persistence$1), registrations, isDevelopmentMode, shouldUseTui, exitAfterFirstEventBlock, undefined, undefined, undefined, undefined, onError);
618
+ let state = IndexerState.makeFromDbState(config$2, persistence$1, Persistence.getInitializedState(persistence$1), registrations, isDevelopmentMode, shouldUseTui, exitAfterFirstEventBlock, undefined, undefined, onError);
619
619
  if (shouldUseTui) {
620
620
  Tui.start(() => state);
621
621
  }
@@ -351,17 +351,6 @@ module IndexingAddresses = {
351
351
  }
352
352
  }
353
353
 
354
- module IndexingMaxConcurrency = {
355
- let gauge = PromClient.Gauge.makeGauge({
356
- "name": "envio_indexing_max_concurrency",
357
- "help": "The maximum number of concurrent data-source queries across the whole indexer.",
358
- })
359
-
360
- let set = (~maxConcurrency) => {
361
- gauge->PromClient.Gauge.set(maxConcurrency)
362
- }
363
- }
364
-
365
354
  module IndexingConcurrency = {
366
355
  let gauge = SafeGauge.makeOrThrow(
367
356
  ~name="envio_indexing_concurrency",