From 812f735110001c1cdf3ca9082fa797b57b190fd6 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Fri, 13 Dec 2024 11:41:54 -0600 Subject: [PATCH] =?UTF-8?q?node:=20Update=20DNS=20seeds,=20optimize=20`Pee?= =?UTF-8?q?rFinder.start()`=20to=20start=20querying=E2=80=A6=20(#5807)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * node: Update DNS seeds, optimize PeerFinder.start() to start querying dns seeds as early as possible * Add new seeds, disable bad seeds * scalafmt --- .../core/config/NetworkParameters.scala | 18 +++++++++++------- .../scala/org/bitcoins/node/PeerFinder.scala | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/src/main/scala/org/bitcoins/core/config/NetworkParameters.scala b/core/src/main/scala/org/bitcoins/core/config/NetworkParameters.scala index 2f6d023136..1de305d09e 100644 --- a/core/src/main/scala/org/bitcoins/core/config/NetworkParameters.scala +++ b/core/src/main/scala/org/bitcoins/core/config/NetworkParameters.scala @@ -72,13 +72,14 @@ sealed abstract class MainNet extends BitcoinNetwork { Vector( // "seed.bitcoin.sipa.be", very slow, commenting out for now "dnsseed.bluematt.me", - "dnsseed.bitcoin.dashjr.org", + "dnsseed.bitcoin.dashjr-list-of-p2p-nodes.us", "seed.bitcoinstats.com", // "seed.btc.petertodd.net", very slow, commenting out for now - "seed.bitcoin.jonasschnelli.ch", + // "seed.bitcoin.jonasschnelli.ch", seems to be down? "seed.bitcoin.sprovoost.nl", "dnsseed.emzy.de", - "seed.bitcoin.wiz.biz" + "seed.bitcoin.wiz.biz", + "seed.mainnet.achownodes.xyz" ) } @@ -104,10 +105,13 @@ sealed abstract class TestNet3 extends BitcoinNetwork { /** @inheritdoc */ override def dnsSeeds: Seq[String] = - Seq("testnet-seed.bitcoin.jonasschnelli.ch", - "seed.tbtc.petertodd.org", - "seed.testnet.bitcoin.sprovoost.nl", - "testnet-seed.bluematt.me") + Seq( + "testnet-seed.bitcoin.jonasschnelli.ch", + "seed.tbtc.petertodd.org", + "seed.testnet.bitcoin.sprovoost.nl", + "testnet-seed.bluematt.me", + "seed.testnet.achownodes.xyz" + ) /* * @inheritdoc */ diff --git a/node/src/main/scala/org/bitcoins/node/PeerFinder.scala b/node/src/main/scala/org/bitcoins/node/PeerFinder.scala index 9d0a6e7e58..a4c2ea1a70 100644 --- a/node/src/main/scala/org/bitcoins/node/PeerFinder.scala +++ b/node/src/main/scala/org/bitcoins/node/PeerFinder.scala @@ -45,7 +45,7 @@ case class PeerFinder( /** Returns peers by querying each dns seed once. These will be IPv4 * addresses. */ - private def getPeersFromDnsSeeds: Future[Vector[Peer]] = { + private lazy val getPeersFromDnsSeeds: Future[Vector[Peer]] = { val dnsSeeds = nodeAppConfig.network.dnsSeeds val addressesF: Future[Vector[String]] = Future .traverse(dnsSeeds) { seed => @@ -163,12 +163,12 @@ case class PeerFinder( _peersToTry.pushAll(pds, priority = 2) val peerDiscoveryF = if (nodeAppConfig.enablePeerDiscovery) { + val dnsF = getPeersFromDnsSeeds val startedF = for { (dbNonCfPeerDb, dbCfPeerDb) <- getPeersFromDb dbNonCf = dbNonCfPeerDb.map(_.peer(nodeAppConfig.socks5ProxyParams)) dbCf = dbCfPeerDb.map(_.peer(nodeAppConfig.socks5ProxyParams)) - peersDbs <- getPeersFromDnsSeeds.map(dns => - dns ++ getPeersFromResources ++ dbNonCf) + peersDbs <- dnsF.map(dns => dns ++ getPeersFromResources ++ dbNonCf) } yield { val pds = peersDbs.map(p => buildPeerData(p, isPersistent = false)) _peersToTry.pushAll(pds)