diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumHeadMerge.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumHeadMerge.kt index 02fa029a..c227ce4e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumHeadMerge.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumHeadMerge.kt @@ -21,6 +21,9 @@ class EthereumHeadMerge( init { val fluxes = upstreams.map { it.getFlux() } flux = Flux.merge(fluxes) + .distinctUntilChanged { + it.hash + } .filter { val curr = head.get() curr == null || curr.totalDifficulty < it.totalDifficulty diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumRpcHead.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumRpcHead.kt index ace32ec4..ac67cf47 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumRpcHead.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/EthereumRpcHead.kt @@ -37,6 +37,7 @@ class EthereumRpcHead( .onErrorContinue { err, _ -> log.warn("RPC error ${err.message}") } + .distinctUntilChanged { it.hash } .filter { block -> val curr = head.get() curr == null || curr.totalDifficulty < block.totalDifficulty diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/GrpcUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/GrpcUpstream.kt index d84906b3..d406bb2f 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/GrpcUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/GrpcUpstream.kt @@ -75,6 +75,7 @@ open class GrpcUpstream( block.hash = BlockHash.from("0x"+value.blockId) block } + .distinctUntilChanged { it.hash } .filter { block -> val curr = headBlock.get() curr == null || curr.totalDifficulty < block.totalDifficulty