Merge pull request #5530 from mempool/mononaut/fix-acc-eta

Fix off-by-one error in multi-pool eta calculation
This commit is contained in:
softsimon 2024-09-19 01:28:43 +08:00 committed by GitHub
commit 0ccb5618f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 {