Skip to content

Commit

Permalink
Store OffersMessages for later sending
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jkczyz committed Sep 14, 2023
1 parent 2f7305b commit 4ce9aad
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use crate::ln::wire::Encode;
use crate::offers::offer::{DerivedMetadata, OfferBuilder};
use crate::offers::parse::Bolt12SemanticError;
use crate::offers::refund::RefundBuilder;
use crate::onion_message::{OffersMessage, PendingOnionMessage};
use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider, WriteableEcdsaChannelSigner};
use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
use crate::util::wakers::{Future, Notifier};
Expand Down Expand Up @@ -964,33 +965,35 @@ where
//
// Lock order tree:
//
// `pending_offers_messages`
//
// `total_consistency_lock`
// |
// |__`forward_htlcs`
// | |
// | |__`pending_intercepted_htlcs`
// |
// |__`per_peer_state`
// | |
// | |__`pending_inbound_payments`
// | |
// | |__`claimable_payments`
// | |
// | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
// | |
// | |__`peer_state`
// | |
// | |__`id_to_peer`
// | |
// | |__`short_to_chan_info`
// | |
// | |__`outbound_scid_aliases`
// | |
// | |__`best_block`
// | |
// | |__`pending_events`
// | |
// | |__`pending_background_events`
// |
// |__`pending_inbound_payments`
// |
// |__`claimable_payments`
// |
// |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
// |
// |__`peer_state`
// |
// |__`id_to_peer`
// |
// |__`short_to_chan_info`
// |
// |__`outbound_scid_aliases`
// |
// |__`best_block`
// |
// |__`pending_events`
// |
// |__`pending_background_events`
//
pub struct ChannelManager<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
where
Expand Down Expand Up @@ -1196,6 +1199,8 @@ where
event_persist_notifier: Notifier,
needs_persist_flag: AtomicBool,

pending_offers_messages: Mutex<Vec<PendingOnionMessage<OffersMessage>>>,

entropy_source: ES,
node_signer: NS,
signer_provider: SP,
Expand Down Expand Up @@ -2266,6 +2271,8 @@ where
event_persist_notifier: Notifier::new(),
needs_persist_flag: AtomicBool::new(false),

pending_offers_messages: Mutex::new(Vec::new()),

entropy_source,
node_signer,
signer_provider,
Expand Down Expand Up @@ -9848,6 +9855,8 @@ where
event_persist_notifier: Notifier::new(),
needs_persist_flag: AtomicBool::new(false),

pending_offers_messages: Mutex::new(Vec::new()),

entropy_source: args.entropy_source,
node_signer: args.node_signer,
signer_provider: args.signer_provider,
Expand Down

0 comments on commit 4ce9aad

Please sign in to comment.