Skip to content

Commit 2d6a15f

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent c37e0f8 commit 2d6a15f

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
@@ -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(async_payments)]
8888
use {
@@ -109,7 +109,7 @@ use core::{cmp, mem};
109109
use core::borrow::Borrow;
110110
use core::cell::RefCell;
111111
use crate::io::Read;
112-
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, MutexGuard, RwLock, RwLockReadGuard};
112+
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, RwLock, RwLockReadGuard};
113113
use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
114114
use core::time::Duration;
115115
use core::ops::Deref;
@@ -2418,8 +2418,6 @@ where
24182418

24192419
#[cfg(feature = "dnssec")]
24202420
hrn_resolver: OMNameResolver,
2421-
#[cfg(feature = "dnssec")]
2422-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
24232421

24242422
#[cfg(test)]
24252423
pub(super) entropy_source: ES,
@@ -3328,8 +3326,6 @@ where
33283326

33293327
#[cfg(feature = "dnssec")]
33303328
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3331-
#[cfg(feature = "dnssec")]
3332-
pending_dns_onion_messages: Mutex::new(Vec::new()),
33333329
}
33343330
}
33353331

@@ -9593,11 +9589,6 @@ where
95939589
MR::Target: MessageRouter,
95949590
L::Target: Logger,
95959591
{
9596-
#[cfg(feature = "dnssec")]
9597-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9598-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9599-
}
9600-
96019592
#[cfg(feature = "dnssec")]
96029593
fn get_hrn_resolver(&self) -> &OMNameResolver {
96039594
&self.hrn_resolver
@@ -13165,8 +13156,6 @@ where
1316513156

1316613157
#[cfg(feature = "dnssec")]
1316713158
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13168-
#[cfg(feature = "dnssec")]
13169-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1317013159
};
1317113160

1317213161
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;
@@ -565,6 +558,9 @@ where
565558
#[cfg(any(test, feature = "_test_utils"))]
566559
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
567560

561+
#[cfg(feature = "dnssec")]
562+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
563+
568564
#[cfg(feature = "_test_utils")]
569565
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
570566
/// offer generated in the test.
@@ -604,6 +600,10 @@ where
604600
message_router,
605601

606602
pending_offers_messages: Mutex::new(Vec::new()),
603+
604+
#[cfg(feature = "dnssec")]
605+
pending_dns_onion_messages: Mutex::new(Vec::new()),
606+
607607
#[cfg(feature = "_test_utils")]
608608
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
609609
logger,
@@ -1547,7 +1547,7 @@ where
15471547
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
15481548
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
15491549
for (reply_path, destination) in message_params {
1550-
self.commons.get_pending_dns_onion_messages().push((
1550+
self.pending_dns_onion_messages.lock().unwrap().push((
15511551
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
15521552
MessageSendInstructions::WithSpecifiedReplyPath {
15531553
destination: destination.clone(),
@@ -1627,6 +1627,6 @@ where
16271627
}
16281628

16291629
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1630-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1630+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
16311631
}
16321632
}

0 commit comments

Comments
 (0)