Fix quorum (#700)

This commit is contained in:
KirillPamPam
2025-08-12 17:36:23 +04:00
committed by GitHub
parent a34f2186cc
commit 0063c89865
2 changed files with 3 additions and 8 deletions

View File

@@ -54,7 +54,6 @@ class ManagedCallMethods(
) )
private val quorum: MutableMap<String, Factory<CallQuorum>> = HashMap() private val quorum: MutableMap<String, Factory<CallQuorum>> = HashMap()
private val staticResponse: MutableMap<String, String> = HashMap() private val staticResponse: MutableMap<String, String> = HashMap()
private val redefined = delegated.keys.filter(enabled::contains).associateWith { true }
init { init {
enabled.forEach { m -> enabled.forEach { m ->
@@ -81,7 +80,7 @@ class ManagedCallMethods(
override fun createQuorumFor(method: String): CallQuorum { override fun createQuorumFor(method: String): CallQuorum {
return when { return when {
isDelegated(method) && !isRedefined(method) -> delegate.createQuorumFor(method) isDelegated(method) -> delegate.createQuorumFor(method)
allAllowed.contains(method) -> quorum[method]?.create() ?: defaultQuorum.create() allAllowed.contains(method) -> quorum[method]?.create() ?: defaultQuorum.create()
else -> { else -> {
log.warn("Getting quorum for unknown method - $method") log.warn("Getting quorum for unknown method - $method")
@@ -94,10 +93,6 @@ class ManagedCallMethods(
return delegated[method] ?: false return delegated[method] ?: false
} }
private fun isRedefined(method: String): Boolean {
return redefined[method] ?: false
}
override fun isCallable(method: String): Boolean { override fun isCallable(method: String): Boolean {
return allAllowed.contains(method) return allAllowed.contains(method)
} }

View File

@@ -75,7 +75,7 @@ class ManagedCallMethodsSpec extends Specification {
def delegated = ["eth_test", "eth_test2"] as Set def delegated = ["eth_test", "eth_test2"] as Set
def delegate = Mock(CallMethods) { def delegate = Mock(CallMethods) {
_ * it.getSupportedMethods() >> delegated _ * it.getSupportedMethods() >> delegated
0 * it.createQuorumFor("eth_test") >> new BroadcastQuorum() 1 * it.createQuorumFor("eth_test") >> new BroadcastQuorum()
} }
def managed = new ManagedCallMethods( def managed = new ManagedCallMethods(
delegate, delegate,
@@ -88,7 +88,7 @@ class ManagedCallMethodsSpec extends Specification {
def act = managed.createQuorumFor("eth_test") def act = managed.createQuorumFor("eth_test")
then: then:
act != null act != null
act instanceof AlwaysQuorum act instanceof BroadcastQuorum
} }
def "Use custom quorum if provided"() { def "Use custom quorum if provided"() {