From b7de4f0490efef8e00787bcf3605140940ab7285 Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Mon, 31 Aug 2020 14:06:26 -0400 Subject: [PATCH] problem: fails to add another dshackle upstream if any of blockchain is unsupported --- .../dshackle/upstream/grpc/GrpcUpstreams.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt index d7b4f7c9..16f9371a 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt @@ -101,6 +101,8 @@ class GrpcUpstreams( prev?.dispose() subscription } + }.doOnError { t -> + log.error("Failed to process update from gRPC upstream $id", t) } return updates @@ -109,11 +111,16 @@ class GrpcUpstreams( fun processDescription(value: BlockchainOuterClass.DescribeResponse): Flux { val current = value.chainsList.filter { Chain.byId(it.chain.number) != Chain.UNSPECIFIED - }.map { chainDetails -> - val chain = Chain.byId(chainDetails.chain.number) - val up = getOrCreate(chain) - (up.upstream as EthereumGrpcUpstream).init(chainDetails) - up + }.mapNotNull { chainDetails -> + try { + val chain = Chain.byId(chainDetails.chain.number) + val up = getOrCreate(chain) + (up.upstream as EthereumGrpcUpstream).init(chainDetails) + up + } catch (e: Throwable) { + log.warn("Skip unsupported upstream ${chainDetails.chain} on $id: ${e.message}") + null + } } val added = current.filter {