Skip to content

Commit 5c7e348

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent 6627c47 commit 5c7e348

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;
@@ -2381,8 +2381,6 @@ where
23812381

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

23872385
#[cfg(test)]
23882386
pub(super) entropy_source: ES,
@@ -3234,8 +3232,6 @@ where
32343232

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

@@ -9484,11 +9480,6 @@ where
94849480
MR::Target: MessageRouter,
94859481
L::Target: Logger,
94869482
{
9487-
#[cfg(feature = "dnssec")]
9488-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9489-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9490-
}
9491-
94929483
#[cfg(feature = "dnssec")]
94939484
fn get_hrn_resolver(&self) -> &OMNameResolver {
94949485
&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
@@ -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;
@@ -69,12 +68,6 @@ use {
6968
///
7069
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
7170
pub trait OffersMessageCommons {
72-
#[cfg(feature = "dnssec")]
73-
/// Get pending DNS onion messages
74-
fn get_pending_dns_onion_messages(
75-
&self,
76-
) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
77-
7871
#[cfg(feature = "dnssec")]
7972
/// Get hrn resolver
8073
fn get_hrn_resolver(&self) -> &OMNameResolver;
@@ -562,6 +555,9 @@ where
562555
#[cfg(any(test, feature = "_test_utils"))]
563556
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
564557

558+
#[cfg(feature = "dnssec")]
559+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
560+
565561
#[cfg(feature = "_test_utils")]
566562
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
567563
/// offer generated in the test.
@@ -601,6 +597,10 @@ where
601597
message_router,
602598

603599
pending_offers_messages: Mutex::new(Vec::new()),
600+
601+
#[cfg(feature = "dnssec")]
602+
pending_dns_onion_messages: Mutex::new(Vec::new()),
603+
604604
#[cfg(feature = "_test_utils")]
605605
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
606606
logger,
@@ -1515,7 +1515,7 @@ where
15151515
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
15161516
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
15171517
for (reply_path, destination) in message_params {
1518-
self.commons.get_pending_dns_onion_messages().push((
1518+
self.pending_dns_onion_messages.lock().unwrap().push((
15191519
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
15201520
MessageSendInstructions::WithSpecifiedReplyPath {
15211521
destination: destination.clone(),
@@ -1595,6 +1595,6 @@ where
15951595
}
15961596

15971597
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1598-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1598+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
15991599
}
16001600
}

0 commit comments

Comments
 (0)