diff --git a/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt index c7ae3a91..79f709b6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt @@ -126,7 +126,7 @@ class QuorumRpcReader( } fun callApi(api: Upstream, key: JsonRpcRequest): Mono, Upstream>> { - return api.getApi() + return api.getIngressReader() .read(key) .flatMap { response -> response.requireResult() diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt index 7e4a635b..d7a95981 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt @@ -274,7 +274,7 @@ open class NativeCall( if (method in DefaultEthereumMethods.newFilterMethods) CreateFilterDecorator() else NoneResultDecorator() fun fetch(ctx: ValidCallContext): Mono { - return ctx.upstream.getRoutedApi(localRouterEnabled) + return ctx.upstream.getLocalReader(localRouterEnabled) .flatMap { api -> api.read(JsonRpcRequest(ctx.payload.method, ctx.payload.params, ctx.nonce, ctx.forwardedSelector)) .flatMap(JsonRpcResponse::requireResult) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Multistream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Multistream.kt index b1343232..6305c7c9 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Multistream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Multistream.kt @@ -173,9 +173,9 @@ abstract class Multistream( /** * Finds an API that leverages caches and other optimizations/transformations of the request. */ - abstract fun getRoutedApi(localEnabled: Boolean): Mono + abstract fun getLocalReader(localEnabled: Boolean): Mono - override fun getApi(): JsonRpcReader { + override fun getIngressReader(): JsonRpcReader { throw NotImplementedError("Immediate direct API is not implemented for Aggregated Upstream") } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Upstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Upstream.kt index 3685bbf9..f42275a4 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Upstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Upstream.kt @@ -26,7 +26,12 @@ interface Upstream { fun getStatus(): UpstreamAvailability fun observeStatus(): Flux fun getHead(): Head - fun getApi(): JsonRpcReader + + /** + * Get an actual reader that access the current upstream + */ + fun getIngressReader(): JsonRpcReader + fun getOptions(): UpstreamsConfig.Options fun getRole(): UpstreamsConfig.UpstreamRole fun setLag(lag: Long) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinMultistream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinMultistream.kt index afa793fb..033ce50e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinMultistream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinMultistream.kt @@ -100,11 +100,11 @@ open class BitcoinMultistream( val apis = getApiSource(matcher) apis.request(1) return Mono.from(apis) - .map(Upstream::getApi) + .map(Upstream::getIngressReader) .switchIfEmpty(Mono.error(Exception("No API available for $chain"))) } - override fun getRoutedApi(localEnabled: Boolean): Mono { + override fun getLocalReader(localEnabled: Boolean): Mono { return Mono.just(callRouter) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinRpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinRpcUpstream.kt index 8d6802ab..fee85f3c 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinRpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/BitcoinRpcUpstream.kt @@ -63,7 +63,7 @@ open class BitcoinRpcUpstream( return head } - override fun getApi(): JsonRpcReader { + override fun getIngressReader(): JsonRpcReader { return directApi } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt index e538b3bb..d1c0fa2e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/ERC20Balance.kt @@ -59,7 +59,7 @@ open class ERC20Balance { open fun getBalance(upstream: EthereumPosRpcUpstream, token: ERC20Token, address: Address): Mono { return upstream - .getApi() + .getIngressReader() .read(prepareEthCall(token, address, upstream.getHead())) .flatMap(JsonRpcResponse::requireStringResult) .map { Hex32.from(it).asQuantity().value } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/LocalCallRouter.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt similarity index 98% rename from src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/LocalCallRouter.kt rename to src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt index b75923d6..217eb6c0 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/LocalCallRouter.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt @@ -36,7 +36,7 @@ import java.math.BigInteger * * @see EthereumCachingReader */ -class LocalCallRouter( +class EthereumLocalReader( private val reader: EthereumCachingReader, private val methods: CallMethods, private val head: Head, @@ -44,7 +44,7 @@ class LocalCallRouter( ) : JsonRpcReader { companion object { - private val log = LoggerFactory.getLogger(LocalCallRouter::class.java) + private val log = LoggerFactory.getLogger(EthereumLocalReader::class.java) } override fun read(key: JsonRpcRequest): Mono { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt index a5a47f50..4f228f5a 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumMultistream.kt @@ -177,8 +177,8 @@ open class EthereumMultistream( return subscribe } - override fun getRoutedApi(localEnabled: Boolean): Mono { - return Mono.just(LocalCallRouter(reader, getMethods(), getHead(), localEnabled)) + override fun getLocalReader(localEnabled: Boolean): Mono { + return Mono.just(EthereumLocalReader(reader, getMethods(), getHead(), localEnabled)) } override fun getHead(mather: Selector.Matcher): Head = diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumRpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumRpcUpstream.kt index d3a4b426..3661d31e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumRpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumRpcUpstream.kt @@ -86,8 +86,8 @@ open class EthereumRpcUpstream( return connector.isRunning() } - override fun getApi(): JsonRpcReader { - return connector.getApi() + override fun getIngressReader(): JsonRpcReader { + return connector.getIngressReader() } override fun isGrpc(): Boolean { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt index d1fdc07c..3ff8e1a6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt @@ -48,7 +48,7 @@ open class EthereumUpstreamValidator( open fun validate(): Mono { return upstream - .getApi() + .getIngressReader() .read(JsonRpcRequest("eth_syncing", listOf())) .flatMap(JsonRpcResponse::requireResult) .map { objectMapper.readValue(it, SyncingJson::class.java) } @@ -62,7 +62,7 @@ open class EthereumUpstreamValidator( Mono.just(UpstreamAvailability.SYNCING) } else { upstream - .getApi() + .getIngressReader() .read(JsonRpcRequest("net_peerCount", listOf())) .flatMap(JsonRpcResponse::requireStringResult) .map(Integer::decode) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumConnector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumConnector.kt index 722c5b98..c000e027 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumConnector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumConnector.kt @@ -8,7 +8,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.EthereumIngressSubscription interface EthereumConnector : Lifecycle { fun getHead(): Head - fun getApi(): JsonRpcReader + fun getIngressReader(): JsonRpcReader fun getIngressSubscription(): EthereumIngressSubscription } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt index 6af81f16..e750b884 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumRpcConnector.kt @@ -32,14 +32,14 @@ class EthereumRpcConnector( // do not set upstream to the WS, since it doesn't control the RPC upstream conn = wsFactory.create(null) val subscriptions = WsSubscriptionsImpl(conn) - val wsHead = EthereumWsHead(id, AlwaysForkChoice(), blockValidator, getApi(), subscriptions) + val wsHead = EthereumWsHead(id, AlwaysForkChoice(), blockValidator, getIngressReader(), subscriptions) // receive all new blocks through WebSockets, but also periodically verify with RPC in case if WS failed - val rpcHead = EthereumRpcHead(getApi(), AlwaysForkChoice(), id, blockValidator, Duration.ofSeconds(30)) + val rpcHead = EthereumRpcHead(getIngressReader(), AlwaysForkChoice(), id, blockValidator, Duration.ofSeconds(30)) head = MergedHead(listOf(rpcHead, wsHead), forkChoice, "Merged for $id") } else { conn = null log.warn("Setting up connector for $id upstream with RPC-only access, less effective than WS+RPC") - head = EthereumRpcHead(getApi(), forkChoice, id, blockValidator) + head = EthereumRpcHead(getIngressReader(), forkChoice, id, blockValidator) } } @@ -70,7 +70,7 @@ class EthereumRpcConnector( conn?.close() } - override fun getApi(): JsonRpcReader { + override fun getIngressReader(): JsonRpcReader { return directReader } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt index bc6bc41f..f7127559 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/connectors/EthereumWsConnector.kt @@ -16,15 +16,15 @@ class EthereumWsConnector( blockValidator: BlockValidator ) : EthereumConnector { private val conn: WsConnectionImpl - private val api: JsonRpcReader + private val reader: JsonRpcReader private val head: EthereumWsHead private val subscriptions: EthereumIngressSubscription init { conn = wsFactory.create(upstream) - api = JsonRpcWsClient(conn) + reader = JsonRpcWsClient(conn) val wsSubscriptions = WsSubscriptionsImpl(conn) - head = EthereumWsHead(upstream.getId(), forkChoice, blockValidator, api, wsSubscriptions) + head = EthereumWsHead(upstream.getId(), forkChoice, blockValidator, reader, wsSubscriptions) subscriptions = EthereumWsIngressSubscription(wsSubscriptions) } @@ -42,8 +42,8 @@ class EthereumWsConnector( head.stop() } - override fun getApi(): JsonRpcReader { - return api + override fun getIngressReader(): JsonRpcReader { + return reader } override fun getIngressSubscription(): EthereumIngressSubscription { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosMultiStream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosMultiStream.kt index 53f116b5..08726521 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosMultiStream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosMultiStream.kt @@ -147,8 +147,8 @@ open class EthereumPosMultiStream( return this as T } - override fun getRoutedApi(localEnabled: Boolean): Mono { - return Mono.just(LocalCallRouter(reader, getMethods(), getHead(), localEnabled)) + override fun getLocalReader(localEnabled: Boolean): Mono { + return Mono.just(EthereumLocalReader(reader, getMethods(), getHead(), localEnabled)) } override fun getEgressSubscription(): EthereumEgressSubscription { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosRpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosRpcUpstream.kt index 390ff7f9..c2a027fa 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosRpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum_pos/EthereumPosRpcUpstream.kt @@ -81,8 +81,8 @@ open class EthereumPosRpcUpstream( return connector.isRunning() } - override fun getApi(): JsonRpcReader { - return connector.getApi() + override fun getIngressReader(): JsonRpcReader { + return connector.getIngressReader() } override fun isGrpc(): Boolean { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/BitcoinGrpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/BitcoinGrpcUpstream.kt index b0acf871..27fe66e6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/BitcoinGrpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/BitcoinGrpcUpstream.kt @@ -112,7 +112,7 @@ class BitcoinGrpcUpstream( return grpcHead } - override fun getApi(): JsonRpcReader { + override fun getIngressReader(): JsonRpcReader { return defaultReader } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstream.kt index 96250ac6..2806f0dd 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumGrpcUpstream.kt @@ -162,7 +162,7 @@ open class EthereumGrpcUpstream( return grpcHead } - override fun getApi(): JsonRpcReader { + override fun getIngressReader(): JsonRpcReader { return defaultReader } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumPosGrpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumPosGrpcUpstream.kt index c7c4c9c5..142c3dd1 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumPosGrpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/EthereumPosGrpcUpstream.kt @@ -162,7 +162,7 @@ open class EthereumPosGrpcUpstream( return grpcHead } - override fun getApi(): JsonRpcReader { + override fun getIngressReader(): JsonRpcReader { return defaultReader } diff --git a/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy index a3f255d2..cc2af7c1 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/quorum/QuorumRpcReaderSpec.groovy @@ -17,7 +17,6 @@ package io.emeraldpay.dshackle.quorum import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.reader.Reader -import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.dshackle.upstream.FilteredApis import io.emeraldpay.dshackle.upstream.Selector import io.emeraldpay.dshackle.upstream.Upstream @@ -40,7 +39,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - 1 * getApi() >> Mock(Reader) { + 1 * getIngressReader() >> Mock(Reader) { 1 * read(new JsonRpcRequest("eth_test", [])) >> Mono.just(JsonRpcResponse.ok("1")) } } @@ -73,7 +72,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> api + _ * getIngressReader() >> api } def apis = new FilteredApis( Chain.ETHEREUM, @@ -110,7 +109,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> api + _ * getIngressReader() >> api } def apis = new FilteredApis( Chain.ETHEREUM, @@ -137,7 +136,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> Mock(Reader) { + _ * getIngressReader() >> Mock(Reader) { 2 * read(new JsonRpcRequest("eth_test", [])) >>> [ Mono.just(JsonRpcResponse.ok("null")), Mono.just(JsonRpcResponse.ok("1")) @@ -169,7 +168,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> Mock(Reader) { + _ * getIngressReader() >> Mock(Reader) { 2 * read(new JsonRpcRequest("eth_test", [])) >>> [ Mono.just(JsonRpcResponse.error(1, "test")), Mono.just(JsonRpcResponse.ok("1")) @@ -200,7 +199,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> Mock(Reader) { + _ * getIngressReader() >> Mock(Reader) { 3 * read(new JsonRpcRequest("eth_test", [])) >>> [ Mono.just(JsonRpcResponse.ok("null")), Mono.just(JsonRpcResponse.error(1, "test")), @@ -239,7 +238,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> api + _ * getIngressReader() >> api } def apis = new FilteredApis( Chain.ETHEREUM, @@ -269,7 +268,7 @@ class QuorumRpcReaderSpec extends Specification { def up = Mock(Upstream) { _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> api + _ * getIngressReader() >> api } def apis = new FilteredApis( Chain.ETHEREUM, @@ -298,7 +297,7 @@ class QuorumRpcReaderSpec extends Specification { _ * getLag() >> 0 _ * isAvailable() >> true _ * getRole() >> UpstreamsConfig.UpstreamRole.PRIMARY - _ * getApi() >> Mock(Reader) { + _ * getIngressReader() >> Mock(Reader) { _ * read(new JsonRpcRequest("eth_test", [])) >>> [ Mono.just(JsonRpcResponse.error(-3010, "test")), ] diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy index 4ce7afc9..3c3a9768 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy @@ -75,7 +75,7 @@ class NativeCallSpec extends Specification { 1 * read(new JsonRpcRequest("eth_test", [])) >> Mono.just(new JsonRpcResponse("1".bytes, null)) } def upstream = Mock(Multistream) { - 1 * getRoutedApi(_) >> Mono.just(routedApi) + 1 * getLocalReader(_) >> Mono.just(routedApi) } def nativeCall = nativeCall() @@ -96,7 +96,7 @@ class NativeCallSpec extends Specification { 1 * read(new JsonRpcRequest("eth_test", [])) >> Mono.error(new RpcException(RpcResponseError.CODE_METHOD_NOT_EXIST, "Test message")) } def upstream = Mock(Multistream) { - 1 * getRoutedApi(_) >> Mono.just(routedApi) + 1 * getLocalReader(_) >> Mono.just(routedApi) } def nativeCall = nativeCall() diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumConnectorMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumConnectorMock.groovy index 010f6f9d..0565dbd9 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/EthereumConnectorMock.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/EthereumConnectorMock.groovy @@ -18,7 +18,7 @@ class EthereumConnectorMock implements EthereumConnector { } @Override - Reader getApi() { + Reader getIngressReader() { return this.api } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy index cef7b663..71ac4bb6 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy @@ -259,7 +259,7 @@ class MultistreamSpec extends Specification { @NotNull @Override - Mono> getRoutedApi(boolean localEnabled) { + Mono> getLocalReader(boolean localEnabled) { return null } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/LocalCallRouterSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy similarity index 91% rename from src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/LocalCallRouterSpec.groovy rename to src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy index 85489977..87d26b94 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/LocalCallRouterSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy @@ -2,7 +2,6 @@ package io.emeraldpay.dshackle.upstream.ethereum import io.emeraldpay.dshackle.Global import io.emeraldpay.dshackle.cache.Caches -import io.emeraldpay.dshackle.config.CacheConfig import io.emeraldpay.dshackle.reader.EmptyReader import io.emeraldpay.dshackle.test.TestingCommons import io.emeraldpay.dshackle.upstream.EmptyHead @@ -18,12 +17,12 @@ import spock.lang.Specification import java.time.Duration -class LocalCallRouterSpec extends Specification { +class EthereumLocalReaderSpec extends Specification { def "Calls hardcoded"() { setup: def methods = new DefaultEthereumMethods(Chain.ETHEREUM) - def router = new LocalCallRouter( + def router = new EthereumLocalReader( new EthereumCachingReader( TestingCommons.multistream(TestingCommons.api()), Caches.default(), @@ -42,7 +41,7 @@ class LocalCallRouterSpec extends Specification { def "Returns empty if nonce set"() { setup: def methods = new DefaultEthereumMethods(Chain.ETHEREUM) - def router = new LocalCallRouter( + def router = new EthereumLocalReader( new EthereumCachingReader( TestingCommons.multistream(TestingCommons.api()), Caches.default(), @@ -72,7 +71,7 @@ class LocalCallRouterSpec extends Specification { } } def methods = new DefaultEthereumMethods(Chain.ETHEREUM) - def router = new LocalCallRouter(reader, methods, head, true) + def router = new EthereumLocalReader(reader, methods, head, true) when: def act = router.getBlockByNumber(["latest", false]) @@ -98,7 +97,7 @@ class LocalCallRouterSpec extends Specification { } } def methods = new DefaultEthereumMethods(Chain.ETHEREUM) - def router = new LocalCallRouter(reader, methods, head, true) + def router = new EthereumLocalReader(reader, methods, head, true) when: def act = router.getBlockByNumber(["earliest", false]) @@ -124,7 +123,7 @@ class LocalCallRouterSpec extends Specification { } } def methods = new DefaultEthereumMethods(Chain.ETHEREUM) - def router = new LocalCallRouter(reader, methods, head, true) + def router = new EthereumLocalReader(reader, methods, head, true) when: def act = router.getBlockByNumber(["0x123ef", false]) @@ -148,7 +147,7 @@ class LocalCallRouterSpec extends Specification { _ * blocksByHeightAsCont() >> new EmptyReader<>() } def methods = new DefaultEthereumMethods(Chain.ETHEREUM) - def router = new LocalCallRouter(reader, methods, head, true) + def router = new EthereumLocalReader(reader, methods, head, true) when: def act = router.getBlockByNumber(["0x0", true])