Skip to content

Commit e15d10a

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent 003a409 commit e15d10a

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

8484
#[cfg(feature = "dnssec")]
85-
use crate::onion_message::dns_resolution::{DNSResolverMessage, OMNameResolver};
85+
use crate::onion_message::dns_resolution::OMNameResolver;
8686

8787
#[cfg(not(c_bindings))]
8888
use {
@@ -107,7 +107,7 @@ use core::{cmp, mem};
107107
use core::borrow::Borrow;
108108
use core::cell::RefCell;
109109
use crate::io::Read;
110-
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, MutexGuard, RwLock, RwLockReadGuard};
110+
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, RwLock, RwLockReadGuard};
111111
use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
112112
use core::time::Duration;
113113
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

@@ -9465,10 +9461,6 @@ impl Default for Bolt11InvoiceParameters {
94659461
///
94669462
/// [`OffersMessageFlow`]: crate::offers::flow::OffersMessageFlow
94679463
pub trait OffersMessageCommons {
9468-
#[cfg(feature = "dnssec")]
9469-
/// Get pending DNS onion messages
9470-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
9471-
94729464
#[cfg(feature = "dnssec")]
94739465
/// Get hrn resolver
94749466
fn get_hrn_resolver(&self) -> &OMNameResolver;
@@ -9601,11 +9593,6 @@ where
96019593
MR::Target: MessageRouter,
96029594
L::Target: Logger,
96039595
{
9604-
#[cfg(feature = "dnssec")]
9605-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9606-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9607-
}
9608-
96099596
#[cfg(feature = "dnssec")]
96109597
fn get_hrn_resolver(&self) -> &OMNameResolver {
96119598
&self.hrn_resolver
@@ -13122,8 +13109,6 @@ where
1312213109

1312313110
#[cfg(feature = "dnssec")]
1312413111
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13125-
#[cfg(feature = "dnssec")]
13126-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1312713112
};
1312813113

1312913114
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
@@ -421,6 +421,9 @@ where
421421
#[cfg(any(test, feature = "_test_utils"))]
422422
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
423423

424+
#[cfg(feature = "dnssec")]
425+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
426+
424427
#[cfg(feature = "_test_utils")]
425428
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
426429
/// offer generated in the test.
@@ -455,6 +458,10 @@ where
455458
message_router,
456459

457460
pending_offers_messages: Mutex::new(Vec::new()),
461+
462+
#[cfg(feature = "dnssec")]
463+
pending_dns_onion_messages: Mutex::new(Vec::new()),
464+
458465
#[cfg(feature = "_test_utils")]
459466
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
460467
logger,
@@ -1369,7 +1376,7 @@ where
13691376
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
13701377
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
13711378
for (reply_path, destination) in message_params {
1372-
self.commons.get_pending_dns_onion_messages().push((
1379+
self.pending_dns_onion_messages.lock().unwrap().push((
13731380
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
13741381
MessageSendInstructions::WithSpecifiedReplyPath {
13751382
destination: destination.clone(),
@@ -1449,6 +1456,6 @@ where
14491456
}
14501457

14511458
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1452-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1459+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
14531460
}
14541461
}

0 commit comments

Comments
 (0)