Skip to content

Commit

Permalink
always set onsyncingmode (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
a10zn8 authored Aug 21, 2024
1 parent 0e8eca5 commit 3d9193e
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,29 @@ object EthereumChainSpecific : AbstractPollChainSpecific() {
) { data ->
val raw = Global.objectMapper.readTree(data)
if (raw.isBoolean) {
upstream.getHead().onSyncingNode(raw.asBoolean())
if (raw.asBoolean()) {
UpstreamAvailability.SYNCING
} else {
UpstreamAvailability.OK
}
} 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 {
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.error("Received unknown syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}")
UpstreamAvailability.OK
}
} else {
log.error("Received unknown syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}")
UpstreamAvailability.OK
}.also {
upstream.getHead().onSyncingNode(it == UpstreamAvailability.SYNCING)
}
}
}
Expand Down

0 comments on commit 3d9193e

Please sign in to comment.