Skip to content

Commit

Permalink
Fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Apr 23, 2024
1 parent 746c2a4 commit 6b8004a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ Here are the available configuration options:

### Bitcoin Core settings

| Config Key | Description | Default Value | Environment Variable |
| ----------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| `bitcoind.baseUrl` | The base URL of the bitcoind instance to connect to. | - | `BITCOIND_BASE_URL` |
| `bitcoind.username` | The username to use for authenticating with the bitcoind instance | - | `BITCOIND_USERNAME` |
| `bitcoind.password` | The password to use for authenticating with the bitcoind instance | - | `BITCOIND_PASSWORD` |
| `bitcoind.confTargets` | The block targets to use for history-based fee estimates | `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 144, 288, 432, 504, 576, 720, 864, 1008]` | `BITCOIND_CONF_TARGETS` |
| `bitcoind.estimateMode` | The estimate mode to use for fee estimates (`ECONOMICAL` or `CONSERVATIVE`) | `ECONOMICAL` | `BITCOIND_ESTIMATE_MODE` |
| Config Key | Description | Default Value | Environment Variable |
| ----------------------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| `bitcoind.baseUrl` | The base URL of the bitcoind instance to connect to. | - | `BITCOIND_BASE_URL` |
| `bitcoind.username` | The username to use for authenticating with the bitcoind instance | - | `BITCOIND_USERNAME` |
| `bitcoind.password` | The password to use for authenticating with the bitcoind instance | - | `BITCOIND_PASSWORD` |
| `bitcoind.confTargets` | The block targets to use for history-based fee estimates | `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 144, 288, 432, 504, 576, 720, 864, 1008]` | `BITCOIND_CONF_TARGETS` |
| `bitcoind.estimateMode` | The estimate mode to use for fee estimates (`ECONOMICAL` or `CONSERVATIVE`) | `ECONOMICAL` | `BITCOIND_ESTIMATE_MODE` |

## Development

Expand Down
23 changes: 11 additions & 12 deletions src/lib/DataProviderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,15 @@ export class DataProviderManager {
*/
private filterEstimates(feeEstimates: FeeByBlockTarget): FeeByBlockTarget {
return Object.fromEntries(
Object.entries(feeEstimates).filter(
([blockTarget, estimate]) => {
if (estimate < this.feeMinimum) {
log.warn({
msg: `Fee estimate for target ${blockTarget} was below the minimum of ${this.feeMinimum}.`,
});
return false;
}
return true;
Object.entries(feeEstimates).filter(([blockTarget, estimate]) => {
if (estimate < this.feeMinimum) {
log.warn({
msg: `Fee estimate for target ${blockTarget} was below the minimum of ${this.feeMinimum}.`,
});
return false;
}
)
return true;
}),
);
}

Expand All @@ -201,8 +199,9 @@ export class DataProviderManager {
// 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)))
(mergedEstimates[key] &&
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
2 changes: 1 addition & 1 deletion src/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const log = logger(LOGLEVEL, "server");

const middlewareLogger = (message: string, ...rest: string[]) => {
log.info({ msg: message, ...rest });
}
};

// Log the configuration values.
log.info(config.util.toObject());
Expand Down
7 changes: 6 additions & 1 deletion test/DataProviderManager-merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ class MockProvider3 implements Provider {
const maxHeightDelta = 2;
const feeMultiplier = 2;
const feeMinimum = 2;
const manager = new DataProviderManager({ stdTTL: 0, checkperiod: 0 }, maxHeightDelta, feeMultiplier, feeMinimum);
const manager = new DataProviderManager(
{ stdTTL: 0, checkperiod: 0 },
maxHeightDelta,
feeMultiplier,
feeMinimum,
);
manager.registerProvider(new MockProvider0());
manager.registerProvider(new MockProvider1());
manager.registerProvider(new MockProvider2());
Expand Down
4 changes: 2 additions & 2 deletions test/DataProviderManager-sort.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class MockProvider3 implements Provider {
getBlockHash = () => Promise.resolve("hash2");
getFeeEstimates = () => Promise.resolve({});
getAllData = () =>
Promise.resolve(({
Promise.resolve({
blockHeight: 999,
blockHash: "hash2",
feeEstimates: {},
}));
});
}

const manager = new DataProviderManager({ stdTTL: 0, checkperiod: 0 });
Expand Down

0 comments on commit 6b8004a

Please sign in to comment.