Skip to content

Commit

Permalink
Lower data timestamp (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillPamPam authored Jan 22, 2024
1 parent 3dd871d commit 55137a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion emerald-grpc
1 change: 1 addition & 0 deletions src/main/kotlin/io/emeraldpay/dshackle/rpc/StreamHead.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down

0 comments on commit 55137a6

Please sign in to comment.