mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 01:40:55 +01:00
Correct log location and logs for oracle server (#2722)
* Correct log location and logs for oracle server * Fix staking address to be mainnet * fix network in test
This commit is contained in:
parent
94934e113d
commit
7aa68998f1
@ -4,7 +4,7 @@ import akka.http.scaladsl.model.ContentTypes._
|
||||
import akka.http.scaladsl.testkit.ScalatestRouteTest
|
||||
import org.bitcoins.core.api.dlcoracle._
|
||||
import org.bitcoins.core.api.dlcoracle.db.EventDb
|
||||
import org.bitcoins.core.config.{BitcoinNetwork, RegTest}
|
||||
import org.bitcoins.core.config._
|
||||
import org.bitcoins.core.number.{Int32, UInt16}
|
||||
import org.bitcoins.core.protocol.Bech32Address
|
||||
import org.bitcoins.core.protocol.dlc.SigningVersion
|
||||
@ -90,7 +90,7 @@ class OracleRoutesSpec
|
||||
"get staking address" in {
|
||||
(mockOracleApi
|
||||
.stakingAddress(_: BitcoinNetwork))
|
||||
.expects(RegTest)
|
||||
.expects(MainNet)
|
||||
.returning(testAddress)
|
||||
|
||||
val route =
|
||||
|
@ -4,6 +4,7 @@ import akka.actor.ActorSystem
|
||||
import akka.http.scaladsl.server.Directives._
|
||||
import akka.http.scaladsl.server._
|
||||
import org.bitcoins.core.api.dlcoracle._
|
||||
import org.bitcoins.core.config.MainNet
|
||||
import org.bitcoins.core.number._
|
||||
import org.bitcoins.core.protocol.tlv._
|
||||
import org.bitcoins.dlc.oracle.config.DLCOracleAppConfig
|
||||
@ -27,8 +28,7 @@ case class OracleRoutes(oracle: DLCOracleApi)(implicit
|
||||
|
||||
case ServerCommand("getstakingaddress", _) =>
|
||||
complete {
|
||||
val network = conf.network
|
||||
val address = oracle.stakingAddress(network)
|
||||
val address = oracle.stakingAddress(MainNet)
|
||||
|
||||
Server.httpSuccess(address.toString)
|
||||
}
|
||||
|
@ -53,5 +53,5 @@ class OracleServerMain(override val args: Array[String])
|
||||
}
|
||||
|
||||
object OracleServerMain extends App {
|
||||
new OracleServerMain(args).run()
|
||||
new OracleServerMain(args).run(Some("oracle"))
|
||||
}
|
||||
|
@ -90,45 +90,46 @@ trait BitcoinSRunner extends BitcoinSLogger {
|
||||
def startup: Future[Unit]
|
||||
|
||||
// start everything!
|
||||
final def run(): Unit = {
|
||||
final def run(customFinalDirOpt: Option[String] = None): Unit = {
|
||||
|
||||
/** Directory specific for current network */
|
||||
val networkDatadir: Path = {
|
||||
val networkStr: String =
|
||||
baseConfig.getString("bitcoin-s.network")
|
||||
/** Directory specific for current network or custom dir */
|
||||
val usedDir: Path = customFinalDirOpt match {
|
||||
case Some(dir) => datadir.resolve(dir)
|
||||
case None =>
|
||||
val networkStr: String =
|
||||
baseConfig.getString("bitcoin-s.network")
|
||||
|
||||
val network: BitcoinNetwork = networkStr.toLowerCase match {
|
||||
case "mainnet" => MainNet
|
||||
case "main" => MainNet
|
||||
case "testnet3" => TestNet3
|
||||
case "testnet" => TestNet3
|
||||
case "test" => TestNet3
|
||||
case "regtest" => RegTest
|
||||
case "signet" => SigNet
|
||||
case "sig" => SigNet
|
||||
case _: String =>
|
||||
throw new IllegalArgumentException(s"Invalid network $networkStr")
|
||||
}
|
||||
val network: BitcoinNetwork = networkStr.toLowerCase match {
|
||||
case "mainnet" => MainNet
|
||||
case "main" => MainNet
|
||||
case "testnet3" => TestNet3
|
||||
case "testnet" => TestNet3
|
||||
case "test" => TestNet3
|
||||
case "regtest" => RegTest
|
||||
case "signet" => SigNet
|
||||
case "sig" => SigNet
|
||||
case _: String =>
|
||||
throw new IllegalArgumentException(s"Invalid network $networkStr")
|
||||
}
|
||||
|
||||
val lastDirname = network match {
|
||||
case MainNet => "mainnet"
|
||||
case TestNet3 => "testnet3"
|
||||
case RegTest => "regtest"
|
||||
case SigNet => "signet"
|
||||
}
|
||||
datadir.resolve(lastDirname)
|
||||
val lastDirname = network match {
|
||||
case MainNet => "mainnet"
|
||||
case TestNet3 => "testnet3"
|
||||
case RegTest => "regtest"
|
||||
case SigNet => "signet"
|
||||
}
|
||||
datadir.resolve(lastDirname)
|
||||
}
|
||||
|
||||
//We need to set the system property before any logger instances
|
||||
//are in instantiated. If we don't do this, we will not log to
|
||||
//the correct location
|
||||
//see: https://github.com/bitcoin-s/bitcoin-s/issues/2496
|
||||
System.setProperty("bitcoins.log.location",
|
||||
networkDatadir.toAbsolutePath.toString)
|
||||
System.setProperty("bitcoins.log.location", usedDir.toAbsolutePath.toString)
|
||||
|
||||
logger.info(s"version=${EnvUtil.getVersion}")
|
||||
|
||||
logger.info(s"networkDatadir=${networkDatadir.toAbsolutePath.toString}")
|
||||
logger.info(s"using directory ${usedDir.toAbsolutePath.toString}")
|
||||
val runner = startup
|
||||
runner.failed.foreach { err =>
|
||||
logger.error(s"Failed to startup server!", err)
|
||||
|
Loading…
Reference in New Issue
Block a user