allow packet zero to be retrieved if it failed as a different number

This commit is contained in:
Lewis Moten
2024-05-17 19:00:17 -04:00
parent b8d675d763
commit bd45432c6e

View File

@@ -127,12 +127,18 @@ export const getFailedPacketIndeces = () => {
return FAILED_SEQUENCES.filter(isPacketInRange);
}
export const getNeededPacketIndeces = () => {
if(!isSizeTrusted()) return getFailedPacketIndeces();
const packetCount = countExpectedPackets();
let packetCount;
if(!isSizeTrusted()) {
packetCount = getFailedPacketIndeces().reduce((max, i) => Math.max(max, i));
} else {
packetCount = countExpectedPackets();
}
let indeces = [];
for(let i = 0; i < packetCount; i++) {
if(SUCCESS_SEQUENCES.includes(i)) continue;
indeces.push(i);
// cut off in case a failed packet returned a high number
if(indeces.length > 20) break;
}
return indeces;
};