diff --git a/Cargo.lock b/Cargo.lock index 812931e..4d35fe4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1990,9 +1990,9 @@ dependencies = [ [[package]] name = "pkarr-relay" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aaf659e9dee61ed790ce8d5e43f439e7444904772365bd975f44005c4a164b0" +checksum = "562497bdc2c273da1cbedd536b4ab6b8127db744d8423ce46bc0c63f06d75239" dependencies = [ "anyhow", "axum", diff --git a/pubky-testnet/Cargo.toml b/pubky-testnet/Cargo.toml index d53e486..129d766 100644 --- a/pubky-testnet/Cargo.toml +++ b/pubky-testnet/Cargo.toml @@ -14,7 +14,7 @@ categories = ["web-programming", "authentication", "cryptography"] anyhow = "1.0.95" http-relay = "0.1.0" mainline = "5.2.0" -pkarr-relay = "0.2.0" +pkarr-relay = "0.3.0" pubky = { version = "0.3.0", path = "../pubky" } pubky-common = "0.2.0" pubky-homeserver = { version = "0.1.0", path = "../pubky-homeserver" } diff --git a/pubky-testnet/src/lib.rs b/pubky-testnet/src/lib.rs index d5bf324..c121c28 100644 --- a/pubky-testnet/src/lib.rs +++ b/pubky-testnet/src/lib.rs @@ -39,29 +39,26 @@ impl Testnet { let storage = std::env::temp_dir().join(Timestamp::now().to_string()); - // TODO: add a builder for pkarr relay for consistency? - let relay = { - let mut config = pkarr_relay::Config { - http_port: 15411, - cache_path: Some(storage.join("pkarr-relay")), - rate_limiter: None, - ..Default::default() - }; + let mut builder = pkarr_relay::Relay::builder(); + builder + .http_port(15411) + .storage(storage.clone()) + .disable_rate_limiter() + .pkarr(|pkarr| { + pkarr + .request_timeout(Duration::from_millis(100)) + .bootstrap(&dht.bootstrap) + .dht(|builder| { + if !dht.bootstrap.first().unwrap().contains("6881") { + builder.server_mode().port(6881); + } - config - .pkarr - .request_timeout(Duration::from_millis(100)) - .bootstrap(&dht.bootstrap) - .dht(|builder| { - if !dht.bootstrap.first().unwrap().contains("6881") { - builder.server_mode().port(6881); - } - - builder - }); - - unsafe { pkarr_relay::Relay::run(config).await? } - }; + builder + .bootstrap(&dht.bootstrap) + .request_timeout(Duration::from_millis(200)) + }) + }); + let relay = unsafe { builder.run() }.await?; let mut builder = Homeserver::builder(); builder