better logs for heads

This commit is contained in:
Termina1
2022-12-02 20:10:22 +02:00
parent e29dbccbe3
commit d371e0c475
2 changed files with 7 additions and 6 deletions

View File

@@ -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}")
}
}

View File

@@ -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)