solution: rename grpc target to method
This commit is contained in:
@@ -3,8 +3,6 @@ package io.emeraldpay.dshackle.rpc
|
|||||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||||
import io.emeraldpay.api.proto.Common
|
import io.emeraldpay.api.proto.Common
|
||||||
import io.emeraldpay.dshackle.upstream.*
|
import io.emeraldpay.dshackle.upstream.*
|
||||||
import io.emeraldpay.grpc.Chain
|
|
||||||
import io.grpc.stub.StreamObserver
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
@@ -24,7 +22,7 @@ class Describe(
|
|||||||
val targets = chainUpstreams.getSupportedTargets()
|
val targets = chainUpstreams.getSupportedTargets()
|
||||||
val chainDescription = BlockchainOuterClass.DescribeChain.newBuilder()
|
val chainDescription = BlockchainOuterClass.DescribeChain.newBuilder()
|
||||||
.setChain(Common.ChainRef.forNumber(chain.id))
|
.setChain(Common.ChainRef.forNumber(chain.id))
|
||||||
.addAllSupportedTargets(targets)
|
.addAllSupportedMethods(targets)
|
||||||
.setStatus(status)
|
.setStatus(status)
|
||||||
chainUpstreams.getAll().let { ups ->
|
chainUpstreams.getAll().let { ups ->
|
||||||
ups.forEach { up ->
|
ups.forEach { up ->
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class NativeCall(
|
|||||||
val matcher = Selector.convertToMatcher(request.selector)
|
val matcher = Selector.convertToMatcher(request.selector)
|
||||||
val apis = upstream.getApis(matcher)
|
val apis = upstream.getApis(matcher)
|
||||||
return request.itemsList.toFlux().map {
|
return request.itemsList.toFlux().map {
|
||||||
val method = it.target
|
val method = it.method
|
||||||
val params = it.payload.toStringUtf8()
|
val params = it.payload.toStringUtf8()
|
||||||
val callQuorum = upstream.targets?.getQuorumFor(method) ?: AlwaysQuorum()
|
val callQuorum = upstream.targets?.getQuorumFor(method) ?: AlwaysQuorum()
|
||||||
callQuorum.init(upstream.getHead())
|
callQuorum.init(upstream.getHead())
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ class EthereumGrpcTransport(
|
|||||||
val params = objectMapper.writeValueAsBytes(call.params)
|
val params = objectMapper.writeValueAsBytes(call.params)
|
||||||
val nativeCallItem = BlockchainOuterClass.NativeCallItem.newBuilder()
|
val nativeCallItem = BlockchainOuterClass.NativeCallItem.newBuilder()
|
||||||
.setId(id)
|
.setId(id)
|
||||||
.setMethod("POST")
|
.setMethod(call.method)
|
||||||
.setTarget(call.method)
|
|
||||||
.setPayload(ByteString.copyFrom(params))
|
.setPayload(ByteString.copyFrom(params))
|
||||||
.build()
|
.build()
|
||||||
req.addItems(nativeCallItem)
|
req.addItems(nativeCallItem)
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ open class GrpcUpstream(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun init(conf: BlockchainOuterClass.DescribeChain) {
|
fun init(conf: BlockchainOuterClass.DescribeChain) {
|
||||||
supportedMethods.addAll(conf.supportedTargetsList)
|
supportedMethods.addAll(conf.supportedMethodsList)
|
||||||
val nodes = NodeDetailsList()
|
val nodes = NodeDetailsList()
|
||||||
conf.nodesList.forEach { node ->
|
conf.nodesList.forEach { node ->
|
||||||
val node = NodeDetailsList.NodeDetails(node.quorum,
|
val node = NodeDetailsList.NodeDetails(node.quorum,
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class UpstreamValidator(
|
|||||||
}
|
}
|
||||||
return UpstreamAvailability.OK
|
return UpstreamAvailability.OK
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
e.printStackTrace()
|
|
||||||
return UpstreamAvailability.UNAVAILABLE
|
return UpstreamAvailability.UNAVAILABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class NativeCallSpec extends Specification {
|
|||||||
.addAllItems([1, 2].collect { id ->
|
.addAllItems([1, 2].collect { id ->
|
||||||
return BlockchainOuterClass.NativeCallItem.newBuilder()
|
return BlockchainOuterClass.NativeCallItem.newBuilder()
|
||||||
.setId(id)
|
.setId(id)
|
||||||
.setTarget("eth_test")
|
.setMethod("eth_test")
|
||||||
.build()
|
.build()
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
@@ -178,7 +178,7 @@ class NativeCallSpec extends Specification {
|
|||||||
.addAllItems([1, 2].collect { id ->
|
.addAllItems([1, 2].collect { id ->
|
||||||
return BlockchainOuterClass.NativeCallItem.newBuilder()
|
return BlockchainOuterClass.NativeCallItem.newBuilder()
|
||||||
.setId(id)
|
.setId(id)
|
||||||
.setTarget("eth_test")
|
.setMethod("eth_test")
|
||||||
.build()
|
.build()
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class EthereumApiMock extends EthereumApi {
|
|||||||
|
|
||||||
def nativeCall(BlockchainOuterClass.NativeCallRequest request, StreamObserver<BlockchainOuterClass.NativeCallReplyItem> responseObserver) {
|
def nativeCall(BlockchainOuterClass.NativeCallRequest request, StreamObserver<BlockchainOuterClass.NativeCallReplyItem> responseObserver) {
|
||||||
request.itemsList.forEach { req ->
|
request.itemsList.forEach { req ->
|
||||||
def resp = execute(req.id, req.target, objectMapper.readerFor(List).readValue(req.payload.toByteArray()))
|
def resp = execute(req.id, req.method, objectMapper.readerFor(List).readValue(req.payload.toByteArray()))
|
||||||
resp.subscribe {
|
resp.subscribe {
|
||||||
def proto = BlockchainOuterClass.NativeCallReplyItem.newBuilder()
|
def proto = BlockchainOuterClass.NativeCallReplyItem.newBuilder()
|
||||||
.setId(req.id)
|
.setId(req.id)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class EthereumGrpcTransportSpec extends Specification {
|
|||||||
chain.number == Chain.ETHEREUM.id
|
chain.number == Chain.ETHEREUM.id
|
||||||
itemsCount == 1
|
itemsCount == 1
|
||||||
with(getItems(0)) {
|
with(getItems(0)) {
|
||||||
target == "eth_test"
|
method == "eth_test"
|
||||||
payload.toStringUtf8() == "[1]"
|
payload.toStringUtf8() == "[1]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,11 +106,11 @@ class EthereumGrpcTransportSpec extends Specification {
|
|||||||
chain.number == Chain.ETHEREUM.id
|
chain.number == Chain.ETHEREUM.id
|
||||||
itemsCount == 2
|
itemsCount == 2
|
||||||
with(getItems(0)) {
|
with(getItems(0)) {
|
||||||
target == "eth_test"
|
method == "eth_test"
|
||||||
payload.toStringUtf8() == "[1]"
|
payload.toStringUtf8() == "[1]"
|
||||||
}
|
}
|
||||||
with(getItems(1)) {
|
with(getItems(1)) {
|
||||||
target == "eth_test2"
|
method == "eth_test2"
|
||||||
payload.toStringUtf8() == "[2,\"3\"]"
|
payload.toStringUtf8() == "[2,\"3\"]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user