Skip to content

Commit

Permalink
use vertx periodic await
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jul 7, 2023
1 parent a8083fb commit 1f1d1ed
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.tuweni.discovery

import io.vertx.core.Vertx
import kotlinx.coroutines.runBlocking
import io.vertx.kotlin.coroutines.setPeriodicAwait
import org.apache.tuweni.devp2p.EthereumNodeRecord
import org.slf4j.LoggerFactory

Expand Down Expand Up @@ -60,7 +60,7 @@ class DNSDaemon @JvmOverloads constructor(
fun start() {
logger.trace("Starting DNSDaemon for $enrLink")
val task = DNSTimerTask(vertx, seq, enrLink, this::updateRecords)
this.periodicHandle = vertx.setPeriodic(period, task::run)
vertx.setPeriodicAwait(period, task::run)
}

/**
Expand All @@ -84,10 +84,8 @@ internal class DNSTimerTask(
val logger = LoggerFactory.getLogger(DNSTimerTask::class.java)
}

fun run(@Suppress("UNUSED_PARAMETER") timerId: Long) {
suspend fun run(@Suppress("UNUSED_PARAMETER") timerId: Long) {
logger.debug("Refreshing DNS records with $enrLink")
runBlocking {
records(dnsResolver.collectAll(enrLink))
}
records(dnsResolver.collectAll(enrLink))
}
}

0 comments on commit 1f1d1ed

Please sign in to comment.