Skip to content

Commit defec29

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent dd177d2 commit defec29

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

lightning/src/ln/channelmanager.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use crate::util::logger::{Level, Logger, WithContext};
8383
use crate::util::errors::APIError;
8484

8585
#[cfg(feature = "dnssec")]
86-
use crate::onion_message::dns_resolution::{DNSResolverMessage, OMNameResolver};
86+
use crate::onion_message::dns_resolution::OMNameResolver;
8787

8888
#[cfg(async_payments)]
8989
use {
@@ -110,7 +110,7 @@ use core::{cmp, mem};
110110
use core::borrow::Borrow;
111111
use core::cell::RefCell;
112112
use crate::io::Read;
113-
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, MutexGuard, RwLock, RwLockReadGuard};
113+
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, RwLock, RwLockReadGuard};
114114
use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
115115
use core::time::Duration;
116116
use core::ops::Deref;
@@ -2414,8 +2414,6 @@ where
24142414

24152415
#[cfg(feature = "dnssec")]
24162416
hrn_resolver: OMNameResolver,
2417-
#[cfg(feature = "dnssec")]
2418-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
24192417

24202418
#[cfg(test)]
24212419
pub(super) entropy_source: ES,
@@ -3324,8 +3322,6 @@ where
33243322

33253323
#[cfg(feature = "dnssec")]
33263324
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3327-
#[cfg(feature = "dnssec")]
3328-
pending_dns_onion_messages: Mutex::new(Vec::new()),
33293325
}
33303326
}
33313327

@@ -9540,11 +9536,6 @@ where
95409536
MR::Target: MessageRouter,
95419537
L::Target: Logger,
95429538
{
9543-
#[cfg(feature = "dnssec")]
9544-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9545-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9546-
}
9547-
95489539
#[cfg(feature = "dnssec")]
95499540
fn get_hrn_resolver(&self) -> &OMNameResolver {
95509541
&self.hrn_resolver
@@ -13157,8 +13148,6 @@ where
1315713148

1315813149
#[cfg(feature = "dnssec")]
1315913150
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13160-
#[cfg(feature = "dnssec")]
13161-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1316213151
};
1316313152

1316413153
for (_, monitor) in args.channel_monitors.iter() {

lightning/src/offers/flow.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use crate::onion_message::messenger::{
4040
Destination, MessageRouter, MessageSendInstructions, Responder, ResponseInstruction,
4141
};
4242
use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
43-
use crate::sync::MutexGuard;
4443

4544
use crate::offers::invoice_error::InvoiceError;
4645
use crate::offers::nonce::Nonce;
@@ -75,12 +74,6 @@ use {
7574
///
7675
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
7776
pub trait OffersMessageCommons {
78-
#[cfg(feature = "dnssec")]
79-
/// Get pending DNS onion messages
80-
fn get_pending_dns_onion_messages(
81-
&self,
82-
) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
83-
8477
#[cfg(feature = "dnssec")]
8578
/// Get hrn resolver
8679
fn get_hrn_resolver(&self) -> &OMNameResolver;
@@ -570,6 +563,9 @@ where
570563
#[cfg(any(test, feature = "_test_utils"))]
571564
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
572565

566+
#[cfg(feature = "dnssec")]
567+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
568+
573569
#[cfg(feature = "_test_utils")]
574570
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
575571
/// offer generated in the test.
@@ -609,6 +605,10 @@ where
609605
message_router,
610606

611607
pending_offers_messages: Mutex::new(Vec::new()),
608+
609+
#[cfg(feature = "dnssec")]
610+
pending_dns_onion_messages: Mutex::new(Vec::new()),
611+
612612
#[cfg(feature = "_test_utils")]
613613
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
614614
logger,
@@ -1536,7 +1536,7 @@ where
15361536
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
15371537
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
15381538
for (reply_path, destination) in message_params {
1539-
self.commons.get_pending_dns_onion_messages().push((
1539+
self.pending_dns_onion_messages.lock().unwrap().push((
15401540
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
15411541
MessageSendInstructions::WithSpecifiedReplyPath {
15421542
destination: destination.clone(),
@@ -1616,6 +1616,6 @@ where
16161616
}
16171617

16181618
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1619-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1619+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
16201620
}
16211621
}

0 commit comments

Comments
 (0)