Skip to content

Commit ddfeb3f

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 bc0203d commit ddfeb3f

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};
@@ -1008,33 +1009,35 @@ where
10081009
//
10091010
// Lock order tree:
10101011
//
1012+
// `pending_offers_messages`
1013+
//
10111014
// `total_consistency_lock`
10121015
// |
10131016
// |__`forward_htlcs`
10141017
// | |
10151018
// | |__`pending_intercepted_htlcs`
10161019
// |
10171020
// |__`per_peer_state`
1018-
// | |
1019-
// | |__`pending_inbound_payments`
1020-
// | |
1021-
// | |__`claimable_payments`
1022-
// | |
1023-
// | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
1024-
// | |
1025-
// | |__`peer_state`
1026-
// | |
1027-
// | |__`id_to_peer`
1028-
// | |
1029-
// | |__`short_to_chan_info`
1030-
// | |
1031-
// | |__`outbound_scid_aliases`
1032-
// | |
1033-
// | |__`best_block`
1034-
// | |
1035-
// | |__`pending_events`
1036-
// | |
1037-
// | |__`pending_background_events`
1021+
// |
1022+
// |__`pending_inbound_payments`
1023+
// |
1024+
// |__`claimable_payments`
1025+
// |
1026+
// |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
1027+
// |
1028+
// |__`peer_state`
1029+
// |
1030+
// |__`id_to_peer`
1031+
// |
1032+
// |__`short_to_chan_info`
1033+
// |
1034+
// |__`outbound_scid_aliases`
1035+
// |
1036+
// |__`best_block`
1037+
// |
1038+
// |__`pending_events`
1039+
// |
1040+
// |__`pending_background_events`
10381041
//
10391042
pub struct ChannelManager<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
10401043
where
@@ -1246,6 +1249,8 @@ where
12461249
event_persist_notifier: Notifier,
12471250
needs_persist_flag: AtomicBool,
12481251

1252+
pending_offers_messages: Mutex<Vec<PendingOnionMessage<OffersMessage>>>,
1253+
12491254
entropy_source: ES,
12501255
node_signer: NS,
12511256
signer_provider: SP,
@@ -2326,6 +2331,8 @@ where
23262331
needs_persist_flag: AtomicBool::new(false),
23272332
funding_batch_states: Mutex::new(BTreeMap::new()),
23282333

2334+
pending_offers_messages: Mutex::new(Vec::new()),
2335+
23292336
entropy_source,
23302337
node_signer,
23312338
signer_provider,
@@ -10329,6 +10336,8 @@ where
1032910336

1033010337
funding_batch_states: Mutex::new(BTreeMap::new()),
1033110338

10339+
pending_offers_messages: Mutex::new(Vec::new()),
10340+
1033210341
entropy_source: args.entropy_source,
1033310342
node_signer: args.node_signer,
1033410343
signer_provider: args.signer_provider,

0 commit comments

Comments
 (0)