diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/Describe.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/Describe.kt index 35075554..ea922ad5 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/Describe.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/Describe.kt @@ -35,44 +35,46 @@ class Describe( return requestMono.map { _ -> val resp = BlockchainOuterClass.DescribeResponse.newBuilder() resp.buildInfoBuilder.version = Global.version - multistreamHolder.getAvailable().forEach { chain -> - multistreamHolder.getUpstream(chain).let { chainUpstreams -> - val status = subscribeStatus.chainStatus(chain, chainUpstreams.getStatus(), chainUpstreams) - val targets = chainUpstreams.getMethods().getSupportedMethods() - val capabilities: MutableSet = mutableSetOf() - val chainDescription = BlockchainOuterClass.DescribeChain.newBuilder() - .setChain(Common.ChainRef.forNumber(chain.id)) - .addAllSupportedMethods(targets) - .addAllSupportedSubscriptions(chainUpstreams.getEgressSubscription().getAvailableTopics()) - .setStatus(status) - .setCurrentHeight(chainUpstreams.getHead().getCurrentHeight() ?: 0) - chainUpstreams.getQuorumLabels() - .forEach { node -> - val nodeDetails = BlockchainOuterClass.NodeDetails.newBuilder() - .setQuorum(node.quorum) - .addAllLabels( - node.labels.entries.map { label -> - BlockchainOuterClass.Label.newBuilder() - .setName(label.key) - .setValue(label.value) - .build() - }, - ) - chainDescription.addNodes(nodeDetails) - } - capabilities.addAll(chainUpstreams.getCapabilities()) - chainDescription.addAllCapabilities( - capabilities.map { - when (it) { - Capability.RPC -> BlockchainOuterClass.Capabilities.CAP_CALLS - Capability.BALANCE -> BlockchainOuterClass.Capabilities.CAP_BALANCE - Capability.WS_HEAD -> BlockchainOuterClass.Capabilities.CAP_WS_HEAD + multistreamHolder.getAvailable() + .filter { Common.ChainRef.forNumber(it.id) != null } + .forEach { chain -> + multistreamHolder.getUpstream(chain).let { chainUpstreams -> + val status = subscribeStatus.chainStatus(chain, chainUpstreams.getStatus(), chainUpstreams) + val targets = chainUpstreams.getMethods().getSupportedMethods() + val capabilities: MutableSet = mutableSetOf() + val chainDescription = BlockchainOuterClass.DescribeChain.newBuilder() + .setChain(Common.ChainRef.forNumber(chain.id)) + .addAllSupportedMethods(targets) + .addAllSupportedSubscriptions(chainUpstreams.getEgressSubscription().getAvailableTopics()) + .setStatus(status) + .setCurrentHeight(chainUpstreams.getHead().getCurrentHeight() ?: 0) + chainUpstreams.getQuorumLabels() + .forEach { node -> + val nodeDetails = BlockchainOuterClass.NodeDetails.newBuilder() + .setQuorum(node.quorum) + .addAllLabels( + node.labels.entries.map { label -> + BlockchainOuterClass.Label.newBuilder() + .setName(label.key) + .setValue(label.value) + .build() + }, + ) + chainDescription.addNodes(nodeDetails) } - }, - ) - resp.addChains(chainDescription.build()) + capabilities.addAll(chainUpstreams.getCapabilities()) + chainDescription.addAllCapabilities( + capabilities.map { + when (it) { + Capability.RPC -> BlockchainOuterClass.Capabilities.CAP_CALLS + Capability.BALANCE -> BlockchainOuterClass.Capabilities.CAP_BALANCE + Capability.WS_HEAD -> BlockchainOuterClass.Capabilities.CAP_WS_HEAD + } + }, + ) + resp.addChains(chainDescription.build()) + } } - } resp.build() } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/StreamHead.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/StreamHead.kt index 4fafa133..72e50959 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/StreamHead.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/StreamHead.kt @@ -93,7 +93,7 @@ class StreamHead( private fun toProtoLowerBoundType(type: LowerBoundType): BlockchainOuterClass.LowerBoundType { return when (type) { LowerBoundType.SLOT -> BlockchainOuterClass.LowerBoundType.LOWER_BOUND_SLOT - LowerBoundType.UNKNOWN -> BlockchainOuterClass.LowerBoundType.UNRECOGNIZED + LowerBoundType.UNKNOWN -> BlockchainOuterClass.LowerBoundType.LOWER_BOUND_UNSPECIFIED LowerBoundType.STATE -> BlockchainOuterClass.LowerBoundType.LOWER_BOUND_STATE LowerBoundType.BLOCK -> BlockchainOuterClass.LowerBoundType.LOWER_BOUND_BLOCK }