@xyo-network/xl1-protocol-sdk 1.26.20 → 1.26.21
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.
|
@@ -1144,7 +1144,13 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
1144
1144
|
() => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
|
|
1145
1145
|
);
|
|
1146
1146
|
const endBlockEpoch = resolvedEndBlock.$epoch;
|
|
1147
|
+
if (!Number.isFinite(startBlockEpoch) || !Number.isFinite(endBlockEpoch)) {
|
|
1148
|
+
throw new TypeError("Block has missing or invalid $epoch");
|
|
1149
|
+
}
|
|
1147
1150
|
const actualTimeDifference = startBlockEpoch - endBlockEpoch;
|
|
1151
|
+
if (actualTimeDifference === 0) {
|
|
1152
|
+
throw new Error("Start and end blocks have identical timestamps");
|
|
1153
|
+
}
|
|
1148
1154
|
const timeDelta = Math.abs(actualTimeDifference - targetTimeMs);
|
|
1149
1155
|
if (timeDelta <= toleranceMs) {
|
|
1150
1156
|
return resolvedEndBlock.block;
|
|
@@ -1157,6 +1163,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
1157
1163
|
const adjustmentFactor = actualTimeDifference / targetTimeMs;
|
|
1158
1164
|
adjustedBlocksBack = Math.floor(estimatedBlocksBack / adjustmentFactor);
|
|
1159
1165
|
}
|
|
1166
|
+
adjustedBlocksBack = Number.isFinite(adjustedBlocksBack) && adjustedBlocksBack >= 1 ? adjustedBlocksBack : 1;
|
|
1160
1167
|
return await findEndBlockRecursive(
|
|
1161
1168
|
viewer,
|
|
1162
1169
|
startBlock,
|