Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Кирилл committed Aug 15, 2024
1 parent 7f2f2d7 commit c01cb0f
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ import io.emeraldpay.dshackle.upstream.lowerbound.LowerBoundData
import io.emeraldpay.dshackle.upstream.lowerbound.LowerBoundServiceBuilder
import io.emeraldpay.dshackle.upstream.lowerbound.LowerBoundType
import org.springframework.context.Lifecycle
import org.springframework.scheduling.concurrent.CustomizableThreadFactory
import reactor.core.Disposable
import reactor.core.publisher.Flux
import reactor.core.publisher.Sinks
import reactor.core.scheduler.Schedulers
import java.time.Duration
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import java.util.function.Supplier
Expand Down Expand Up @@ -331,9 +334,11 @@ open class GenericUpstream(

private fun detectFinalization() {
finalizationDetectorSubscription =
finalizationDetector.detectFinalization(this, chainConfig.expectedBlockTime, getChain()).subscribe {
sendUpstreamStateEvent(UPDATED)
}
finalizationDetector.detectFinalization(this, chainConfig.expectedBlockTime, getChain())
.subscribeOn(finalizationScheduler)
.subscribe {
sendUpstreamStateEvent(UPDATED)
}
}

private fun detectLowerBlock() {
Expand All @@ -355,4 +360,9 @@ open class GenericUpstream(
}

fun isValid(): Boolean = isUpstreamValid.get()

companion object {
private val finalizationScheduler =
Schedulers.fromExecutor(Executors.newFixedThreadPool(4, CustomizableThreadFactory("finalization")))
}
}

0 comments on commit c01cb0f

Please sign in to comment.