Lower data timestamp (#404)

This commit is contained in:
KirillPamPam
2024-01-22 16:23:00 +04:00
committed by GitHub
parent 3dd871ddc4
commit 55137a689b
4 changed files with 9 additions and 3 deletions

View File

@@ -57,6 +57,7 @@ class StreamHead(
.setSlot(block.slot)
.setCurrentLowerBlock(ms.getLowerBlock().blockNumber)
.setCurrentLowerSlot(ms.getLowerBlock().slot ?: 0)
.setCurrentLowerDataTimestamp(ms.getLowerBlock().timestamp)
.setTimestamp(block.timestamp.toEpochMilli())
.setWeight(ByteString.copyFrom(block.difficulty.toByteArray()))
.setBlockId(block.hash.toHex())

View File

@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import java.time.Duration
import java.time.Instant
import java.util.concurrent.atomic.AtomicReference
typealias LowerBoundBlockDetectorBuilder = (Chain, Upstream) -> LowerBoundBlockDetector
@@ -41,11 +42,14 @@ abstract class LowerBoundBlockDetector(
data class LowerBlockData(
val blockNumber: Long,
val slot: Long?,
val timestamp: Long,
) : Comparable<LowerBlockData> {
constructor(blockNumber: Long) : this(blockNumber, null)
constructor(blockNumber: Long) : this(blockNumber, null, Instant.now().epochSecond)
constructor(blockNumber: Long, slot: Long) : this(blockNumber, slot, Instant.now().epochSecond)
companion object {
fun default() = LowerBlockData(0, 0)
fun default() = LowerBlockData(0, 0, 0)
}
override fun compareTo(other: LowerBlockData): Int {

View File

@@ -33,6 +33,7 @@ class EthereumLowerBoundBlockDetector(
"header for hash not found",
"after last accepted block",
"Version has either been pruned, or is for a future block", // cronos
"no historical RPC is available for this historical", // optimism
)
}