NEAR has same pruning algo for state and block (#464)

This commit is contained in:
Vyacheslav
2024-06-10 16:29:10 +03:00
committed by GitHub
parent 73e5030980
commit 95ab1da8a5

View File

@@ -8,7 +8,6 @@ import io.emeraldpay.dshackle.upstream.lowerbound.LowerBoundDetector
import io.emeraldpay.dshackle.upstream.lowerbound.LowerBoundType
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
import reactor.core.publisher.Flux
import reactor.kotlin.core.publisher.toFlux
class NearLowerBoundStateDetector(
private val upstream: Upstream,
@@ -21,8 +20,15 @@ class NearLowerBoundStateDetector(
override fun internalDetectLowerBound(): Flux<LowerBoundData> {
return upstream.getIngressReader().read(ChainRequest("status", ListParams())).map {
val resp = Global.objectMapper.readValue(it.getResult(), NearStatus::class.java)
LowerBoundData(resp.syncInfo.earliestHeight, LowerBoundType.STATE)
}.toFlux()
resp.syncInfo.earliestHeight
}.flatMapMany {
Flux.fromIterable(
listOf(
LowerBoundData(it, LowerBoundType.STATE),
LowerBoundData(it, LowerBoundType.BLOCK),
),
)
}
}
override fun types(): Set<LowerBoundType> {