Skip to content

Commit 2da16d4

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent 79cfd24 commit 2da16d4

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 13 deletions
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(not(c_bindings))]
8989
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

@@ -9479,11 +9475,6 @@ where
94799475
MR::Target: MessageRouter,
94809476
L::Target: Logger,
94819477
{
9482-
#[cfg(feature = "dnssec")]
9483-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9484-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9485-
}
9486-
94879478
#[cfg(feature = "dnssec")]
94889479
fn get_hrn_resolver(&self) -> &OMNameResolver {
94899480
&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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use crate::onion_message::messenger::{
4242
Destination, MessageRouter, MessageSendInstructions, Responder, ResponseInstruction,
4343
};
4444
use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
45-
use crate::sync::MutexGuard;
4645

4746
use crate::offers::invoice_error::InvoiceError;
4847
use crate::offers::nonce::Nonce;
@@ -71,12 +70,6 @@ use {
7170
///
7271
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
7372
pub trait OffersMessageCommons {
74-
#[cfg(feature = "dnssec")]
75-
/// Get pending DNS onion messages
76-
fn get_pending_dns_onion_messages(
77-
&self,
78-
) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
79-
8073
#[cfg(feature = "dnssec")]
8174
/// Get hrn resolver
8275
fn get_hrn_resolver(&self) -> &OMNameResolver;
@@ -568,6 +561,9 @@ where
568561
#[cfg(any(test, feature = "_test_utils"))]
569562
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
570563

564+
#[cfg(feature = "dnssec")]
565+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
566+
571567
#[cfg(feature = "_test_utils")]
572568
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
573569
/// offer generated in the test.
@@ -607,6 +603,10 @@ where
607603
message_router,
608604

609605
pending_offers_messages: Mutex::new(Vec::new()),
606+
607+
#[cfg(feature = "dnssec")]
608+
pending_dns_onion_messages: Mutex::new(Vec::new()),
609+
610610
#[cfg(feature = "_test_utils")]
611611
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
612612
logger,
@@ -1521,7 +1521,7 @@ where
15211521
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
15221522
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
15231523
for (reply_path, destination) in message_params {
1524-
self.commons.get_pending_dns_onion_messages().push((
1524+
self.pending_dns_onion_messages.lock().unwrap().push((
15251525
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
15261526
MessageSendInstructions::WithSpecifiedReplyPath {
15271527
destination: destination.clone(),
@@ -1601,6 +1601,6 @@ where
16011601
}
16021602

16031603
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1604-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1604+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
16051605
}
16061606
}

0 commit comments

Comments
 (0)