diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/lowerbound/LowerBounds.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/lowerbound/LowerBounds.kt index cfcb078f..839eff3f 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/lowerbound/LowerBounds.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/lowerbound/LowerBounds.kt @@ -4,12 +4,13 @@ import com.google.common.util.concurrent.AtomicDouble import io.emeraldpay.dshackle.Chain import org.apache.commons.math3.stat.regression.SimpleRegression import java.time.Instant +import java.time.temporal.ChronoUnit import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentLinkedDeque import kotlin.math.roundToLong class LowerBounds( - chain: Chain, + val chain: Chain, ) { companion object { private const val MAX_BOUNDS = 3 @@ -67,9 +68,15 @@ class LowerBounds( } fun predictNextBound(type: LowerBoundType): Long { + val offset = if (chain == Chain.BSC__MAINNET && type == LowerBoundType.STATE) { + 30 + } else { + 0 + }.toLong() + val lowerBoundCoeffs = lowerBounds[type] ?: return 0 - val xTime = Instant.now().epochSecond + val xTime = Instant.now().plus(offset, ChronoUnit.SECONDS).epochSecond return (lowerBoundCoeffs.k.get() * xTime + lowerBoundCoeffs.b.get()).roundToLong() }