-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
need/triageNeeds initial labeling and prioritizationNeeds initial labeling and prioritization
Description
Nanoseconds are calculated incorrectly. See ipfs/helia-verified-fetch#19 (comment) for more details. Basically,
Some proofs (copy and paste into dev console):
- nanoseconds are
1e9
, or "One billionth of one second".BigInt(1)/*<s>*/ * BigInt(1e9)/*<ns>*/ === (1000000000n)/*<ns>*/ /* 1,000,000,000/*<ns>*/
1000000000/*<ns>*/ * 1e-9/*<ns-to-s>*/ === 1
- milliseconds are "1e6" or "One millionth of one second"
BigInt(1)/*<s>*/ * BigInt(1e6)/*<ms>*/ === 1000000n/*<ms>*/ /* === 1,000,000/*<ms>*/
1000000/*<ms>*/ * 1e-6/*<ms-to-s>*/ === 1
- nanoseconds are
1e6
or "One millionth of one millisecond"BigInt(1)/*<ms>*/ * BigInt(1e6)/*<ns>*/ === 1000000n/*<ns>*/ /* === 1,000,000/*<ms>*/
1000000/*<ns>*/ * 1e-6/*<ns-to-ms>*/ === 1
Line 171 in 16e0e10
const lifetimeNs = (BigInt(ms) * BigInt(100000)) + BigInt(ns ?? '0') |
function lifeTimeNs(ms, ns) {
// BigInt(100000) === BigInt(1e5)
return (BigInt(ms) * BigInt(100000)) + BigInt(ns ?? '0')
}
// should match BigInt(1)/*<ms>*/ * BigInt(1e6)/*<ns>*/ === 1000000n/*<ns>*/
lifeTimeNs(1) === BigInt(1e6) // false,
// returns `100000n` instead of `1000000n`
references:
Metadata
Metadata
Assignees
Labels
need/triageNeeds initial labeling and prioritizationNeeds initial labeling and prioritization