Gelato head liveness (#474)

This commit is contained in:
KirillPamPam
2024-05-10 18:56:56 +04:00
committed by GitHub
parent df5e3b98db
commit ac1ef255eb
4 changed files with 18 additions and 3 deletions

View File

@@ -12,3 +12,9 @@ class NoHeadLivenessValidator : HeadLivenessValidator {
return Flux.just(false)
}
}
class AlwaysHeadLivenessValidator : HeadLivenessValidator {
override fun getFlux(): Flux<Boolean> {
return Flux.just(true)
}
}

View File

@@ -79,6 +79,7 @@ open class GenericConnectorFactory(
headLivenessScheduler,
expectedBlockTime,
specific,
chain,
)
}

View File

@@ -1,5 +1,6 @@
package io.emeraldpay.dshackle.upstream.generic.connectors
import io.emeraldpay.dshackle.Chain
import io.emeraldpay.dshackle.cache.Caches
import io.emeraldpay.dshackle.cache.CachesEnabled
import io.emeraldpay.dshackle.reader.ChainReader
@@ -11,6 +12,7 @@ import io.emeraldpay.dshackle.upstream.IngressSubscription
import io.emeraldpay.dshackle.upstream.Lifecycle
import io.emeraldpay.dshackle.upstream.MergedHead
import io.emeraldpay.dshackle.upstream.NoIngressSubscription
import io.emeraldpay.dshackle.upstream.ethereum.AlwaysHeadLivenessValidator
import io.emeraldpay.dshackle.upstream.ethereum.GenericWsHead
import io.emeraldpay.dshackle.upstream.ethereum.HeadLivenessValidator
import io.emeraldpay.dshackle.upstream.ethereum.HeadLivenessValidatorImpl
@@ -45,6 +47,7 @@ class GenericRpcConnector(
headLivenessScheduler: Scheduler,
expectedBlockTime: Duration,
private val chainSpecific: ChainSpecific,
private val chain: Chain,
) : GenericConnector, CachesEnabled {
private val id = upstream.getId()
private val pool: WsConnectionPool?
@@ -126,9 +129,13 @@ class GenericRpcConnector(
}
}
liveness = when (connectorType) {
RPC_ONLY -> NoHeadLivenessValidator()
RPC_REQUESTS_WITH_MIXED_HEAD, RPC_REQUESTS_WITH_WS_HEAD, WS_ONLY -> HeadLivenessValidatorImpl(head, expectedBlockTime, headLivenessScheduler, id)
liveness = if (connectorType != RPC_ONLY && (chain == Chain.ALEPHZERO__SEPOLIA || chain == Chain.CONNEXT__SEPOLIA)) {
AlwaysHeadLivenessValidator()
} else {
when (connectorType) {
RPC_ONLY -> NoHeadLivenessValidator()
RPC_REQUESTS_WITH_MIXED_HEAD, RPC_REQUESTS_WITH_WS_HEAD, WS_ONLY -> HeadLivenessValidatorImpl(head, expectedBlockTime, headLivenessScheduler, id)
}
}
}

View File

@@ -38,6 +38,7 @@ class RestConnectorFactory(
headLivenessScheduler,
expectedBlockTime,
specific,
chain,
)
}