Skip to content

Commit 4f71682

Browse files
committed
fix: only republish if derp url changes
1 parent b2b773d commit 4f71682

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-dns/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ hickory-proto = { version = "0.24.0", features = ["dnssec", "ring"] }
2222
hickory-resolver = { version = "0.24.0", features = ["dns-over-https", "dns-over-tls", "tokio-rustls", "webpki-roots", "dns-over-rustls", "dns-over-https-rustls"] }
2323
iroh-base = { version = "0.12.0", path = "../iroh-base", default_features = false, features = ["base32"] }
2424
iroh-net = { version = "0.12.0", path = "../iroh-net", default_features = false }
25+
parking_lot = "0.12.1"
2526
pkarr = { version = "1.1.1", features = ["async", "relay"], default_features = false }
2627
reqwest = { version = "0.11.24", features = ["rustls"] }
2728
ring = "0.16"

iroh-dns/src/publish.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anyhow::Result;
22
use ed25519_dalek::SigningKey;
33
use iroh_net::{key::SecretKey, AddrInfo, NodeId};
4+
use parking_lot::RwLock;
45
use pkarr::PkarrClient;
56
use url::Url;
67

@@ -41,6 +42,7 @@ pub struct Publisher {
4142
signing_key: SigningKey,
4243
pkarr_relay: Url,
4344
pkarr_client: PkarrClient,
45+
last_announce: RwLock<Option<NodeAnnounce>>
4446
}
4547

4648
impl Publisher {
@@ -53,6 +55,7 @@ impl Publisher {
5355
signing_key,
5456
pkarr_relay: config.pkarr_relay,
5557
pkarr_client,
58+
last_announce: Default::default()
5659
}
5760
}
5861

@@ -62,6 +65,10 @@ impl Publisher {
6265
info.derp_url.as_ref().map(|u| u.clone().into()),
6366
Default::default(),
6467
);
68+
if self.last_announce.read().as_ref() == Some(&an) {
69+
return Ok(());
70+
}
71+
let _ = self.last_announce.write().insert(an.clone());
6572
let signed_packet = an.into_pkarr_signed_packet(&self.signing_key)?;
6673
self.pkarr_client
6774
.relay_put(&self.pkarr_relay, &signed_packet)

0 commit comments

Comments
 (0)