problem: uses only one Head Subscription for Dshackle Upstream even if multiple are provided
This commit is contained in:
@@ -93,7 +93,7 @@ class BitcoinGrpcUpstream(
|
||||
}
|
||||
}
|
||||
private val upstreamStatus = GrpcUpstreamStatus()
|
||||
private val grpcHead = GrpcHead(chain, this, blockConverter, reloadBlock)
|
||||
private val grpcHead = GrpcHead(chain, this, remote, blockConverter, reloadBlock)
|
||||
var timeout = Defaults.timeout
|
||||
private var capabilities: Set<Capability> = emptySet()
|
||||
|
||||
@@ -126,15 +126,13 @@ class BitcoinGrpcUpstream(
|
||||
}
|
||||
|
||||
override fun isRunning(): Boolean {
|
||||
return grpcHead.isRunning
|
||||
return true
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
grpcHead.start(remote)
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
grpcHead.stop()
|
||||
}
|
||||
|
||||
override fun update(conf: BlockchainOuterClass.DescribeChain) {
|
||||
|
||||
@@ -95,22 +95,20 @@ open class EthereumGrpcUpstream(
|
||||
|
||||
private val log = LoggerFactory.getLogger(EthereumGrpcUpstream::class.java)
|
||||
private val upstreamStatus = GrpcUpstreamStatus()
|
||||
private val grpcHead = GrpcHead(chain, this, blockConverter, reloadBlock)
|
||||
private val grpcHead = GrpcHead(chain, this, remote, blockConverter, reloadBlock)
|
||||
private var capabilities: Set<Capability> = emptySet()
|
||||
|
||||
private val defaultReader: Reader<JsonRpcRequest, JsonRpcResponse> = client.forSelector(Selector.empty)
|
||||
var timeout = Defaults.timeout
|
||||
|
||||
override fun start() {
|
||||
grpcHead.start(remote)
|
||||
}
|
||||
|
||||
override fun isRunning(): Boolean {
|
||||
return grpcHead.isRunning
|
||||
return true
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
grpcHead.stop()
|
||||
}
|
||||
|
||||
override fun update(conf: BlockchainOuterClass.DescribeChain) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.function.Function
|
||||
class GrpcHead(
|
||||
private val chain: Chain,
|
||||
private val parent: DefaultUpstream,
|
||||
private val remote: ReactorBlockchainGrpc.ReactorBlockchainStub,
|
||||
/**
|
||||
* Converted from remote head details to the block container, which could be partial at this point
|
||||
*/
|
||||
@@ -56,10 +57,11 @@ class GrpcHead(
|
||||
/**
|
||||
* Initiate a new head subscription with connection to the remote
|
||||
*/
|
||||
fun start(remote: ReactorBlockchainGrpc.ReactorBlockchainStub) {
|
||||
private fun internalStart(remote: ReactorBlockchainGrpc.ReactorBlockchainStub) {
|
||||
if (this.isRunning) {
|
||||
stop()
|
||||
}
|
||||
log.debug("Start Head subscription to ${parent.getId()}")
|
||||
|
||||
val source = Flux.concat(
|
||||
// first connect immediately
|
||||
@@ -68,7 +70,7 @@ class GrpcHead(
|
||||
Flux.just(remote).repeat().delayElements(Defaults.retryConnection)
|
||||
).flatMap(this::subscribeHead)
|
||||
|
||||
start(source)
|
||||
internalStart(source)
|
||||
}
|
||||
|
||||
fun subscribeHead(client: ReactorBlockchainGrpc.ReactorBlockchainStub): Publisher<BlockchainOuterClass.ChainHead> {
|
||||
@@ -88,7 +90,7 @@ class GrpcHead(
|
||||
/**
|
||||
* Initiate a new head from provided source of head details
|
||||
*/
|
||||
fun start(source: Flux<BlockchainOuterClass.ChainHead>) {
|
||||
private fun internalStart(source: Flux<BlockchainOuterClass.ChainHead>) {
|
||||
var blocks = source.map(converter)
|
||||
.distinctUntilChanged {
|
||||
it.hash
|
||||
@@ -112,7 +114,7 @@ class GrpcHead(
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
log.error("Use start with provides source")
|
||||
this.internalStart(remote)
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
|
||||
Reference in New Issue
Block a user