From 6b8004af7ecaf63dde7bdf78fc201ba734cb839f Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Tue, 23 Apr 2024 12:02:04 +0200 Subject: [PATCH] Fix formatting issues --- README.md | 14 +++++++------- src/lib/DataProviderManager.ts | 23 +++++++++++------------ src/server.tsx | 2 +- test/DataProviderManager-merge.test.ts | 7 ++++++- test/DataProviderManager-sort.test.ts | 4 ++-- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 218a708..350ba4c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/lib/DataProviderManager.ts b/src/lib/DataProviderManager.ts index 861371d..802f2e6 100644 --- a/src/lib/DataProviderManager.ts +++ b/src/lib/DataProviderManager.ts @@ -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; + }), ); } @@ -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`, diff --git a/src/server.tsx b/src/server.tsx index 850c016..8e022a2 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -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()); diff --git a/test/DataProviderManager-merge.test.ts b/test/DataProviderManager-merge.test.ts index 88050d2..696ef10 100644 --- a/test/DataProviderManager-merge.test.ts +++ b/test/DataProviderManager-merge.test.ts @@ -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()); diff --git a/test/DataProviderManager-sort.test.ts b/test/DataProviderManager-sort.test.ts index aaeae37..3a66be9 100644 --- a/test/DataProviderManager-sort.test.ts +++ b/test/DataProviderManager-sort.test.ts @@ -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 });