Skip to content

Commit

Permalink
support erigon3 syncing validation
Browse files Browse the repository at this point in the history
  • Loading branch information
a10zn8 committed Aug 1, 2024
1 parent 6b249a3 commit 4f8c7af
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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
}
} 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
}
}
}
Expand Down

0 comments on commit 4f8c7af

Please sign in to comment.