Add guard to not allow us to check the network configuration on bitcoind (#3582)

* Add guard to not allow us to check the network configuration on bitcoind if we are using tor because tor isn't started yet

* Remove unecessary logs, revert config
This commit is contained in:
Chris Stewart 2021-08-20 14:49:37 -05:00 committed by GitHub
parent 54ce2ebeb2
commit e62615dc5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -52,11 +52,19 @@ class LandingPaneModel(serverArgParser: ServerArgParser)(implicit
// know what network it is on now // know what network it is on now
Future.successful(ConfigFactory.empty()) Future.successful(ConfigFactory.empty())
case BitcoindBackend => case BitcoindBackend =>
tmpConf.bitcoindRpcConf.client.getBlockChainInfo.map { info => if (!appConfig.torConf.enabled) {
val networkStr = tmpConf.bitcoindRpcConf.client.getBlockChainInfo.map { info =>
DatadirUtil.networkStrToDirName(info.chain.name) val networkStr =
ConfigFactory.parseString(s"bitcoin-s.network = $networkStr") DatadirUtil.networkStrToDirName(info.chain.name)
ConfigFactory.parseString(s"bitcoin-s.network = $networkStr")
}
} else {
//we cannot connect to bitcoind and determine
//the network over tor since tor isn't started
//yet
Future.successful(ConfigFactory.empty())
} }
} }
netConfF.map { netConf => netConfF.map { netConf =>
@ -82,7 +90,6 @@ class LandingPaneModel(serverArgParser: ServerArgParser)(implicit
GlobalData.setBitcoinNetwork( GlobalData.setBitcoinNetwork(
finalAppConfig.network, finalAppConfig.network,
finalAppConfig.socks5ProxyParams.isDefined) finalAppConfig.socks5ProxyParams.isDefined)
new BitcoinSServerMain(serverArgParser)(system, finalAppConfig) new BitcoinSServerMain(serverArgParser)(system, finalAppConfig)
.run() .run()
} }

View File

@ -45,6 +45,7 @@ class BitcoinSServerMain(override val serverArgParser: ServerArgParser)(implicit
implicit lazy val torConf: TorAppConfig = conf.torConf implicit lazy val torConf: TorAppConfig = conf.torConf
override def start(): Future[Unit] = { override def start(): Future[Unit] = {
logger.info("Starting appServer")
val startedConfigF = conf.start() val startedConfigF = conf.start()
logger.info(s"Start on network ${walletConf.network}") logger.info(s"Start on network ${walletConf.network}")

View File

@ -41,6 +41,7 @@ case class TorAppConfig(
override def start(): Future[Unit] = { override def start(): Future[Unit] = {
lazy val torRunning = checkIfTorAlreadyRunning lazy val torRunning = checkIfTorAlreadyRunning
if (enabled && !isStarted.get && !torRunning) { if (enabled && !isStarted.get && !torRunning) {
logger.info(s"Starting tor")
isStarted.set(true) isStarted.set(true)
val start = System.currentTimeMillis() val start = System.currentTimeMillis()
//remove old tor log file so we accurately tell when //remove old tor log file so we accurately tell when