Skip to content

Commit

Permalink
Merge pull request #56 from LN-Zap/fix/fee-min-filter
Browse files Browse the repository at this point in the history
Filter out duplicate estimates
  • Loading branch information
mrfelton authored Apr 23, 2024
2 parents 93286e0 + 2d73bdc commit 7ac2371
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/DataProviderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,10 @@ export class DataProviderManager {
log.debug({ msg: `Estimates for dataPoint ${providerName}`, estimates });

keys.forEach((key) => {
// Only add the estimate if it has a higher confirmation target and a lower fee
// Only add the estimate if it has a higher confirmation target and a lower fee.
if (
(!mergedEstimates[key] && estimates[key]) ||
(mergedEstimates[key] &&
key > Math.max(...Object.keys(mergedEstimates).map(Number)) &&
estimates[key] < Math.min(...Object.values(mergedEstimates)))
key > Math.max(...Object.keys(mergedEstimates).map(Number)) &&
estimates[key] < Math.min(...Object.values(mergedEstimates))
) {
log.debug({
msg: `Adding estimate from ${providerName} with target ${key} and fee ${estimates[key]} to mergedEstimates`,
Expand Down
4 changes: 4 additions & 0 deletions test/DataProviderManager-merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class MockProvider3 implements Provider {
"2": 15,
"3": 5,
"5": 3,
"6": 3,
"7": 3,
});
getAllData = () =>
Promise.resolve({
Expand All @@ -79,6 +81,8 @@ class MockProvider3 implements Provider {
"2": 15,
"3": 5,
"5": 3,
"6": 3,
"7": 3,
},
});
}
Expand Down

0 comments on commit 7ac2371

Please sign in to comment.