From 6aae65cf40066cb9e19f5c3fa96a1653aaab231a Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Sat, 18 Jun 2022 15:15:35 -0400 Subject: [PATCH] problem: default quorum options per method may not work for everyone but cannot be reconfigured --- .../dshackle/upstream/calls/ManagedCallMethods.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 0e36c6f9..e2ffc47f 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethods.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethods.kt @@ -47,6 +47,7 @@ class ManagedCallMethods( ) private val quorum: MutableMap = HashMap() private val staticResponse: MutableMap = HashMap() + private val redefined = delegated.filter(enabled::contains).sorted() init { enabled.forEach { m -> @@ -73,7 +74,7 @@ class ManagedCallMethods( override fun getQuorumFor(method: String): CallQuorum { return when { - Collections.binarySearch(delegated, method) >= 0 -> delegate.getQuorumFor(method) + isDelegated(method) && !isRedefined(method) -> delegate.getQuorumFor(method) enabled.contains(method) -> quorum[method] ?: defaultQuorum else -> { log.warn("Getting quorum for unknown method") @@ -82,6 +83,14 @@ class ManagedCallMethods( } } + private fun isDelegated(method: String): Boolean { + return Collections.binarySearch(delegated, method) >= 0 + } + + private fun isRedefined(method: String): Boolean { + return Collections.binarySearch(redefined, method) >= 0 + } + override fun isCallable(method: String): Boolean { return allAllowed.contains(method) }