problem: gives duplicate blocks if came simultaneously from different upstreams

This commit is contained in:
Igor Artamonov
2019-08-11 13:13:09 -04:00
parent 07bca4fa22
commit 29cea2575e
3 changed files with 5 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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