diff --git a/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJson.java b/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJson.java deleted file mode 100644 index 9b27acba0..000000000 --- a/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJson.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.emeraldpay.dshackle.upstream.arbitrum.json; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonDeserialize(using = NitroSyncingJsonDeserializer.class) -@JsonSerialize(using = NitroSyncingJsonSerializer.class) -public class NitroSyncingJson { - - private boolean syncing; - - private Long syncTargetMsgCount; - private Long feedPendingMessageCount; - private Long msgCount; - - public boolean isSyncing() { - return syncing; - } - - public void setSyncing(boolean syncing) { - this.syncing = syncing; - } - - public Long getSyncTargetMsgCount() { - return syncTargetMsgCount; - } - - public void setSyncTargetMsgCount(Long syncTargetMsgCount) { - this.syncTargetMsgCount = syncTargetMsgCount; - } - - public Long getFeedPendingMessageCount() { - return feedPendingMessageCount; - } - - public void setFeedPendingMessageCount(Long feedPendingMessageCount) { - this.feedPendingMessageCount = feedPendingMessageCount; - } - - public Long getMsgCount() { - return msgCount; - } - - public void setMsgCount(Long msgCount) { - this.msgCount = msgCount; - } -} diff --git a/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJsonDeserializer.java b/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJsonDeserializer.java deleted file mode 100644 index 7bcbcfebf..000000000 --- a/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJsonDeserializer.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.emeraldpay.dshackle.upstream.arbitrum.json; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import io.emeraldpay.dshackle.upstream.arbitrum.json.NitroSyncingJson; -import io.emeraldpay.dshackle.upstream.ethereum.json.EtherJsonDeserializer; - -import java.io.IOException; - -public class NitroSyncingJsonDeserializer extends EtherJsonDeserializer { - - @Override - public NitroSyncingJson deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - JsonNode node = jp.readValueAsTree(); - NitroSyncingJson resp = new NitroSyncingJson(); - if (node.isBoolean()) { - resp.setSyncing(node.asBoolean()); - } else { - resp.setSyncing(true); - resp.setSyncTargetMsgCount(getLong(node, "syncTargetMsgCount")); - resp.setFeedPendingMessageCount(getLong(node, "feedPendingMessageCount")); - resp.setMsgCount(getLong(node, "msgCount")); - } - return resp; - } -} diff --git a/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJsonSerializer.java b/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJsonSerializer.java deleted file mode 100644 index be63c51c4..000000000 --- a/src/main/java/io/emeraldpay/dshackle/upstream/arbitrum/json/NitroSyncingJsonSerializer.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.emeraldpay.dshackle.upstream.arbitrum.json; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import io.emeraldpay.dshackle.upstream.ethereum.json.EtherJsonSerializer; - -import java.io.IOException; - -public class NitroSyncingJsonSerializer extends EtherJsonSerializer { - - @Override - public void serialize(NitroSyncingJson value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - if (value == null) { - gen.writeNull(); - } else if (value.isSyncing()) { - gen.writeStartObject(); - writeField(gen, "syncTargetMsgCount", value.getSyncTargetMsgCount()); - writeField(gen, "feedPendingMessageCount", value.getFeedPendingMessageCount()); - writeField(gen, "msgCount", value.getMsgCount()); - gen.writeEndObject(); - } else { - gen.writeBoolean(false); - } - } -} diff --git a/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJson.java b/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJson.java deleted file mode 100644 index ed6b3ffaa..000000000 --- a/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJson.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.emeraldpay.dshackle.upstream.ethereum.json; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonDeserialize(using = SyncingJsonDeserializer.class) -@JsonSerialize(using = SyncingJsonSerializer.class) -public class SyncingJson { - - private boolean syncing; - - private Long startingBlock; - private Long currentBlock; - private Long highestBlock; - - public boolean isSyncing() { - return syncing; - } - - public void setSyncing(boolean syncing) { - this.syncing = syncing; - } - - public Long getStartingBlock() { - return startingBlock; - } - - public void setStartingBlock(Long startingBlock) { - this.startingBlock = startingBlock; - } - - public Long getCurrentBlock() { - return currentBlock; - } - - public void setCurrentBlock(Long currentBlock) { - this.currentBlock = currentBlock; - } - - public Long getHighestBlock() { - return highestBlock; - } - - public void setHighestBlock(Long highestBlock) { - this.highestBlock = highestBlock; - } -} diff --git a/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJsonDeserializer.java b/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJsonDeserializer.java deleted file mode 100644 index f146f7808..000000000 --- a/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJsonDeserializer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.emeraldpay.dshackle.upstream.ethereum.json; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; - -import java.io.IOException; - -public class SyncingJsonDeserializer extends EtherJsonDeserializer { - - @Override - public SyncingJson deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - JsonNode node = jp.readValueAsTree(); - SyncingJson resp = new SyncingJson(); - if (node.isBoolean()) { - resp.setSyncing(node.asBoolean()); - } else { - resp.setSyncing(true); - resp.setStartingBlock(getLong(node, "startingBlock")); - resp.setCurrentBlock(getLong(node, "currentBlock")); - resp.setHighestBlock(getLong(node, "highestBlock")); - } - return resp; - } -} diff --git a/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJsonSerializer.java b/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJsonSerializer.java deleted file mode 100644 index 09e3d7d63..000000000 --- a/src/main/java/io/emeraldpay/dshackle/upstream/ethereum/json/SyncingJsonSerializer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.emeraldpay.dshackle.upstream.ethereum.json; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; - -import java.io.IOException; - -public class SyncingJsonSerializer extends EtherJsonSerializer { - - @Override - public void serialize(SyncingJson value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - if (value == null) { - gen.writeNull(); - } else if (value.isSyncing()) { - gen.writeStartObject(); - writeField(gen, "startingBlock", value.getStartingBlock()); - writeField(gen, "currentBlock", value.getCurrentBlock()); - writeField(gen, "highestBlock", value.getHighestBlock()); - gen.writeEndObject(); - } else { - gen.writeBoolean(false); - } - } -} diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt index 956fd5dd2..204c35565 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt @@ -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 @@ -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 } } }