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

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


The following commit(s) were added to refs/heads/main by this push:
     new 7ce3f04  Revert passing coroutine context
7ce3f04 is described below

commit 7ce3f0467aef180af70de39edbe8f05e5584ee15
Author: Antoine Toulme <[email protected]>
AuthorDate: Tue Jun 29 23:06:44 2021 +0200

    Revert passing coroutine context
---
 .../main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt  |  3 +--
 .../apache/tuweni/eth/crawler/RelationalPeerRepository.kt    | 12 ++++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt 
b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt
index 6a4b1d0..fa1e9e0 100644
--- a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt
+++ b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/CrawlerApp.kt
@@ -101,7 +101,7 @@ class CrawlerApplication(
       .load()
     flyway.migrate()
 
-    val repo = RelationalPeerRepository(ds, config.peerCacheExpiration(), 
config.clientIdsInterval(), coroutineContext)
+    val repo = RelationalPeerRepository(ds, config.peerCacheExpiration(), 
config.clientIdsInterval())
 
     logger.info("Initial bootnodes: ${config.bootNodes()}")
     val scraper = Scraper(
@@ -109,7 +109,6 @@ class CrawlerApplication(
       initialURIs = config.bootNodes(),
       bindAddress = SocketAddress.inetSocketAddress(config.discoveryPort(), 
config.discoveryNetworkInterface()),
       repository = repo,
-      coroutineContext = coroutineContext,
     )
 
     val dnsDaemon = DNSDaemon(
diff --git 
a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
 
b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
index 03c4dc2..eecf7ab 100644
--- 
a/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
+++ 
b/eth-crawler/src/main/kotlin/org/apache/tuweni/eth/crawler/RelationalPeerRepository.kt
@@ -226,10 +226,13 @@ open class RelationalPeerRepository(
   private val started = AtomicBoolean(false)
 
   fun start() {
+    logger.info("Starting repo")
     launch {
       started.set(true)
       while (started.get()) {
+        logger.info("Finding client ids")
         val newClientIds = getClientIdsInternal()
+        logger.info("Found client ids ${newClientIds.size}")
         clientIds = newClientIds
         var londonReady = 0
         var total = 0
@@ -258,12 +261,13 @@ open class RelationalPeerRepository(
 
   internal fun getClientIdsInternal(): List<ClientInfo> {
     dataSource.connection.use { conn ->
+      val sql = "select clients.clientId, count(clients.clientId) from (select 
nodeinfo.clientId, nodeInfo.createdAt from nodeinfo inner join (select 
identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) 
maxSeen on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = 
maxSeen.maxCreatedAt) as clients where clients.createdAt > ? group by 
clients.clientId"
       val stmt =
-        conn.prepareStatement(
-          "select clients.clientId, count(clients.clientId) from (select 
nodeinfo.clientId, nodeInfo.createdAt from nodeinfo inner join (select 
identity, max(createdAt) as maxCreatedAt from nodeinfo group by identity) 
maxSeen on nodeinfo.identity = maxSeen.identity and nodeinfo.createdAt = 
maxSeen.maxCreatedAt) as clients where clients.createdAt > ? group by 
clients.clientId"
-        )
+        conn.prepareStatement(sql)
       stmt.use {
-        it.setTimestamp(1, Timestamp(System.currentTimeMillis() - 
clientIdsInterval))
+        val time = System.currentTimeMillis() - clientIdsInterval
+        logger.info("Logging client ids query: $sql with $time")
+        it.setTimestamp(1, Timestamp(time))
         // map results.
         val rs = stmt.executeQuery()
         val result = mutableListOf<ClientInfo>()

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to