From 9b8cd65a7028ba3caf3d2795a5a42c115b80fb60 Mon Sep 17 00:00:00 2001 From: piotrkosecki Date: Mon, 31 Jan 2022 09:32:47 +0100 Subject: [PATCH] resolved race condition in metadata caching --- .../tech/cryptonomic/conseil/api/ConseilApi.scala | 13 ++++--------- conseil-common/src/main/resources/reference.conf | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/conseil-api/src/main/scala/tech/cryptonomic/conseil/api/ConseilApi.scala b/conseil-api/src/main/scala/tech/cryptonomic/conseil/api/ConseilApi.scala index 356e7689f..2c41d40c4 100644 --- a/conseil-api/src/main/scala/tech/cryptonomic/conseil/api/ConseilApi.scala +++ b/conseil-api/src/main/scala/tech/cryptonomic/conseil/api/ConseilApi.scala @@ -17,11 +17,7 @@ import tech.cryptonomic.conseil.api.routes.Docs import tech.cryptonomic.conseil.api.routes.info.AppInfo import tech.cryptonomic.conseil.api.routes.platform.data.ApiDataRoutes import tech.cryptonomic.conseil.api.routes.platform.data.bitcoin.{BitcoinDataOperations, BitcoinDataRoutes} -import tech.cryptonomic.conseil.api.routes.platform.data.ethereum.{ - EthereumDataOperations, - EthereumDataRoutes, - QuorumDataRoutes -} +import tech.cryptonomic.conseil.api.routes.platform.data.ethereum.{EthereumDataOperations, EthereumDataRoutes, QuorumDataRoutes} import tech.cryptonomic.conseil.api.routes.platform.data.tezos.{TezosDataOperations, TezosDataRoutes} import tech.cryptonomic.conseil.api.routes.platform.discovery.{GenericPlatformDiscoveryOperations, PlatformDiscovery} import tech.cryptonomic.conseil.api.security.Security @@ -31,10 +27,9 @@ import tech.cryptonomic.conseil.common.config.Platforms.BlockchainPlatform import tech.cryptonomic.conseil.common.io.Logging.ConseilLogSupport import tech.cryptonomic.conseil.common.sql.DatabaseRunner -import scala.concurrent.ExecutionContext -import scala.concurrent.duration.DurationInt +import scala.concurrent.{Await, ExecutionContext} +import scala.concurrent.duration.{Duration, DurationInt} import scala.util.{Failure, Success} - import cats.effect.unsafe.implicits.global object ConseilApi { @@ -228,7 +223,7 @@ class ConseilApi(config: CombinedConfiguration)(implicit system: ActorSystem) } yield platform -> network if (visibleNetworks.nonEmpty) { // At least one blockchain is enabled - cachedDiscoveryOperations.init(visibleNetworks).onComplete { + Await.ready(cachedDiscoveryOperations.init(visibleNetworks), Duration.Inf).onComplete { case Failure(exception) => logger.error("Pre-caching metadata failed", exception) case Success(_) => logger.info("Pre-caching successful!") } diff --git a/conseil-common/src/main/resources/reference.conf b/conseil-common/src/main/resources/reference.conf index 71ff6f08a..f8e13eb76 100644 --- a/conseil-common/src/main/resources/reference.conf +++ b/conseil-common/src/main/resources/reference.conf @@ -27,7 +27,6 @@ platforms: [ baker-rolls-size: 8000 baker-rolls-size: ${?CONSEIL_XTZ_BACKER_ROLLS_SIZE} - network: "mainnet" network: "granadanet" network: ${?CONSEIL_XTZ_NETWORK}