Fix off-by-one error in multi-pool eta calculation

This commit is contained in:
Mononaut 2024-09-17 20:24:35 +00:00
parent d8cfc6e32d
commit b64caf8f4b
No known key found for this signature in database
GPG key ID: A3F058E41374C04E

View file

@ -204,7 +204,7 @@ export class EtaService {
let tailProb = 0; let tailProb = 0;
let Q = 0; let Q = 0;
for (let i = 0; i < max; i++) { for (let i = 0; i <= max; i++) {
// find H_i // find H_i
const H = shares.reduce((total, share) => total + (share.block <= i ? share.hashrateShare : 0), 0); const H = shares.reduce((total, share) => total + (share.block <= i ? share.hashrateShare : 0), 0);
// find S_i // find S_i
@ -215,7 +215,7 @@ export class EtaService {
tailProb += S; tailProb += S;
} }
// at max depth, the transaction is guaranteed to be mined in the next block if it hasn't already // at max depth, the transaction is guaranteed to be mined in the next block if it hasn't already
Q += (1-tailProb); Q += ((max + 1) * (1-tailProb));
const eta = da.timeAvg * Q; // T x Q const eta = da.timeAvg * Q; // T x Q
return { return {