Skip to content

Commit aa2d4ce

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent 58613e7 commit aa2d4ce

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
@@ -81,7 +81,7 @@ use crate::util::logger::{Level, Logger, WithContext};
8181
use crate::util::errors::APIError;
8282

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

8686
#[cfg(async_payments)]
8787
use {
@@ -108,7 +108,7 @@ use core::{cmp, mem};
108108
use core::borrow::Borrow;
109109
use core::cell::RefCell;
110110
use crate::io::Read;
111-
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, MutexGuard, RwLock, RwLockReadGuard};
111+
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, RwLock, RwLockReadGuard};
112112
use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
113113
use core::time::Duration;
114114
use core::ops::Deref;
@@ -2380,8 +2380,6 @@ where
23802380

23812381
#[cfg(feature = "dnssec")]
23822382
hrn_resolver: OMNameResolver,
2383-
#[cfg(feature = "dnssec")]
2384-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
23852383

23862384
#[cfg(test)]
23872385
pub(super) entropy_source: ES,
@@ -3233,8 +3231,6 @@ where
32333231

32343232
#[cfg(feature = "dnssec")]
32353233
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3236-
#[cfg(feature = "dnssec")]
3237-
pending_dns_onion_messages: Mutex::new(Vec::new()),
32383234
}
32393235
}
32403236

@@ -9419,11 +9415,6 @@ where
94199415
MR::Target: MessageRouter,
94209416
L::Target: Logger,
94219417
{
9422-
#[cfg(feature = "dnssec")]
9423-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9424-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9425-
}
9426-
94279418
#[cfg(feature = "dnssec")]
94289419
fn get_hrn_resolver(&self) -> &OMNameResolver {
94299420
&self.hrn_resolver
@@ -12987,8 +12978,6 @@ where
1298712978

1298812979
#[cfg(feature = "dnssec")]
1298912980
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
12990-
#[cfg(feature = "dnssec")]
12991-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1299212981
};
1299312982

1299412983
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;
@@ -578,6 +571,9 @@ where
578571
#[cfg(any(test, feature = "_test_utils"))]
579572
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
580573

574+
#[cfg(feature = "dnssec")]
575+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
576+
581577
#[cfg(feature = "_test_utils")]
582578
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
583579
/// offer generated in the test.
@@ -617,6 +613,10 @@ where
617613
message_router,
618614

619615
pending_offers_messages: Mutex::new(Vec::new()),
616+
617+
#[cfg(feature = "dnssec")]
618+
pending_dns_onion_messages: Mutex::new(Vec::new()),
619+
620620
#[cfg(feature = "_test_utils")]
621621
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
622622
logger,
@@ -1528,7 +1528,7 @@ where
15281528
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
15291529
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
15301530
for (reply_path, destination) in message_params {
1531-
self.commons.get_pending_dns_onion_messages().push((
1531+
self.pending_dns_onion_messages.lock().unwrap().push((
15321532
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
15331533
MessageSendInstructions::WithSpecifiedReplyPath {
15341534
destination: destination.clone(),
@@ -1608,6 +1608,6 @@ where
16081608
}
16091609

16101610
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1611-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1611+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
16121612
}
16131613
}

0 commit comments

Comments
 (0)