fixed review comments
This commit is contained in:
@@ -63,6 +63,12 @@ open class NativeSubscribe(
|
|||||||
|
|
||||||
val nonce = request.nonce.takeIf { it != 0L }
|
val nonce = request.nonce.takeIf { it != 0L }
|
||||||
val matcher = Selector.convertToMatcher(request.selector)
|
val matcher = Selector.convertToMatcher(request.selector)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to proxy request subscription directly to the upstream dshackle instance.
|
||||||
|
* If not possible - performs subscription logic on the current instance
|
||||||
|
* @see EthereumLikeMultistream.tryProxy
|
||||||
|
*/
|
||||||
val publisher = getUpstream(chain)?.tryProxy(matcher, request) ?: run {
|
val publisher = getUpstream(chain)?.tryProxy(matcher, request) ?: run {
|
||||||
val method = request.method
|
val method = request.method
|
||||||
val params: Any? = request.payload?.takeIf { !it.isEmpty }?.let {
|
val params: Any? = request.payload?.takeIf { !it.isEmpty }?.let {
|
||||||
|
|||||||
@@ -12,5 +12,12 @@ interface EthereumLikeMultistream : Upstream {
|
|||||||
|
|
||||||
fun getHead(mather: Selector.Matcher): Head
|
fun getHead(mather: Selector.Matcher): Head
|
||||||
|
|
||||||
fun tryProxy(mather: Selector.Matcher, request: BlockchainOuterClass.NativeSubscribeRequest): Flux<out Any>?
|
/**
|
||||||
|
* Tries to proxy the native subscribe request to the managed upstreams if
|
||||||
|
* - any of them matches the matcher criteria
|
||||||
|
* - all of matching above are gRPC ones
|
||||||
|
* in this case the upstream dshackle instances can sign the results and they will just proxied as is with original signs
|
||||||
|
* Otherwise return null
|
||||||
|
*/
|
||||||
|
fun tryProxy(matcher: Selector.Matcher, request: BlockchainOuterClass.NativeSubscribeRequest): Flux<out Any>?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,21 +97,17 @@ open class EthereumMultistream(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun tryProxy(
|
override fun tryProxy(
|
||||||
mather: Selector.Matcher,
|
matcher: Selector.Matcher,
|
||||||
request: BlockchainOuterClass.NativeSubscribeRequest
|
request: BlockchainOuterClass.NativeSubscribeRequest
|
||||||
): Flux<out Any>? =
|
): Flux<out Any>? =
|
||||||
upstreams.filter {
|
upstreams.filter {
|
||||||
mather.matches(it)
|
matcher.matches(it)
|
||||||
}.takeIf { ups ->
|
}.takeIf { ups ->
|
||||||
ups.all { it.isGrpc() }
|
ups.all { it.isGrpc() }
|
||||||
}?.map {
|
}?.map {
|
||||||
it as GrpcUpstream
|
it as GrpcUpstream
|
||||||
}?.map {
|
}?.map {
|
||||||
it.getBlockchainApi().nativeSubscribe(
|
it.getBlockchainApi().nativeSubscribe(request)
|
||||||
request.toBuilder()
|
|
||||||
.setSelector(BlockchainOuterClass.Selector.getDefaultInstance())
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
}?.let {
|
}?.let {
|
||||||
Flux.merge(it)
|
Flux.merge(it)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,19 +91,15 @@ open class EthereumPosMultiStream(
|
|||||||
return head!!
|
return head!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tryProxy(mather: Selector.Matcher, request: BlockchainOuterClass.NativeSubscribeRequest): Flux<out Any>? =
|
override fun tryProxy(matcher: Selector.Matcher, request: BlockchainOuterClass.NativeSubscribeRequest): Flux<out Any>? =
|
||||||
upstreams.filter {
|
upstreams.filter {
|
||||||
mather.matches(it)
|
matcher.matches(it)
|
||||||
}.takeIf { ups ->
|
}.takeIf { ups ->
|
||||||
ups.all { it.isGrpc() }
|
ups.all { it.isGrpc() }
|
||||||
}?.map {
|
}?.map {
|
||||||
it as GrpcUpstream
|
it as GrpcUpstream
|
||||||
}?.map {
|
}?.map {
|
||||||
it.getBlockchainApi().nativeSubscribe(
|
it.getBlockchainApi().nativeSubscribe(request)
|
||||||
request.toBuilder()
|
|
||||||
.setSelector(BlockchainOuterClass.Selector.getDefaultInstance())
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
}?.let {
|
}?.let {
|
||||||
Flux.merge(it)
|
Flux.merge(it)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user