Skip to content

Commit

Permalink
Gelato head liveness (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillPamPam authored May 10, 2024
1 parent df5e3b9 commit ac1ef25
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ class NoHeadLivenessValidator : HeadLivenessValidator {
return Flux.just(false)
}
}

class AlwaysHeadLivenessValidator : HeadLivenessValidator {
override fun getFlux(): Flux<Boolean> {
return Flux.just(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ open class GenericConnectorFactory(
headLivenessScheduler,
expectedBlockTime,
specific,
chain,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RestConnectorFactory(
headLivenessScheduler,
expectedBlockTime,
specific,
chain,
)
}

Expand Down

0 comments on commit ac1ef25

Please sign in to comment.