From 3e46475f9fd348348f12265f72beb9c90748525a Mon Sep 17 00:00:00 2001 From: Dominique <5765435+dpad85@users.noreply.github.com> Date: Mon, 3 Jun 2019 09:44:06 +0200 Subject: [PATCH] Initialize global feerate with default from conf (#1019) `Globals.feeratePerKB` is an atomic reference initialized to `null` and is asynchronously set by the fee provider only once it's ready. This means that it is possible to retrieve a null object from feeratePerKB, scenario that must be handled separately to prevent any issues. This commit now initialize `Globals.feeratePerKB` with the default values set in the configuration file. This makes sure that the feerate is always set to a meaningful value. --- .../main/scala/fr/acinq/eclair/Setup.scala | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala b/eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala index 2d4c653b5..809222c1b 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala @@ -179,14 +179,19 @@ class Setup(datadir: File, tcpBound = Promise[Done]() routerInitialized = Promise[Done]() - defaultFeerates = FeeratesPerKB( - block_1 = config.getLong("default-feerates.delay-blocks.1"), - blocks_2 = config.getLong("default-feerates.delay-blocks.2"), - blocks_6 = config.getLong("default-feerates.delay-blocks.6"), - blocks_12 = config.getLong("default-feerates.delay-blocks.12"), - blocks_36 = config.getLong("default-feerates.delay-blocks.36"), - blocks_72 = config.getLong("default-feerates.delay-blocks.72") - ) + defaultFeerates = { + val confDefaultFeerates = FeeratesPerKB( + block_1 = config.getLong("default-feerates.delay-blocks.1"), + blocks_2 = config.getLong("default-feerates.delay-blocks.2"), + blocks_6 = config.getLong("default-feerates.delay-blocks.6"), + blocks_12 = config.getLong("default-feerates.delay-blocks.12"), + blocks_36 = config.getLong("default-feerates.delay-blocks.36"), + blocks_72 = config.getLong("default-feerates.delay-blocks.72") + ) + Globals.feeratesPerKB.set(confDefaultFeerates) + Globals.feeratesPerKw.set(FeeratesPerKw(confDefaultFeerates)) + confDefaultFeerates + } minFeeratePerByte = config.getLong("min-feerate") smoothFeerateWindow = config.getInt("smooth-feerate-window") feeProvider = (nodeParams.chainHash, bitcoin) match {