Skip to content

Commit 0e01bd3

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent c7ee105 commit 0e01bd3

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 17 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;
@@ -2373,8 +2373,6 @@ where
23732373

23742374
#[cfg(feature = "dnssec")]
23752375
hrn_resolver: OMNameResolver,
2376-
#[cfg(feature = "dnssec")]
2377-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
23782376

23792377
entropy_source: ES,
23802378
node_signer: NS,
@@ -3222,8 +3220,6 @@ where
32223220

32233221
#[cfg(feature = "dnssec")]
32243222
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3225-
#[cfg(feature = "dnssec")]
3226-
pending_dns_onion_messages: Mutex::new(Vec::new()),
32273223
}
32283224
}
32293225

@@ -9154,10 +9150,6 @@ impl Default for Bolt11InvoiceParameters {
91549150
///
91559151
/// [`OffersMessageFlow`]: crate::offers::flow::OffersMessageFlow
91569152
pub trait OffersMessageCommons {
9157-
#[cfg(feature = "dnssec")]
9158-
/// Get pending DNS onion messages
9159-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
9160-
91619153
#[cfg(feature = "dnssec")]
91629154
/// Get hrn resolver
91639155
fn get_hrn_resolver(&self) -> &OMNameResolver;
@@ -9290,11 +9282,6 @@ where
92909282
MR::Target: MessageRouter,
92919283
L::Target: Logger,
92929284
{
9293-
#[cfg(feature = "dnssec")]
9294-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9295-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9296-
}
9297-
92989285
#[cfg(feature = "dnssec")]
92999286
fn get_hrn_resolver(&self) -> &OMNameResolver {
93009287
&self.hrn_resolver
@@ -12792,8 +12779,6 @@ where
1279212779

1279312780
#[cfg(feature = "dnssec")]
1279412781
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
12795-
#[cfg(feature = "dnssec")]
12796-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1279712782
};
1279812783

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

lightning/src/offers/flow.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ where
419419
#[cfg(any(test, feature = "_test_utils"))]
420420
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
421421

422+
#[cfg(feature = "dnssec")]
423+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
424+
422425
#[cfg(feature = "_test_utils")]
423426
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
424427
/// offer generated in the test.
@@ -453,6 +456,10 @@ where
453456
message_router,
454457

455458
pending_offers_messages: Mutex::new(Vec::new()),
459+
460+
#[cfg(feature = "dnssec")]
461+
pending_dns_onion_messages: Mutex::new(Vec::new()),
462+
456463
#[cfg(feature = "_test_utils")]
457464
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
458465
logger,
@@ -1367,7 +1374,7 @@ where
13671374
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
13681375
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
13691376
for (reply_path, destination) in message_params {
1370-
self.commons.get_pending_dns_onion_messages().push((
1377+
self.pending_dns_onion_messages.lock().unwrap().push((
13711378
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
13721379
MessageSendInstructions::WithSpecifiedReplyPath {
13731380
destination: destination.clone(),
@@ -1447,6 +1454,6 @@ where
14471454
}
14481455

14491456
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1450-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1457+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
14511458
}
14521459
}

0 commit comments

Comments
 (0)