fix formatting

This commit is contained in:
terminal
2022-07-29 19:24:32 +04:00
parent bdd1281458
commit 38958a6296
29 changed files with 61 additions and 62 deletions

View File

@@ -116,8 +116,8 @@ open class UpstreamsConfig {
} }
class EthereumPosConnection : UpstreamConnection() { class EthereumPosConnection : UpstreamConnection() {
var execution : EthereumConnection? = null var execution: EthereumConnection? = null
var blockPriority : Int = 0 var blockPriority: Int = 0
} }
data class BitcoinZeroMq( data class BitcoinZeroMq(

View File

@@ -165,7 +165,7 @@ class UpstreamsConfigReader(
return connection return connection
} }
private fun readEthereumPosConnection(connConfigNode: MappingNode) : UpstreamsConfig.EthereumPosConnection { private fun readEthereumPosConnection(connConfigNode: MappingNode): UpstreamsConfig.EthereumPosConnection {
val connection = UpstreamsConfig.EthereumPosConnection() val connection = UpstreamsConfig.EthereumPosConnection()
getMapping(connConfigNode, "execution")?.let { getMapping(connConfigNode, "execution")?.let {
connection.execution = readEthereumConnection(it) connection.execution = readEthereumConnection(it)
@@ -175,7 +175,7 @@ class UpstreamsConfigReader(
} }
return connection return connection
} }
private fun readEthereumConnection(connConfigNode : MappingNode) : UpstreamsConfig.EthereumConnection { private fun readEthereumConnection(connConfigNode: MappingNode): UpstreamsConfig.EthereumConnection {
val connection = UpstreamsConfig.EthereumConnection() val connection = UpstreamsConfig.EthereumConnection()
getMapping(connConfigNode, "rpc")?.let { node -> getMapping(connConfigNode, "rpc")?.let { node ->
getValueAsString(node, "url")?.let { url -> getValueAsString(node, "url")?.let { url ->
@@ -211,7 +211,7 @@ class UpstreamsConfigReader(
return connection return connection
} }
private fun <T : UpstreamsConfig.UpstreamConnection>readUpstream(config: UpstreamsConfig, upNode: MappingNode, connFactory: () -> T) { private fun <T : UpstreamsConfig.UpstreamConnection> readUpstream(config: UpstreamsConfig, upNode: MappingNode, connFactory: () -> T) {
val upstream = UpstreamsConfig.Upstream<T>() val upstream = UpstreamsConfig.Upstream<T>()
readUpstreamCommon(upNode, upstream) readUpstreamCommon(upNode, upstream)
readUpstreamStandard(upNode, upstream) readUpstreamStandard(upNode, upstream)

View File

@@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicReference
class RingSet<T>( class RingSet<T>(
private val maxSize: Int private val maxSize: Int
): Set<T> { ) : Set<T> {
private var seqValues: AtomicReference<List<T>> = AtomicReference(emptyList()) private var seqValues: AtomicReference<List<T>> = AtomicReference(emptyList())
private var set: Set<T> = emptySet() private var set: Set<T> = emptySet()
override val size: Int override val size: Int
@@ -41,4 +41,4 @@ class RingSet<T>(
override fun containsAll(elements: Collection<@UnsafeVariance T>): Boolean { override fun containsAll(elements: Collection<@UnsafeVariance T>): Boolean {
return set.containsAll(elements) return set.containsAll(elements)
} }
} }

View File

@@ -21,7 +21,6 @@ import io.emeraldpay.dshackle.Global
import io.emeraldpay.dshackle.SilentException import io.emeraldpay.dshackle.SilentException
import io.emeraldpay.dshackle.upstream.MultistreamHolder import io.emeraldpay.dshackle.upstream.MultistreamHolder
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import io.emeraldpay.grpc.BlockchainType import io.emeraldpay.grpc.BlockchainType
import io.emeraldpay.grpc.Chain import io.emeraldpay.grpc.Chain
import io.grpc.Status import io.grpc.Status

View File

@@ -20,7 +20,11 @@ import io.emeraldpay.dshackle.FileResolver
import io.emeraldpay.dshackle.Global import io.emeraldpay.dshackle.Global
import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.config.UpstreamsConfig
import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.upstream.* import io.emeraldpay.dshackle.upstream.CurrentMultistreamHolder
import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.HttpRpcFactory
import io.emeraldpay.dshackle.upstream.MergedHead
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinRpcHead import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinRpcHead
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinRpcUpstream import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinRpcUpstream
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinZMQHead import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinZMQHead
@@ -147,7 +151,7 @@ open class ConfiguredUpstreams(
config: UpstreamsConfig.Upstream<UpstreamsConfig.EthereumPosConnection>, config: UpstreamsConfig.Upstream<UpstreamsConfig.EthereumPosConnection>,
chain: Chain, chain: Chain,
options: UpstreamsConfig.Options options: UpstreamsConfig.Options
) : Upstream? { ): Upstream? {
val conn = config.connection!! val conn = config.connection!!
val execution = conn.execution val execution = conn.execution
if (execution == null) { if (execution == null) {
@@ -176,7 +180,7 @@ open class ConfiguredUpstreams(
config: UpstreamsConfig.Upstream<UpstreamsConfig.BitcoinConnection>, config: UpstreamsConfig.Upstream<UpstreamsConfig.BitcoinConnection>,
chain: Chain, chain: Chain,
options: UpstreamsConfig.Options options: UpstreamsConfig.Options
) : Upstream? { ): Upstream? {
val conn = config.connection!! val conn = config.connection!!
val httpFactory = buildHttpFactory(conn) val httpFactory = buildHttpFactory(conn)
if (httpFactory == null) { if (httpFactory == null) {
@@ -218,7 +222,7 @@ open class ConfiguredUpstreams(
config: UpstreamsConfig.Upstream<UpstreamsConfig.EthereumConnection>, config: UpstreamsConfig.Upstream<UpstreamsConfig.EthereumConnection>,
chain: Chain, chain: Chain,
options: UpstreamsConfig.Options options: UpstreamsConfig.Options
) : EthereumRpcUpstream? { ): EthereumRpcUpstream? {
val conn = config.connection!! val conn = config.connection!!
val urls = ArrayList<URI>() val urls = ArrayList<URI>()
@@ -291,7 +295,7 @@ open class ConfiguredUpstreams(
} }
} }
private fun buildEthereumConnectorFactory(conn: UpstreamsConfig.EthereumConnection, chain: Chain, urls: ArrayList<URI>, forkChoice: ForkChoice): EthereumConnectorFactory? { private fun buildEthereumConnectorFactory(conn: UpstreamsConfig.EthereumConnection, chain: Chain, urls: ArrayList<URI>, forkChoice: ForkChoice): EthereumConnectorFactory? {
val wsFactoryApi = buildWsFactory(conn, urls) val wsFactoryApi = buildWsFactory(conn, urls)
val httpFactory = buildHttpFactory(conn, urls) val httpFactory = buildHttpFactory(conn, urls)
log.info("Using ${chain.chainName} upstream, at ${urls.joinToString()}") log.info("Using ${chain.chainName} upstream, at ${urls.joinToString()}")

View File

@@ -20,11 +20,9 @@ import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import reactor.core.Disposable import reactor.core.Disposable
import reactor.core.publisher.Flux import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.core.publisher.Sinks import reactor.core.publisher.Sinks
import reactor.core.scheduler.Schedulers import reactor.core.scheduler.Schedulers
import reactor.kotlin.core.publisher.toMono import reactor.kotlin.core.publisher.toMono
import java.util.concurrent.atomic.AtomicReference
abstract class AbstractHead( abstract class AbstractHead(
private val forkChoice: ForkChoice private val forkChoice: ForkChoice

View File

@@ -4,8 +4,8 @@ import io.emeraldpay.dshackle.data.BlockContainer
class DistanceExtractor { class DistanceExtractor {
sealed class ChainDistance { sealed class ChainDistance {
data class Distance(val dist: Long): ChainDistance() data class Distance(val dist: Long) : ChainDistance()
object Fork: ChainDistance() object Fork : ChainDistance()
} }
companion object { companion object {
@@ -25,4 +25,4 @@ class DistanceExtractor {
} }
} }
} }
} }

View File

@@ -7,4 +7,4 @@ import io.emeraldpay.grpc.Chain
interface HttpFactory { interface HttpFactory {
fun create(id: String?, chain: Chain): Reader<JsonRpcRequest, JsonRpcResponse> fun create(id: String?, chain: Chain): Reader<JsonRpcRequest, JsonRpcResponse>
} }

View File

@@ -42,4 +42,4 @@ open class HttpRpcFactory(
tls tls
) )
} }
} }

View File

@@ -86,8 +86,8 @@ open class BitcoinMultistream(
} }
} else { } else {
val newHead = MergedHead(upstreams.map { it.getHead() }, MostWorkForkChoice()).apply { val newHead = MergedHead(upstreams.map { it.getHead() }, MostWorkForkChoice()).apply {
this.start() this.start()
} }
val lagObserver = BitcoinHeadLagObserver(newHead, upstreams) val lagObserver = BitcoinHeadLagObserver(newHead, upstreams)
this.lagObserver = lagObserver this.lagObserver = lagObserver
lagObserver.start() lagObserver.start()

View File

@@ -21,7 +21,9 @@ import io.emeraldpay.dshackle.cache.CachesEnabled
import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.config.UpstreamsConfig
import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.startup.QuorumForLabels import io.emeraldpay.dshackle.startup.QuorumForLabels
import io.emeraldpay.dshackle.upstream.* import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.calls.CallMethods import io.emeraldpay.dshackle.upstream.calls.CallMethods
import io.emeraldpay.dshackle.upstream.ethereum.connectors.ConnectorFactory import io.emeraldpay.dshackle.upstream.ethereum.connectors.ConnectorFactory
import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector
@@ -42,8 +44,8 @@ open class EthereumRpcUpstream(
connectorFactory: ConnectorFactory connectorFactory: ConnectorFactory
) : EthereumUpstream(id, options, role, targets, node), Lifecycle, Upstream, CachesEnabled { ) : EthereumUpstream(id, options, role, targets, node), Lifecycle, Upstream, CachesEnabled {
private val log = LoggerFactory.getLogger(EthereumRpcUpstream::class.java) private val log = LoggerFactory.getLogger(EthereumRpcUpstream::class.java)
private val validator : EthereumUpstreamValidator = EthereumUpstreamValidator(this, getOptions()) private val validator: EthereumUpstreamValidator = EthereumUpstreamValidator(this, getOptions())
private val connector : EthereumConnector = connectorFactory.create(this, validator, chain) private val connector: EthereumConnector = connectorFactory.create(this, validator, chain)
private var validatorSubscription: Disposable? = null private var validatorSubscription: Disposable? = null

View File

@@ -43,4 +43,4 @@ abstract class EthereumUpstream(
override fun getLabels(): Collection<UpstreamsConfig.Labels> { override fun getLabels(): Collection<UpstreamsConfig.Labels> {
return node?.let { listOf(it.labels) } ?: emptyList() return node?.let { listOf(it.labels) } ?: emptyList()
} }
} }

View File

@@ -22,7 +22,6 @@ import io.emeraldpay.dshackle.Global
import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.config.UpstreamsConfig
import io.emeraldpay.dshackle.upstream.Upstream import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.UpstreamAvailability import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.etherjar.rpc.json.SyncingJson import io.emeraldpay.etherjar.rpc.json.SyncingJson

View File

@@ -7,4 +7,4 @@ import io.emeraldpay.grpc.Chain
interface ConnectorFactory { interface ConnectorFactory {
fun create(upstream: DefaultUpstream, validator: EthereumUpstreamValidator, chain: Chain): EthereumConnector fun create(upstream: DefaultUpstream, validator: EthereumUpstreamValidator, chain: Chain): EthereumConnector
fun isValid(): Boolean fun isValid(): Boolean
} }

View File

@@ -10,4 +10,4 @@ interface EthereumConnector : Lifecycle {
fun getHead(): Head fun getHead(): Head
fun getApi(): Reader<JsonRpcRequest, JsonRpcResponse> fun getApi(): Reader<JsonRpcRequest, JsonRpcResponse>
} }

View File

@@ -2,7 +2,6 @@ package io.emeraldpay.dshackle.upstream.ethereum.connectors
import io.emeraldpay.dshackle.upstream.DefaultUpstream import io.emeraldpay.dshackle.upstream.DefaultUpstream
import io.emeraldpay.dshackle.upstream.HttpFactory import io.emeraldpay.dshackle.upstream.HttpFactory
import io.emeraldpay.dshackle.upstream.HttpRpcFactory
import io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator import io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsFactory import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsFactory
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
@@ -14,18 +13,18 @@ open class EthereumConnectorFactory(
private val wsFactory: EthereumWsFactory?, private val wsFactory: EthereumWsFactory?,
private val httpFactory: HttpFactory?, private val httpFactory: HttpFactory?,
private val forkChoice: ForkChoice private val forkChoice: ForkChoice
): ConnectorFactory { ) : ConnectorFactory {
private val log = LoggerFactory.getLogger(EthereumConnectorFactory::class.java) private val log = LoggerFactory.getLogger(EthereumConnectorFactory::class.java)
override fun isValid(): Boolean { override fun isValid(): Boolean {
if (preferHttp && httpFactory == null) { if (preferHttp && httpFactory == null) {
return false; return false
} }
return true return true
} }
override fun create(upstream: DefaultUpstream, validator: EthereumUpstreamValidator, chain: Chain): EthereumConnector { override fun create(upstream: DefaultUpstream, validator: EthereumUpstreamValidator, chain: Chain): EthereumConnector {
if (wsFactory!= null && !preferHttp) { if (wsFactory != null && !preferHttp) {
return EthereumWsConnector(wsFactory, upstream, validator, chain, forkChoice) return EthereumWsConnector(wsFactory, upstream, validator, chain, forkChoice)
} }
if (httpFactory == null) { if (httpFactory == null) {
@@ -33,4 +32,4 @@ open class EthereumConnectorFactory(
} }
return EthereumRpcConnector(httpFactory.create(upstream.getId(), chain), wsFactory, upstream.getId(), forkChoice) return EthereumRpcConnector(httpFactory.create(upstream.getId(), chain), wsFactory, upstream.getId(), forkChoice)
} }
} }

View File

@@ -5,9 +5,11 @@ import io.emeraldpay.dshackle.cache.CachesEnabled
import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.MergedHead import io.emeraldpay.dshackle.upstream.MergedHead
import io.emeraldpay.dshackle.upstream.ethereum.* import io.emeraldpay.dshackle.upstream.ethereum.EthereumRpcHead
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsFactory
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsHead
import io.emeraldpay.dshackle.upstream.ethereum.WsConnection
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import io.emeraldpay.dshackle.upstream.forkchoice.MostWorkForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
@@ -15,13 +17,13 @@ import org.springframework.context.Lifecycle
import java.time.Duration import java.time.Duration
class EthereumRpcConnector( class EthereumRpcConnector(
private val directReader : Reader<JsonRpcRequest, JsonRpcResponse>, private val directReader: Reader<JsonRpcRequest, JsonRpcResponse>,
wsFactory: EthereumWsFactory?, wsFactory: EthereumWsFactory?,
id : String, id: String,
forkChoice: ForkChoice forkChoice: ForkChoice
) : EthereumConnector, CachesEnabled { ) : EthereumConnector, CachesEnabled {
private val conn : WsConnection? private val conn: WsConnection?
private val head : Head private val head: Head
companion object { companion object {
private val log = LoggerFactory.getLogger(EthereumRpcConnector::class.java) private val log = LoggerFactory.getLogger(EthereumRpcConnector::class.java)
@@ -76,4 +78,4 @@ class EthereumRpcConnector(
override fun getHead(): Head { override fun getHead(): Head {
return head return head
} }
} }

View File

@@ -58,7 +58,7 @@ class EthereumWsConnector(
} }
override fun isRunning(): Boolean { override fun isRunning(): Boolean {
return head.isRunning return head.isRunning
} }
override fun stop() { override fun stop() {
@@ -73,4 +73,4 @@ class EthereumWsConnector(
override fun getHead(): Head { override fun getHead(): Head {
return head return head
} }
} }

View File

@@ -20,7 +20,6 @@ import io.emeraldpay.dshackle.data.BlockId
import io.emeraldpay.dshackle.data.TxId import io.emeraldpay.dshackle.data.TxId
import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux import reactor.core.publisher.Flux
import reactor.core.scheduler.Schedulers import reactor.core.scheduler.Schedulers

View File

@@ -16,7 +16,6 @@
package io.emeraldpay.dshackle.upstream.ethereum.subscribe package io.emeraldpay.dshackle.upstream.ethereum.subscribe
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage
import io.emeraldpay.etherjar.domain.Address import io.emeraldpay.etherjar.domain.Address
import io.emeraldpay.etherjar.hex.Hex32 import io.emeraldpay.etherjar.hex.Hex32

View File

@@ -16,7 +16,6 @@
package io.emeraldpay.dshackle.upstream.ethereum.subscribe package io.emeraldpay.dshackle.upstream.ethereum.subscribe
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.NewHeadMessage import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.NewHeadMessage
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux import reactor.core.publisher.Flux

View File

@@ -17,7 +17,6 @@ package io.emeraldpay.dshackle.upstream.ethereum.subscribe
import io.emeraldpay.dshackle.upstream.UpstreamAvailability import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux import reactor.core.publisher.Flux
import java.time.Duration import java.time.Duration

View File

@@ -21,7 +21,6 @@ import io.emeraldpay.dshackle.data.BlockId
import io.emeraldpay.dshackle.data.TxId import io.emeraldpay.dshackle.data.TxId
import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumLikeMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage
import io.emeraldpay.etherjar.hex.HexData import io.emeraldpay.etherjar.hex.HexData
import io.emeraldpay.etherjar.rpc.json.TransactionReceiptJson import io.emeraldpay.etherjar.rpc.json.TransactionReceiptJson

View File

@@ -21,7 +21,9 @@ import io.emeraldpay.dshackle.cache.CachesEnabled
import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.config.UpstreamsConfig
import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.startup.QuorumForLabels import io.emeraldpay.dshackle.startup.QuorumForLabels
import io.emeraldpay.dshackle.upstream.* import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.calls.CallMethods import io.emeraldpay.dshackle.upstream.calls.CallMethods
import io.emeraldpay.dshackle.upstream.ethereum.connectors.ConnectorFactory import io.emeraldpay.dshackle.upstream.ethereum.connectors.ConnectorFactory
import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector import io.emeraldpay.dshackle.upstream.ethereum.connectors.EthereumConnector
@@ -42,8 +44,8 @@ open class EthereumPosRpcUpstream(
connectorFactory: ConnectorFactory connectorFactory: ConnectorFactory
) : EthereumPosUpstream(id, options, role, targets, node), Lifecycle, Upstream, CachesEnabled { ) : EthereumPosUpstream(id, options, role, targets, node), Lifecycle, Upstream, CachesEnabled {
private val log = LoggerFactory.getLogger(EthereumPosRpcUpstream::class.java) private val log = LoggerFactory.getLogger(EthereumPosRpcUpstream::class.java)
private val validator : EthereumUpstreamValidator = EthereumUpstreamValidator(this, getOptions()) private val validator: EthereumUpstreamValidator = EthereumUpstreamValidator(this, getOptions())
private val connector : EthereumConnector = connectorFactory.create(this, validator, chain) private val connector: EthereumConnector = connectorFactory.create(this, validator, chain)
private var validatorSubscription: Disposable? = null private var validatorSubscription: Disposable? = null

View File

@@ -43,4 +43,4 @@ abstract class EthereumPosUpstream(
override fun getLabels(): Collection<UpstreamsConfig.Labels> { override fun getLabels(): Collection<UpstreamsConfig.Labels> {
return node?.let { listOf(it.labels) } ?: emptyList() return node?.let { listOf(it.labels) } ?: emptyList()
} }
} }

View File

@@ -5,8 +5,8 @@ import io.emeraldpay.dshackle.data.BlockContainer
interface ForkChoice { interface ForkChoice {
sealed class ChoiceResult { sealed class ChoiceResult {
data class Updated(val nwhead: BlockContainer): ChoiceResult() data class Updated(val nwhead: BlockContainer) : ChoiceResult()
data class Same(val head: BlockContainer?): ChoiceResult() data class Same(val head: BlockContainer?) : ChoiceResult()
} }
fun getHead(): BlockContainer? fun getHead(): BlockContainer?
@@ -14,4 +14,4 @@ interface ForkChoice {
fun filter(block: BlockContainer): Boolean fun filter(block: BlockContainer): Boolean
fun choose(block: BlockContainer): ChoiceResult fun choose(block: BlockContainer): ChoiceResult
} }

View File

@@ -6,7 +6,7 @@ import java.util.concurrent.atomic.AtomicReference
class MostWorkForkChoice : ForkChoice { class MostWorkForkChoice : ForkChoice {
private val head = AtomicReference<BlockContainer>(null) private val head = AtomicReference<BlockContainer>(null)
override fun getHead() : BlockContainer? { override fun getHead(): BlockContainer? {
return head.get() return head.get()
} }
@@ -28,5 +28,4 @@ class MostWorkForkChoice : ForkChoice {
} }
return ForkChoice.ChoiceResult.Same(nwhead) return ForkChoice.ChoiceResult.Same(nwhead)
} }
}
}

View File

@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicReference
class NoChoiceWithPriorityForkChoice( class NoChoiceWithPriorityForkChoice(
private val nodeRating: Int private val nodeRating: Int
): ForkChoice { ) : ForkChoice {
private val head = AtomicReference<BlockContainer>(null) private val head = AtomicReference<BlockContainer>(null)
private val seenBlocks = RingSet<BlockId>(10) private val seenBlocks = RingSet<BlockId>(10)
@@ -33,4 +33,4 @@ class NoChoiceWithPriorityForkChoice(
} }
return ForkChoice.ChoiceResult.Same(nwhead) return ForkChoice.ChoiceResult.Same(nwhead)
} }
} }

View File

@@ -5,7 +5,7 @@ import io.emeraldpay.dshackle.data.BlockId
import io.emeraldpay.dshackle.data.RingSet import io.emeraldpay.dshackle.data.RingSet
import java.util.concurrent.atomic.AtomicReference import java.util.concurrent.atomic.AtomicReference
class PriorityForkChoice: ForkChoice { class PriorityForkChoice : ForkChoice {
private val head = AtomicReference<BlockContainer>(null) private val head = AtomicReference<BlockContainer>(null)
private val seenBlocks = RingSet<BlockId>(10) private val seenBlocks = RingSet<BlockId>(10)
@@ -32,4 +32,4 @@ class PriorityForkChoice: ForkChoice {
} }
return ForkChoice.ChoiceResult.Same(nwhead) return ForkChoice.ChoiceResult.Same(nwhead)
} }
} }