Skip to content

Commit

Permalink
Filter out duplicate estimates
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Apr 23, 2024
1 parent 6b8004a commit 2d73bdc
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 2d73bdc

Please sign in to comment.