mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 09:52:09 +01:00
Implement AppConfigFactory (#1462)
* Implement AppConfigFactory * Fix docs
This commit is contained in:
parent
192cd49974
commit
d8170f319a
@ -95,14 +95,14 @@ case class ChainAppConfig(
|
||||
config.getInt(s"${moduleName}.neutrino.filter-batch-size")
|
||||
}
|
||||
|
||||
object ChainAppConfig {
|
||||
object ChainAppConfig extends AppConfigFactory[ChainAppConfig] {
|
||||
|
||||
/** Constructs a chain verification configuration from the default Bitcoin-S
|
||||
* data directory and given list of configuration overrides.
|
||||
*/
|
||||
def fromDefaultDatadir(useLogbackConf: Boolean, confs: Config*)(
|
||||
override def fromDatadir(datadir: Path, useLogbackConf: Boolean, confs: Vector[Config])(
|
||||
implicit ec: ExecutionContext): ChainAppConfig =
|
||||
ChainAppConfig(AppConfig.DEFAULT_BITCOIN_S_DATADIR,
|
||||
ChainAppConfig(datadir,
|
||||
useLogbackConf,
|
||||
confs: _*)
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package org.bitcoins.db
|
||||
|
||||
import java.nio.file.Path
|
||||
|
||||
import com.typesafe.config.Config
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
trait AppConfigFactory[C <: AppConfig] {
|
||||
|
||||
def fromDefaultDatadir(useLogbackConf: Boolean, confs: Vector[Config] = Vector.empty)(
|
||||
implicit ec: ExecutionContext): C = {
|
||||
fromDatadir(AppConfig.DEFAULT_BITCOIN_S_DATADIR,useLogbackConf,confs)
|
||||
}
|
||||
|
||||
def fromDatadir(datadir: Path, useLogbackConf: Boolean, confs: Vector[Config] = Vector.empty)(implicit ec: ExecutionContext): C
|
||||
}
|
@ -4,7 +4,7 @@ import java.nio.file.Path
|
||||
|
||||
import com.typesafe.config.Config
|
||||
import org.bitcoins.core.util.FutureUtil
|
||||
import org.bitcoins.db.{AppConfig, JdbcProfileComponent}
|
||||
import org.bitcoins.db.{AppConfig, AppConfigFactory, JdbcProfileComponent}
|
||||
import org.bitcoins.node.db.NodeDbManagement
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
@ -70,14 +70,14 @@ case class NodeAppConfig(
|
||||
}
|
||||
}
|
||||
|
||||
object NodeAppConfig {
|
||||
object NodeAppConfig extends AppConfigFactory[NodeAppConfig] {
|
||||
|
||||
/** Constructs a node configuration from the default Bitcoin-S
|
||||
* data directory and given list of configuration overrides.
|
||||
*/
|
||||
def fromDefaultDatadir(useLogbackConf: Boolean, confs: Config*)(
|
||||
override def fromDatadir(datadir: Path, useLogbackConf: Boolean, confs: Vector[Config])(
|
||||
implicit ec: ExecutionContext): NodeAppConfig =
|
||||
NodeAppConfig(AppConfig.DEFAULT_BITCOIN_S_DATADIR,
|
||||
NodeAppConfig(datadir,
|
||||
useLogbackConf,
|
||||
confs: _*)
|
||||
|
||||
|
@ -6,7 +6,7 @@ import java.util.concurrent.TimeUnit
|
||||
import com.typesafe.config.Config
|
||||
import org.bitcoins.core.hd._
|
||||
import org.bitcoins.core.util.FutureUtil
|
||||
import org.bitcoins.db.{AppConfig, JdbcProfileComponent}
|
||||
import org.bitcoins.db.{AppConfig, AppConfigFactory, JdbcProfileComponent}
|
||||
import org.bitcoins.keymanager.{KeyManagerParams, WalletStorage}
|
||||
import org.bitcoins.wallet.db.WalletDbManagement
|
||||
|
||||
@ -127,14 +127,14 @@ case class WalletAppConfig(
|
||||
}
|
||||
}
|
||||
|
||||
object WalletAppConfig {
|
||||
object WalletAppConfig extends AppConfigFactory[WalletAppConfig] {
|
||||
|
||||
/** Constructs a wallet configuration from the default Bitcoin-S
|
||||
* data directory and given list of configuration overrides.
|
||||
*/
|
||||
def fromDefaultDatadir(useLogbackConf: Boolean, confs: Config*)(
|
||||
override def fromDatadir(datadir: Path, useLogbackConf: Boolean, confs: Vector[Config])(
|
||||
implicit ec: ExecutionContext): WalletAppConfig =
|
||||
WalletAppConfig(AppConfig.DEFAULT_BITCOIN_S_DATADIR,
|
||||
WalletAppConfig(datadir,
|
||||
useLogbackConf,
|
||||
confs: _*)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user