Skip to content

Commit

Permalink
Simplify eth_syncing check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Sizov committed Jun 14, 2024
1 parent 10f4c6b commit 880b200
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 247 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ import io.emeraldpay.dshackle.upstream.ChainResponse
import io.emeraldpay.dshackle.upstream.Upstream
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
import io.emeraldpay.dshackle.upstream.ValidateUpstreamSettingsResult
import io.emeraldpay.dshackle.upstream.arbitrum.json.NitroSyncingJson
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
import io.emeraldpay.dshackle.upstream.ethereum.json.SyncingJson
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionCallJson
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
import org.springframework.scheduling.concurrent.CustomizableThreadFactory
Expand Down Expand Up @@ -60,10 +58,12 @@ open class EthereumUpstreamValidator @JvmOverloads constructor(
return ValidateSyncingRequest(
ChainRequest("eth_syncing", ListParams()),
) { bytes ->
if (listOf(Chain.ARBITRUM__MAINNET, Chain.ARBITRUM__SEPOLIA, Chain.ARBITRUM_NOVA__MAINNET).contains(chain)) {
objectMapper.readValue(bytes, NitroSyncingJson::class.java).isSyncing
val raw = Global.objectMapper.readTree(bytes)
if (raw.isBoolean) {
raw.asBoolean()
} else {
objectMapper.readValue(bytes, SyncingJson::class.java).isSyncing
log.warn("Received syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}")
true
}
}
}
Expand Down

0 comments on commit 880b200

Please sign in to comment.