You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2020/06/09 07:51:52 UTC

[incubator-tuweni] 01/04: Make DNSDaemon easier to work with

This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git

commit 44e40122880b6cd299b079b82993118488c87793
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Tue Jun 9 00:49:24 2020 -0700

    Make DNSDaemon easier to work with
---
 .../main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt  | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt b/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt
index afead4d..d915c83 100644
--- a/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt
+++ b/dns-discovery/src/main/kotlin/org/apache/tuweni/discovery/DNSDaemon.kt
@@ -26,27 +26,22 @@ import java.util.concurrent.atomic.AtomicReference
 /**
  * Resolves DNS records over time, refreshing records.
  *
+ * @param enrLink the ENR link to start with, of the form enrtree://PUBKEY@domain
+ * @param listeners  Listeners notified when records are read and whenever they are updated.
  * @param dnsServer the DNS server to use for DNS query. If null, the default DNS server will be used.
  * @param seq the sequence number of the root record. If the root record seq is higher, proceed with visit.
- * @param enrLink the ENR link to start with, of the form enrtree://PUBKEY@domain
  * @param period the period at which to poll DNS records
  * @param resolver
  */
 public class DNSDaemon @JvmOverloads constructor(
-  private val dnsServer: String? = null,
-  private val seq: Long = 0,
   private val enrLink: String,
+  val listeners : Set<(List<EthereumNodeRecord>) -> Unit> = HashSet(),
+  private val seq: Long = 0,
   private val period: Long = 60000L,
+  private val dnsServer: String? = null,
   private val resolver: Resolver = SimpleResolver(dnsServer)
 ) {
-
-  /**
-   * Listeners notified when records are read and whenever they are updated.
-   */
-  val listeners = HashSet<(List<EthereumNodeRecord>) -> Unit>()
-
   private val timer: Timer = Timer(false)
-  private val records = AtomicReference<EthereumNodeRecord>()
 
   init {
     timer.scheduleAtFixedRate(DNSTimerTask(resolver, seq, enrLink, this::updateRecords), 0, period)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org