Skip to content

Commit 9d208df

Browse files
committed
Store OffersMessages for later sending
Upcoming commits will add utilities for sending an InvoiceRequest for an Offer and an Invoice for a Refund. These messages need to be enqueued so that they can be released in ChannelManager's implementation of OffersMessageHandler to OnionMessenger for sending. These messages do not need to be serialized as they must be resent upon restart.
1 parent ffde8ae commit 9d208df

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use crate::ln::wire::Encode;
5959
use crate::offers::offer::{DerivedMetadata, OfferBuilder};
6060
use crate::offers::parse::Bolt12SemanticError;
6161
use crate::offers::refund::RefundBuilder;
62+
use crate::onion_message::{OffersMessage, PendingOnionMessage};
6263
use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider, WriteableEcdsaChannelSigner};
6364
use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
6465
use crate::util::wakers::{Future, Notifier};
@@ -982,33 +983,35 @@ where
982983
//
983984
// Lock order tree:
984985
//
986+
// `pending_offers_messages`
987+
//
985988
// `total_consistency_lock`
986989
// |
987990
// |__`forward_htlcs`
988991
// | |
989992
// | |__`pending_intercepted_htlcs`
990993
// |
991994
// |__`per_peer_state`
992-
// | |
993-
// | |__`pending_inbound_payments`
994-
// | |
995-
// | |__`claimable_payments`
996-
// | |
997-
// | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
998-
// | |
999-
// | |__`peer_state`
1000-
// | |
1001-
// | |__`id_to_peer`
1002-
// | |
1003-
// | |__`short_to_chan_info`
1004-
// | |
1005-
// | |__`outbound_scid_aliases`
1006-
// | |
1007-
// | |__`best_block`
1008-
// | |
1009-
// | |__`pending_events`
1010-
// | |
1011-
// | |__`pending_background_events`
995+
// |
996+
// |__`pending_inbound_payments`
997+
// |
998+
// |__`claimable_payments`
999+
// |
1000+
// |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
1001+
// |
1002+
// |__`peer_state`
1003+
// |
1004+
// |__`id_to_peer`
1005+
// |
1006+
// |__`short_to_chan_info`
1007+
// |
1008+
// |__`outbound_scid_aliases`
1009+
// |
1010+
// |__`best_block`
1011+
// |
1012+
// |__`pending_events`
1013+
// |
1014+
// |__`pending_background_events`
10121015
//
10131016
pub struct ChannelManager<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
10141017
where
@@ -1220,6 +1223,8 @@ where
12201223
event_persist_notifier: Notifier,
12211224
needs_persist_flag: AtomicBool,
12221225

1226+
pending_offers_messages: Mutex<Vec<PendingOnionMessage<OffersMessage>>>,
1227+
12231228
entropy_source: ES,
12241229
node_signer: NS,
12251230
signer_provider: SP,
@@ -2300,6 +2305,8 @@ where
23002305
needs_persist_flag: AtomicBool::new(false),
23012306
funding_batch_states: Mutex::new(BTreeMap::new()),
23022307

2308+
pending_offers_messages: Mutex::new(Vec::new()),
2309+
23032310
entropy_source,
23042311
node_signer,
23052312
signer_provider,
@@ -10100,6 +10107,8 @@ where
1010010107

1010110108
funding_batch_states: Mutex::new(BTreeMap::new()),
1010210109

10110+
pending_offers_messages: Mutex::new(Vec::new()),
10111+
1010310112
entropy_source: args.entropy_source,
1010410113
node_signer: args.node_signer,
1010510114
signer_provider: args.signer_provider,

0 commit comments

Comments
 (0)