diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index bba29c21123..6ed4501dc81 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -83,7 +83,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(async_payments)] use { @@ -110,7 +110,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; @@ -2400,8 +2400,6 @@ where #[cfg(feature = "dnssec")] hrn_resolver: OMNameResolver, - #[cfg(feature = "dnssec")] - pending_dns_onion_messages: Mutex>, #[cfg(test)] pub(super) entropy_source: ES, @@ -3311,8 +3309,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()), } } @@ -9497,11 +9493,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 @@ -13103,8 +13094,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 a94eb125591..d0c76b33315 100644 --- a/lightning/src/offers/flow.rs +++ b/lightning/src/offers/flow.rs @@ -40,7 +40,6 @@ use crate::onion_message::messenger::{ Destination, MessageRouter, MessageSendInstructions, Responder, ResponseInstruction, }; use crate::onion_message::offers::{OffersMessage, OffersMessageHandler}; -use crate::sync::MutexGuard; use crate::offers::invoice_error::InvoiceError; use crate::offers::nonce::Nonce; @@ -75,12 +74,6 @@ use { /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager 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; @@ -570,6 +563,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. @@ -609,6 +605,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, @@ -1536,7 +1536,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(), @@ -1616,6 +1616,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()) } }