Skip to content

Commit e6f8081

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 98f4d10 commit e6f8081

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};
@@ -964,33 +965,35 @@ where
964965
//
965966
// Lock order tree:
966967
//
968+
// `pending_offers_messages`
969+
//
967970
// `total_consistency_lock`
968971
// |
969972
// |__`forward_htlcs`
970973
// | |
971974
// | |__`pending_intercepted_htlcs`
972975
// |
973976
// |__`per_peer_state`
974-
// | |
975-
// | |__`pending_inbound_payments`
976-
// | |
977-
// | |__`claimable_payments`
978-
// | |
979-
// | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
980-
// | |
981-
// | |__`peer_state`
982-
// | |
983-
// | |__`id_to_peer`
984-
// | |
985-
// | |__`short_to_chan_info`
986-
// | |
987-
// | |__`outbound_scid_aliases`
988-
// | |
989-
// | |__`best_block`
990-
// | |
991-
// | |__`pending_events`
992-
// | |
993-
// | |__`pending_background_events`
977+
// |
978+
// |__`pending_inbound_payments`
979+
// |
980+
// |__`claimable_payments`
981+
// |
982+
// |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
983+
// |
984+
// |__`peer_state`
985+
// |
986+
// |__`id_to_peer`
987+
// |
988+
// |__`short_to_chan_info`
989+
// |
990+
// |__`outbound_scid_aliases`
991+
// |
992+
// |__`best_block`
993+
// |
994+
// |__`pending_events`
995+
// |
996+
// |__`pending_background_events`
994997
//
995998
pub struct ChannelManager<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
996999
where
@@ -1196,6 +1199,8 @@ where
11961199
event_persist_notifier: Notifier,
11971200
needs_persist_flag: AtomicBool,
11981201

1202+
pending_offers_messages: Mutex<Vec<PendingOnionMessage<OffersMessage>>>,
1203+
11991204
entropy_source: ES,
12001205
node_signer: NS,
12011206
signer_provider: SP,
@@ -2266,6 +2271,8 @@ where
22662271
event_persist_notifier: Notifier::new(),
22672272
needs_persist_flag: AtomicBool::new(false),
22682273

2274+
pending_offers_messages: Mutex::new(Vec::new()),
2275+
22692276
entropy_source,
22702277
node_signer,
22712278
signer_provider,
@@ -9848,6 +9855,8 @@ where
98489855
event_persist_notifier: Notifier::new(),
98499856
needs_persist_flag: AtomicBool::new(false),
98509857

9858+
pending_offers_messages: Mutex::new(Vec::new()),
9859+
98519860
entropy_source: args.entropy_source,
98529861
node_signer: args.node_signer,
98539862
signer_provider: args.signer_provider,

0 commit comments

Comments
 (0)