From 09a6508cab441371e8ef21f9290292aa6aa712c4 Mon Sep 17 00:00:00 2001 From: a10zn8 Date: Thu, 1 Aug 2024 13:25:46 +0300 Subject: [PATCH] support erigon3 syncing validation (#538) --- .../ethereum/EthereumChainSpecific.kt | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt index 92b0525e..5604c300 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt @@ -115,25 +115,20 @@ object EthereumChainSpecific : AbstractPollChainSpecific() { } else { UpstreamAvailability.OK } - } else { - when (chain) { - Chain.TRON__MAINNET, Chain.TRON__SHASTA -> { - var current = - BigInteger(raw.get("currentBlock")?.asText()?.lowercase()?.substringAfter("x"), 16) - var highest = - BigInteger(raw.get("highestBlock")?.asText()?.lowercase()?.substringAfter("x"), 16) + } else if (raw.get("currentBlock") != null && raw.get("highestBlock") != null) { + val current = + BigInteger(raw.get("currentBlock")?.asText()?.lowercase()?.substringAfter("x"), 16) + val highest = + BigInteger(raw.get("highestBlock")?.asText()?.lowercase()?.substringAfter("x"), 16) - if (highest - current > config.syncingLagSize.toBigInteger()) { - UpstreamAvailability.SYNCING - } else { - UpstreamAvailability.OK - } - } - else -> { - log.warn("Received syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}") - UpstreamAvailability.SYNCING - } + if (highest - current > config.syncingLagSize.toBigInteger()) { + UpstreamAvailability.SYNCING + } else { + UpstreamAvailability.OK } + } else { + log.error("Received unknown syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}") + UpstreamAvailability.OK } } }