Skip to content

Commit 7555bb8

Browse files
committed
Move pending_dns_onion_messages to flow.rs
1 parent c3c3658 commit 7555bb8

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
@@ -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(async_payments)]
8989
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;
@@ -2400,8 +2400,6 @@ where
24002400

24012401
#[cfg(feature = "dnssec")]
24022402
hrn_resolver: OMNameResolver,
2403-
#[cfg(feature = "dnssec")]
2404-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
24052403

24062404
#[cfg(test)]
24072405
pub(super) entropy_source: ES,
@@ -3311,8 +3309,6 @@ where
33113309

33123310
#[cfg(feature = "dnssec")]
33133311
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3314-
#[cfg(feature = "dnssec")]
3315-
pending_dns_onion_messages: Mutex::new(Vec::new()),
33163312
}
33173313
}
33183314

@@ -9497,11 +9493,6 @@ where
94979493
MR::Target: MessageRouter,
94989494
L::Target: Logger,
94999495
{
9500-
#[cfg(feature = "dnssec")]
9501-
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9502-
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9503-
}
9504-
95059496
#[cfg(feature = "dnssec")]
95069497
fn get_hrn_resolver(&self) -> &OMNameResolver {
95079498
&self.hrn_resolver
@@ -13097,8 +13088,6 @@ where
1309713088

1309813089
#[cfg(feature = "dnssec")]
1309913090
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13100-
#[cfg(feature = "dnssec")]
13101-
pending_dns_onion_messages: Mutex::new(Vec::new()),
1310213091
};
1310313092

1310413093
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;
@@ -578,6 +571,9 @@ where
578571
#[cfg(any(test, feature = "_test_utils"))]
579572
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
580573

574+
#[cfg(feature = "dnssec")]
575+
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
576+
581577
#[cfg(feature = "_test_utils")]
582578
/// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
583579
/// offer generated in the test.
@@ -617,6 +613,10 @@ where
617613
message_router,
618614

619615
pending_offers_messages: Mutex::new(Vec::new()),
616+
617+
#[cfg(feature = "dnssec")]
618+
pending_dns_onion_messages: Mutex::new(Vec::new()),
619+
620620
#[cfg(feature = "_test_utils")]
621621
testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
622622
logger,
@@ -1528,7 +1528,7 @@ where
15281528
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
15291529
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
15301530
for (reply_path, destination) in message_params {
1531-
self.commons.get_pending_dns_onion_messages().push((
1531+
self.pending_dns_onion_messages.lock().unwrap().push((
15321532
DNSResolverMessage::DNSSECQuery(onion_message.clone()),
15331533
MessageSendInstructions::WithSpecifiedReplyPath {
15341534
destination: destination.clone(),
@@ -1608,6 +1608,6 @@ where
16081608
}
16091609

16101610
fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1611-
core::mem::take(&mut self.commons.get_pending_dns_onion_messages())
1611+
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
16121612
}
16131613
}

0 commit comments

Comments
 (0)