From 117a66869b4822e8eebb3a265a532487dc692018 Mon Sep 17 00:00:00 2001 From: Adinael Perez Ruelas Date: Sun, 18 Nov 2018 20:43:33 -0700 Subject: [PATCH] server: Add the genesis block to the config file --- .../xsn/explorer/config/ExplorerConfig.scala | 21 +++++++++++++++++++ .../xsn/explorer/modules/ConfigModule.scala | 1 + server/conf/application.conf | 4 ++++ 3 files changed, 26 insertions(+) create mode 100644 server/app/com/xsn/explorer/config/ExplorerConfig.scala diff --git a/server/app/com/xsn/explorer/config/ExplorerConfig.scala b/server/app/com/xsn/explorer/config/ExplorerConfig.scala new file mode 100644 index 0000000..b985e95 --- /dev/null +++ b/server/app/com/xsn/explorer/config/ExplorerConfig.scala @@ -0,0 +1,21 @@ +package com.xsn.explorer.config + +import com.xsn.explorer.models.Blockhash +import javax.inject.Inject +import play.api.Configuration + +trait ExplorerConfig { + + def genesisBlock: Blockhash +} + +class PlayExplorerConfig @Inject() (config: Configuration) extends ExplorerConfig { + + override val genesisBlock: Blockhash = { + Blockhash + .from(config.get[String]("explorer.genesisBlock")) + .getOrElse(throw new RuntimeException("The given genesisBlock is incorrect")) + } + +} + diff --git a/server/app/com/xsn/explorer/modules/ConfigModule.scala b/server/app/com/xsn/explorer/modules/ConfigModule.scala index b5df3b4..f790b79 100644 --- a/server/app/com/xsn/explorer/modules/ConfigModule.scala +++ b/server/app/com/xsn/explorer/modules/ConfigModule.scala @@ -8,5 +8,6 @@ class ConfigModule extends AbstractModule { override def configure(): Unit = { bind(classOf[RPCConfig]).to(classOf[PlayRPCConfig]) bind(classOf[LedgerSynchronizerConfig]).to(classOf[LedgerSynchronizerPlayConfig]) + bind(classOf[ExplorerConfig]).to(classOf[PlayExplorerConfig]) } } diff --git a/server/conf/application.conf b/server/conf/application.conf index 038c2b7..e919960 100644 --- a/server/conf/application.conf +++ b/server/conf/application.conf @@ -102,3 +102,7 @@ externalService.dispatcher { fixed-pool-size = 50 } } + +explorer { + genesisBlock = "00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34" +}