problem: tx and block by hash can be fetched from any available node
This commit is contained in:
@@ -15,19 +15,22 @@
|
|||||||
*/
|
*/
|
||||||
package io.emeraldpay.dshackle.upstream.calls
|
package io.emeraldpay.dshackle.upstream.calls
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
|
||||||
import io.emeraldpay.dshackle.quorum.*
|
import io.emeraldpay.dshackle.quorum.*
|
||||||
import io.infinitape.etherjar.rpc.RpcException
|
import io.infinitape.etherjar.rpc.RpcException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class DefaultBitcoinMethods() : CallMethods {
|
class DefaultBitcoinMethods() : CallMethods {
|
||||||
|
|
||||||
private val anyResponseMethods = listOf(
|
private val freshMethods = listOf(
|
||||||
"getblock", "getblockhash",
|
"getblock",
|
||||||
"gettransaction", "getrawtransaction", "gettxout",
|
"gettransaction", "gettxout",
|
||||||
"getmemorypool"
|
"getmemorypool"
|
||||||
).sorted()
|
).sorted()
|
||||||
|
|
||||||
|
private val anyResponseMethods = listOf(
|
||||||
|
"getblockhash", "getrawtransaction"
|
||||||
|
).sorted()
|
||||||
|
|
||||||
private val headVerifiedMethods = listOf(
|
private val headVerifiedMethods = listOf(
|
||||||
"getbestblockhash", "getblocknumber", "getblockcount",
|
"getbestblockhash", "getblocknumber", "getblockcount",
|
||||||
"listunspent", "getreceivedbyaddress"
|
"listunspent", "getreceivedbyaddress"
|
||||||
@@ -41,12 +44,13 @@ class DefaultBitcoinMethods() : CallMethods {
|
|||||||
"sendrawtransaction"
|
"sendrawtransaction"
|
||||||
).sorted()
|
).sorted()
|
||||||
|
|
||||||
private val allowedMethods = (anyResponseMethods + hardcodedMethods + headVerifiedMethods).sorted()
|
private val allowedMethods = (freshMethods + anyResponseMethods + hardcodedMethods + headVerifiedMethods).sorted()
|
||||||
|
|
||||||
override fun getQuorumFor(method: String): CallQuorum {
|
override fun getQuorumFor(method: String): CallQuorum {
|
||||||
return when {
|
return when {
|
||||||
Collections.binarySearch(hardcodedMethods, method) >= 0 -> AlwaysQuorum()
|
Collections.binarySearch(hardcodedMethods, method) >= 0 -> AlwaysQuorum()
|
||||||
Collections.binarySearch(anyResponseMethods, method) >= 0 -> NotLaggingQuorum(2)
|
Collections.binarySearch(anyResponseMethods, method) >= 0 -> NonEmptyQuorum()
|
||||||
|
Collections.binarySearch(freshMethods, method) >= 0 -> NotLaggingQuorum(2)
|
||||||
Collections.binarySearch(headVerifiedMethods, method) >= 0 -> NotLaggingQuorum(0)
|
Collections.binarySearch(headVerifiedMethods, method) >= 0 -> NotLaggingQuorum(0)
|
||||||
Collections.binarySearch(broadcastMethods, method) >= 0 -> BroadcastQuorum()
|
Collections.binarySearch(broadcastMethods, method) >= 0 -> BroadcastQuorum()
|
||||||
else -> AlwaysQuorum()
|
else -> AlwaysQuorum()
|
||||||
|
|||||||
Reference in New Issue
Block a user