@xyo-network/xl1-protocol-sdk 1.24.19 → 1.24.20

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.
@@ -1937,13 +1937,20 @@ var blockRate = (startBlock, endBlock, timeUnit) => {
1937
1937
  const endingBlock = endBlock[0];
1938
1938
  const heightDifference = endingBlock.block - startingBlock.block;
1939
1939
  const timeDifference = endingBlock.$epoch - startingBlock.$epoch;
1940
+ if (timeDifference === 0) {
1941
+ throw new Error("Time difference must be greater than 0");
1942
+ }
1940
1943
  const rate = heightDifference / timeDifference;
1944
+ const timeUnitValue = isDefined8(timeUnit) ? timeUnit : "millis";
1945
+ const returnedTimeDifference = isDefined8(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference;
1946
+ const timePerBlock = returnedTimeDifference / heightDifference;
1941
1947
  return {
1942
1948
  range: asXL1BlockRange([startingBlock.block, endingBlock.block], true),
1943
1949
  span: heightDifference,
1944
1950
  rate: isDefined8(timeUnit) ? rate * rateMultipliers[timeUnit] : rate,
1945
- rateUnit: isDefined8(timeUnit) ? timeUnit : "millis",
1946
- timeDifference: isDefined8(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference
1951
+ timeUnit: timeUnitValue,
1952
+ timeDifference: returnedTimeDifference,
1953
+ timePerBlock
1947
1954
  };
1948
1955
  };
1949
1956
  var getBlockRateBlocks = async (viewer, startBlockHeight, endBlockHeight) => {
@@ -2019,6 +2026,8 @@ var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, t
2019
2026
  );
2020
2027
  };
2021
2028
  var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBlocksBack, toleranceMs, attemptsRemaining) => {
2029
+ console.log(`Attempts remaining: ${attemptsRemaining}, Estimated blocks back: ${estimatedBlocksBack}`);
2030
+ assertEx15(attemptsRemaining < 0, () => "Maximum attempts reached while searching for end block");
2022
2031
  const startBlockEpoch = startBlock.$epoch;
2023
2032
  const estimatedEndBlockNumber = asXL1BlockNumber5(startBlock.block - estimatedBlocksBack, true);
2024
2033
  if (estimatedEndBlockNumber < 0) {