|
5 | 5 | use std::borrow::Cow;
|
6 | 6 | use std::cmp;
|
7 | 7 | use std::collections::{HashMap, HashSet};
|
8 |
| -#[cfg(feature = "nip11")] |
9 |
| -use std::sync::atomic::AtomicU64; |
10 | 8 | use std::sync::atomic::{AtomicBool, Ordering};
|
11 | 9 | use std::sync::Arc;
|
12 | 10 | use std::time::Duration;
|
@@ -135,10 +133,6 @@ impl Default for SubscriptionData {
|
135 | 133 | #[derive(Debug)]
|
136 | 134 | pub(super) struct AtomicPrivateData {
|
137 | 135 | status: AtomicRelayStatus,
|
138 |
| - #[cfg(feature = "nip11")] |
139 |
| - pub(super) document: RwLock<RelayInformationDocument>, |
140 |
| - #[cfg(feature = "nip11")] |
141 |
| - last_document_fetch: AtomicU64, |
142 | 136 | channels: RelayChannels,
|
143 | 137 | subscriptions: RwLock<HashMap<SubscriptionId, SubscriptionData>>,
|
144 | 138 | running: AtomicBool,
|
@@ -171,10 +165,6 @@ impl InnerRelay {
|
171 | 165 | url,
|
172 | 166 | atomic: Arc::new(AtomicPrivateData {
|
173 | 167 | status: AtomicRelayStatus::default(),
|
174 |
| - #[cfg(feature = "nip11")] |
175 |
| - document: RwLock::new(RelayInformationDocument::new()), |
176 |
| - #[cfg(feature = "nip11")] |
177 |
| - last_document_fetch: AtomicU64::new(0), |
178 | 168 | channels: RelayChannels::new(),
|
179 | 169 | subscriptions: RwLock::new(HashMap::new()),
|
180 | 170 | running: AtomicBool::new(false),
|
@@ -289,50 +279,6 @@ impl InnerRelay {
|
289 | 279 | Ok(())
|
290 | 280 | }
|
291 | 281 |
|
292 |
| - #[cfg(feature = "nip11")] |
293 |
| - fn request_nip11_document(&self) { |
294 |
| - #[cfg_attr(target_arch = "wasm32", allow(unused_mut))] |
295 |
| - let mut opts: Nip11GetOptions = |
296 |
| - Nip11GetOptions::default().timeout(DEFAULT_CONNECTION_TIMEOUT); |
297 |
| - |
298 |
| - let allowed: bool = match self.opts.connection_mode { |
299 |
| - ConnectionMode::Direct => true, |
300 |
| - #[cfg(not(target_arch = "wasm32"))] |
301 |
| - ConnectionMode::Proxy(proxy) => { |
302 |
| - // Update proxy |
303 |
| - opts.proxy = Some(proxy); |
304 |
| - true |
305 |
| - } |
306 |
| - #[cfg(all(feature = "tor", not(target_arch = "wasm32")))] |
307 |
| - ConnectionMode::Tor { .. } => false, |
308 |
| - }; |
309 |
| - |
310 |
| - if allowed { |
311 |
| - let now: u64 = Timestamp::now().as_u64(); |
312 |
| - |
313 |
| - // Check last fetch |
314 |
| - if self.atomic.last_document_fetch.load(Ordering::SeqCst) + 3600 < now { |
315 |
| - // Update last fetch |
316 |
| - self.atomic.last_document_fetch.store(now, Ordering::SeqCst); |
317 |
| - |
318 |
| - // Fetch |
319 |
| - let url = self.url.clone(); |
320 |
| - let atomic = self.atomic.clone(); |
321 |
| - task::spawn(async move { |
322 |
| - match RelayInformationDocument::get(url.clone().into(), opts).await { |
323 |
| - Ok(document) => { |
324 |
| - let mut d = atomic.document.write().await; |
325 |
| - *d = document |
326 |
| - } |
327 |
| - Err(e) => { |
328 |
| - tracing::warn!(url = %url, error = %e, "Can't get information document.") |
329 |
| - } |
330 |
| - }; |
331 |
| - }); |
332 |
| - } |
333 |
| - } |
334 |
| - } |
335 |
| - |
336 | 282 | pub async fn subscriptions(&self) -> HashMap<SubscriptionId, Filter> {
|
337 | 283 | let subscription = self.atomic.subscriptions.read().await;
|
338 | 284 | subscription
|
@@ -757,10 +703,6 @@ impl InnerRelay {
|
757 | 703 | ws_rx: BoxStream,
|
758 | 704 | rx_nostr: &mut MutexGuard<'_, Receiver<Vec<ClientMessageJson>>>,
|
759 | 705 | ) {
|
760 |
| - // Request information document |
761 |
| - #[cfg(feature = "nip11")] |
762 |
| - self.request_nip11_document(); |
763 |
| - |
764 | 706 | // (Re)subscribe to relay
|
765 | 707 | if self.flags.can_read() {
|
766 | 708 | if let Err(e) = self.resubscribe().await {
|
|
0 commit comments