diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 94ae21bd0e2..5046dca3a85 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -82,7 +82,7 @@ use crate::util::logger::{Level, Logger, WithContext}; use crate::util::errors::APIError; #[cfg(feature = "dnssec")] -use crate::onion_message::dns_resolution::{DNSResolverMessage, OMNameResolver}; +use crate::onion_message::dns_resolution::OMNameResolver; #[cfg(not(c_bindings))] use { @@ -107,7 +107,7 @@ use core::{cmp, mem}; use core::borrow::Borrow; use core::cell::RefCell; use crate::io::Read; -use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, MutexGuard, RwLock, RwLockReadGuard}; +use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, RwLock, RwLockReadGuard}; use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering}; use core::time::Duration; use core::ops::Deref; @@ -2380,8 +2380,6 @@ where #[cfg(feature = "dnssec")] hrn_resolver: OMNameResolver, - #[cfg(feature = "dnssec")] - pending_dns_onion_messages: Mutex>, #[cfg(test)] pub(super) entropy_source: ES, @@ -3233,8 +3231,6 @@ where #[cfg(feature = "dnssec")] hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height), - #[cfg(feature = "dnssec")] - pending_dns_onion_messages: Mutex::new(Vec::new()), } } @@ -9465,10 +9461,6 @@ impl Default for Bolt11InvoiceParameters { /// /// [`OffersMessageFlow`]: crate::offers::flow::OffersMessageFlow pub trait OffersMessageCommons { - #[cfg(feature = "dnssec")] - /// Get pending DNS onion messages - fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>; - #[cfg(feature = "dnssec")] /// Get hrn resolver fn get_hrn_resolver(&self) -> &OMNameResolver; @@ -9601,11 +9593,6 @@ where MR::Target: MessageRouter, L::Target: Logger, { - #[cfg(feature = "dnssec")] - fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> { - self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.") - } - #[cfg(feature = "dnssec")] fn get_hrn_resolver(&self) -> &OMNameResolver { &self.hrn_resolver @@ -13122,8 +13109,6 @@ where #[cfg(feature = "dnssec")] hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height), - #[cfg(feature = "dnssec")] - pending_dns_onion_messages: Mutex::new(Vec::new()), }; for (_, monitor) in args.channel_monitors.iter() { diff --git a/lightning/src/offers/flow.rs b/lightning/src/offers/flow.rs index cc73d684202..bd6b94f1439 100644 --- a/lightning/src/offers/flow.rs +++ b/lightning/src/offers/flow.rs @@ -421,6 +421,9 @@ where #[cfg(any(test, feature = "_test_utils"))] pub(crate) pending_offers_messages: Mutex>, + #[cfg(feature = "dnssec")] + pending_dns_onion_messages: Mutex>, + #[cfg(feature = "_test_utils")] /// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an /// offer generated in the test. @@ -455,6 +458,10 @@ where message_router, pending_offers_messages: Mutex::new(Vec::new()), + + #[cfg(feature = "dnssec")] + pending_dns_onion_messages: Mutex::new(Vec::new()), + #[cfg(feature = "_test_utils")] testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()), logger, @@ -1369,7 +1376,7 @@ where .flat_map(|destination| reply_paths.iter().map(move |path| (path, destination))) .take(OFFERS_MESSAGE_REQUEST_LIMIT); for (reply_path, destination) in message_params { - self.commons.get_pending_dns_onion_messages().push(( + self.pending_dns_onion_messages.lock().unwrap().push(( DNSResolverMessage::DNSSECQuery(onion_message.clone()), MessageSendInstructions::WithSpecifiedReplyPath { destination: destination.clone(), @@ -1449,6 +1456,6 @@ where } fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> { - core::mem::take(&mut self.commons.get_pending_dns_onion_messages()) + core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap()) } }