Skip to content

Commit 2d9bd3d

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent 287a88e commit 2d9bd3d

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 {
@@ -110,7 +110,7 @@ use core::{cmp, mem};
110110
use core::borrow::Borrow;
111111
use core::cell::RefCell;
112112
use crate::io::Read;
113-
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, MutexGuard, RwLock, RwLockReadGuard};
113+
use crate::sync::{Arc, FairRwLock, LockHeldState, LockTestExt, Mutex, RwLock, RwLockReadGuard};
114114
use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
115115
use core::time::Duration;
116116
use core::ops::Deref;
@@ -2440,8 +2440,6 @@ where
24402440

24412441
#[cfg(feature = "dnssec")]
24422442
hrn_resolver: OMNameResolver,
2443-
#[cfg(feature = "dnssec")]
2444-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
24452443

24462444
#[cfg(test)]
24472445
pub(super) entropy_source: ES,
@@ -3354,8 +3352,6 @@ where
33543352

33553353
#[cfg(feature = "dnssec")]
33563354
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3357-
#[cfg(feature = "dnssec")]
3358-
pending_dns_onion_messages: Mutex::new(Vec::new()),
33593355
}
33603356
}
33613357

@@ -9469,11 +9465,6 @@ where
94699465
MR::Target: MessageRouter,
94709466
L::Target: Logger,
94719467
{
9472-
#[cfg(feature = "dnssec")]
9473-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9474-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9475-
}
9476-
94779468
#[cfg(feature = "dnssec")]
94789469
fn get_hrn_resolver(&self) -> &OMNameResolver {
94799470
&self.hrn_resolver
@@ -13118,8 +13109,6 @@ where
1311813109

1311913110
#[cfg(feature = "dnssec")]
1312013111
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13121-
#[cfg(feature = "dnssec")]
13122-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1312313112
};
1312413113

1312513114
let mut processed_claims: HashSet<Vec<MPPClaimHTLCSource>> = new_hash_set();

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;
@@ -84,12 +83,6 @@ use {
8483
///
8584
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
8685
pub trait OffersMessageCommons {
87-
#[cfg(feature = "dnssec")]
88-
/// Get pending DNS onion messages
89-
fn get_pending_dns_onion_messages(
90-
&self,
91-
) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
92-
9386
#[cfg(feature = "dnssec")]
9487
/// Get hrn resolver
9588
fn get_hrn_resolver(&self) -> &OMNameResolver;
@@ -575,6 +568,9 @@ where
575568
#[cfg(any(test, feature = "_test_utils"))]
576569
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
577570

571+
#[cfg(feature = "dnssec")]
572+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
573+
578574
#[cfg(feature = "_test_utils")]
579575
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
580576
/// offer generated in the test.
@@ -614,6 +610,10 @@ where
614610
message_router,
615611

616612
pending_offers_messages: Mutex::new(Vec::new()),
613+
614+
#[cfg(feature = "dnssec")]
615+
pending_dns_onion_messages: Mutex::new(Vec::new()),
616+
617617
#[cfg(feature = "_test_utils")]
618618
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
619619
logger,
@@ -1661,7 +1661,7 @@ where
16611661
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
16621662
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
16631663
for (reply_path, destination) in message_params {
1664-
self.commons.get_pending_dns_onion_messages().push((
1664+
self.pending_dns_onion_messages.lock().unwrap().push((
16651665
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
16661666
MessageSendInstructions::WithSpecifiedReplyPath {
16671667
destination: destination.clone(),
@@ -1742,6 +1742,6 @@ where
17421742
}
17431743

17441744
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1745-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1745+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
17461746
}
17471747
}

0 commit comments

Comments
 (0)