Skip to content

Commit 21e8600

Browse files
committed
f - Drop unnecessary std gates and restore unrelated whitespace
`Notifier`, `Future`, and `.await` are all available in no-std; only `Future::wait_timeout` requires std. Stop gating the notifier field and callers on `std`, and also revert the incidental blank-line removals that crept into the async-receive-offer refresh changes. Co-Authored-By: HAL 9000
1 parent 7f69689 commit 21e8600

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5893,7 +5893,6 @@ impl<
58935893
///
58945894
/// [`Future`]: crate::util::wakers::Future
58955895
/// [`Future::wait_timeout`]: crate::util::wakers::Future::wait_timeout
5896-
#[cfg(feature = "std")]
58975896
pub async fn await_async_receive_offer(&self) -> Result<Offer, ()> {
58985897
if let Ok(offer) = self.get_async_receive_offer() {
58995898
return Ok(offer);
@@ -5909,7 +5908,6 @@ impl<
59095908
///
59105909
/// [`Future`]: crate::util::wakers::Future
59115910
/// [`OffersMessageFlow::get_async_receive_offer_ready_future`]: crate::offers::flow::OffersMessageFlow::get_async_receive_offer_ready_future
5912-
#[cfg(feature = "std")]
59135911
pub fn get_async_receive_offer_ready_future(&self) -> crate::util::wakers::Future {
59145912
self.flow.get_async_receive_offer_ready_future()
59155913
}

lightning/src/offers/flow.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ use crate::sync::{Mutex, RwLock};
6161
use crate::types::payment::{PaymentHash, PaymentSecret};
6262
use crate::util::logger::Logger;
6363
use crate::util::ser::Writeable;
64-
#[cfg(feature = "std")]
65-
use crate::util::wakers::Future;
66-
#[cfg(feature = "std")]
67-
use crate::util::wakers::Notifier;
64+
use crate::util::wakers::{Future, Notifier};
6865

6966
/// A BOLT12 offers code and flow utility provider, which facilitates
7067
/// BOLT12 builder generation and onion message handling.
@@ -91,7 +88,6 @@ pub struct OffersMessageFlow<MR: MessageRouter, L: Logger> {
9188

9289
pending_async_payments_messages: Mutex<Vec<(AsyncPaymentsMessage, MessageSendInstructions)>>,
9390
async_receive_offer_cache: Mutex<AsyncReceiveOfferCache>,
94-
#[cfg(feature = "std")]
9591
async_receive_offer_ready_notifier: Notifier,
9692

9793
logger: L,
@@ -122,7 +118,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
122118
pending_async_payments_messages: Mutex::new(Vec::new()),
123119

124120
async_receive_offer_cache: Mutex::new(AsyncReceiveOfferCache::new()),
125-
#[cfg(feature = "std")]
126121
async_receive_offer_ready_notifier: Notifier::new(),
127122

128123
logger,
@@ -1369,6 +1364,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
13691364
Some(idx) => idx,
13701365
None => return Ok(()),
13711366
};
1367+
13721368
// If we need new offers, send out offer paths request messages to the static invoice server.
13731369
let context = MessageContext::AsyncPayments(AsyncPaymentsContext::OfferPaths {
13741370
path_absolute_expiry: duration_since_epoch
@@ -1482,6 +1478,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
14821478
},
14831479
_ => return None,
14841480
};
1481+
14851482
// Create the blinded paths that will be included in the async recipient's offer.
14861483
let (offer_paths, paths_expiry) = {
14871484
let path_absolute_expiry =
@@ -1543,6 +1540,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15431540
},
15441541
_ => return None,
15451542
};
1543+
15461544
{
15471545
// Only respond with `ServeStaticInvoice` if we actually need a new offer built.
15481546
let mut cache = self.async_receive_offer_cache.lock().unwrap();
@@ -1574,6 +1572,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15741572
return None;
15751573
},
15761574
};
1575+
15771576
let (invoice, forward_invoice_request_path) = match self.create_static_invoice_for_server(
15781577
&offer,
15791578
offer_nonce,
@@ -1587,6 +1586,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15871586
return None;
15881587
},
15891588
};
1589+
15901590
if let Err(()) = self.async_receive_offer_cache.lock().unwrap().cache_pending_offer(
15911591
offer,
15921592
message.paths_absolute_expiry,
@@ -1598,6 +1598,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15981598
log_error!(self.logger, "Failed to cache pending offer");
15991599
return None;
16001600
}
1601+
16011602
let reply_path_context = {
16021603
MessageContext::AsyncPayments(AsyncPaymentsContext::StaticInvoicePersisted {
16031604
offer_id,
@@ -1714,7 +1715,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
17141715
pub fn handle_static_invoice_persisted(&self, context: AsyncPaymentsContext) -> bool {
17151716
let mut cache = self.async_receive_offer_cache.lock().unwrap();
17161717
let updated = cache.static_invoice_persisted(context);
1717-
#[cfg(feature = "std")]
17181718
if updated {
17191719
self.async_receive_offer_ready_notifier.notify();
17201720
}
@@ -1727,7 +1727,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
17271727
/// Callers can either `.await` the returned [`Future`] in an async context or call
17281728
/// [`Future::wait_timeout`] from a synchronous context. After it completes, use
17291729
/// [`Self::get_async_receive_offer`] to retrieve the offer.
1730-
#[cfg(feature = "std")]
17311730
pub fn get_async_receive_offer_ready_future(&self) -> Future {
17321731
self.async_receive_offer_ready_notifier.get_future()
17331732
}

0 commit comments

Comments
 (0)