From d371e0c47510ac82b963024cd111cd72ca09122d Mon Sep 17 00:00:00 2001 From: Termina1 Date: Fri, 2 Dec 2022 20:10:22 +0200 Subject: [PATCH] better logs for heads --- .../io/emeraldpay/dshackle/upstream/AbstractHead.kt | 11 ++++++----- .../dshackle/upstream/ethereum/DefaultEthereumHead.kt | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/AbstractHead.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/AbstractHead.kt index 77318863..0c90ff18 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/AbstractHead.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/AbstractHead.kt @@ -30,10 +30,11 @@ import java.util.concurrent.Executors import java.util.concurrent.TimeUnit import java.util.concurrent.locks.ReentrantLock -abstract class AbstractHead( +abstract class AbstractHead @JvmOverloads constructor( private val forkChoice: ForkChoice, private val blockValidator: BlockValidator = BlockValidator.ALWAYS_VALID, - awaitHeadTimeoutMs: Long = 60_000 + awaitHeadTimeoutMs: Long = 60_000, + private val upstreamId: String = "" ) : Head { companion object { @@ -103,9 +104,9 @@ abstract class AbstractHead( val newHead = choiceResult.nwhead lastHeadUpdated = System.currentTimeMillis() when (val result = stream.tryEmitNext(newHead)) { - OK -> log.debug("New block ${newHead.height} ${newHead.hash} @ ${this.javaClass}") - FAIL_ZERO_SUBSCRIBER -> log.debug("No subscribers for ${this.javaClass}") - else -> log.warn("Failed to dispatch block: $result as ${this.javaClass}") + OK -> log.debug("New block $upstreamId ${newHead.height} ${newHead.hash} @ ${this.javaClass}") + FAIL_ZERO_SUBSCRIBER -> log.debug("No subscribers $upstreamId ${this.javaClass}") + else -> log.warn("Failed to dispatch block $upstreamId: $result as ${this.javaClass}") } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHead.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHead.kt index 66b2f129..c2a41119 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHead.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/DefaultEthereumHead.kt @@ -32,7 +32,7 @@ open class DefaultEthereumHead( private val upstreamId: String, forkChoice: ForkChoice, blockValidator: BlockValidator -) : Head, AbstractHead(forkChoice, blockValidator) { +) : Head, AbstractHead(forkChoice, blockValidator,60_000, upstreamId) { companion object { private val log = LoggerFactory.getLogger(DefaultEthereumHead::class.java)