X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannelmanager.rs;fp=lightning%2Fsrc%2Fln%2Fchannelmanager.rs;h=3007f736c0b9978eac30b6a9712c04974e192ee0;hb=8c8bb6d246a53f1a0e4fc70788eb59947352fcb9;hp=410386aa076808e3c1398f27a9c699a043ab3284;hpb=5588eeb06b12979e21fb3aaae0c2cc95d0aa8389;p=rust-lightning diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 410386aa..3007f736 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -424,6 +424,16 @@ pub(super) enum RAACommitmentOrder { RevokeAndACKFirst, } +/// Information about claimable or being-claimed payments +struct ClaimablePayments { + /// Map from payment hash to the payment data and any HTLCs which are to us and can be + /// failed/claimed by the user. + /// + /// Note that, no consistency guarantees are made about the channels given here actually + /// existing anymore by the time you go to read them! + claimable_htlcs: HashMap)>, +} + // Note this is only exposed in cfg(test): pub(super) struct ChannelHolder { pub(super) by_id: HashMap<[u8; 32], Channel>, @@ -699,7 +709,7 @@ pub type SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, M, T, F, L> = ChannelManage // | // |__`pending_inbound_payments` // | | -// | |__`claimable_htlcs` +// | |__`claimable_payments` // | | // | |__`pending_outbound_payments` // | | @@ -787,14 +797,11 @@ pub struct ChannelManager /// See `ChannelManager` struct-level documentation for lock order requirements. pending_intercepted_htlcs: Mutex>, - /// Map from payment hash to the payment data and any HTLCs which are to us and can be - /// failed/claimed by the user. - /// - /// Note that, no consistency guarantees are made about the channels given here actually - /// existing anymore by the time you go to read them! + /// The sets of payments which are claimable or currently being claimed. See + /// [`ClaimablePayments`]' individual field docs for more info. /// /// See `ChannelManager` struct-level documentation for lock order requirements. - claimable_htlcs: Mutex)>>, + claimable_payments: Mutex, /// The set of outbound SCID aliases across all our channels, including unconfirmed channels /// and some closed channels which reached a usable state prior to being closed. This is used @@ -1600,7 +1607,7 @@ impl ChannelManager ChannelManager ChannelManager { - match self.claimable_htlcs.lock().unwrap().entry(payment_hash) { + match self.claimable_payments.lock().unwrap().claimable_htlcs.entry(payment_hash) { hash_map::Entry::Vacant(e) => { let purpose = events::PaymentPurpose::SpontaneousPayment(preimage); e.insert((purpose.clone(), vec![claimable_htlc])); @@ -3851,7 +3858,7 @@ impl ChannelManager ChannelManager ChannelManager Writeable for ChannelMana } let pending_inbound_payments = self.pending_inbound_payments.lock().unwrap(); - let claimable_htlcs = self.claimable_htlcs.lock().unwrap(); + let claimable_payments = self.claimable_payments.lock().unwrap(); let pending_outbound_payments = self.pending_outbound_payments.lock().unwrap(); let mut htlc_purposes: Vec<&events::PaymentPurpose> = Vec::new(); - (claimable_htlcs.len() as u64).write(writer)?; - for (payment_hash, (purpose, previous_hops)) in claimable_htlcs.iter() { + (claimable_payments.claimable_htlcs.len() as u64).write(writer)?; + for (payment_hash, (purpose, previous_hops)) in claimable_payments.claimable_htlcs.iter() { payment_hash.write(writer)?; (previous_hops.len() as u64).write(writer)?; for htlc in previous_hops.iter() { @@ -7827,7 +7834,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> pending_intercepted_htlcs: Mutex::new(pending_intercepted_htlcs.unwrap()), forward_htlcs: Mutex::new(forward_htlcs), - claimable_htlcs: Mutex::new(claimable_htlcs), + claimable_payments: Mutex::new(ClaimablePayments { claimable_htlcs }), outbound_scid_aliases: Mutex::new(outbound_scid_aliases), id_to_peer: Mutex::new(id_to_peer), short_to_chan_info: FairRwLock::new(short_to_chan_info),