From 0063c898658a816b41efb5e3f97cead823b8a64b Mon Sep 17 00:00:00 2001 From: KirillPamPam Date: Tue, 12 Aug 2025 17:36:23 +0400 Subject: [PATCH] Fix quorum (#700) --- .../dshackle/upstream/calls/ManagedCallMethods.kt | 7 +------ .../dshackle/upstream/calls/ManagedCallMethodsSpec.groovy | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethods.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethods.kt index a5fea9fa..d4ac669e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethods.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethods.kt @@ -54,7 +54,6 @@ class ManagedCallMethods( ) private val quorum: MutableMap> = HashMap() private val staticResponse: MutableMap = HashMap() - private val redefined = delegated.keys.filter(enabled::contains).associateWith { true } init { enabled.forEach { m -> @@ -81,7 +80,7 @@ class ManagedCallMethods( override fun createQuorumFor(method: String): CallQuorum { return when { - isDelegated(method) && !isRedefined(method) -> delegate.createQuorumFor(method) + isDelegated(method) -> delegate.createQuorumFor(method) allAllowed.contains(method) -> quorum[method]?.create() ?: defaultQuorum.create() else -> { log.warn("Getting quorum for unknown method - $method") @@ -94,10 +93,6 @@ class ManagedCallMethods( return delegated[method] ?: false } - private fun isRedefined(method: String): Boolean { - return redefined[method] ?: false - } - override fun isCallable(method: String): Boolean { return allAllowed.contains(method) } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy index fa4c1de4..d47731f7 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy @@ -75,7 +75,7 @@ class ManagedCallMethodsSpec extends Specification { def delegated = ["eth_test", "eth_test2"] as Set def delegate = Mock(CallMethods) { _ * it.getSupportedMethods() >> delegated - 0 * it.createQuorumFor("eth_test") >> new BroadcastQuorum() + 1 * it.createQuorumFor("eth_test") >> new BroadcastQuorum() } def managed = new ManagedCallMethods( delegate, @@ -88,7 +88,7 @@ class ManagedCallMethodsSpec extends Specification { def act = managed.createQuorumFor("eth_test") then: act != null - act instanceof AlwaysQuorum + act instanceof BroadcastQuorum } def "Use custom quorum if provided"() {