From: Matt Corallo Date: Sat, 21 Mar 2020 22:29:17 +0000 (-0400) Subject: Flatten ChannelMonitor substructs that don't add clarity X-Git-Tag: v0.0.12~83^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b49e63b1bc759d49a203a1cd503cace86736e704;p=rust-lightning Flatten ChannelMonitor substructs that don't add clarity The new OnchainDetection struct (which is the remnants of the old KeyStorage enum, which was removed in 1dbda4faedc33506e63176e6a456) doesn't really add any clarity to ChannelMonitor, so best to just drop it and move its members into ChannelMonitor directly. --- diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 950b50f3a..e88dd3339 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -290,7 +290,7 @@ impl return Err(MonitorUpdateError("Channel monitor for given key is already present")), hash_map::Entry::Vacant(e) => e, }; - match monitor.onchain_detection.funding_info { + match monitor.funding_info { None => { return Err(MonitorUpdateError("Try to update a useless monitor without funding_txo !")); }, @@ -314,7 +314,7 @@ impl { - log_trace!(self, "Updating Channel Monitor for channel {}", log_funding_info!(orig_monitor.onchain_detection)); + log_trace!(self, "Updating Channel Monitor for channel {}", log_funding_info!(orig_monitor)); orig_monitor.update_monitor(update, &self.broadcaster) }, None => Err(MonitorUpdateError("No such monitor registered")) @@ -391,20 +391,6 @@ pub(crate) const LATENCY_GRACE_PERIOD_BLOCKS: u32 = 3; /// keeping bumping another claim tx to solve the outpoint. pub(crate) const ANTI_REORG_DELAY: u32 = 6; -struct OnchainDetection { - keys: ChanSigner, - funding_info: Option<(OutPoint, Script)>, - current_remote_commitment_txid: Option, - prev_remote_commitment_txid: Option, -} - -#[cfg(any(test, feature = "fuzztarget"))] -impl PartialEq for OnchainDetection { - fn eq(&self, other: &Self) -> bool { - self.keys.pubkeys() == other.keys.pubkeys() - } -} - #[derive(Clone, PartialEq)] struct LocalSignedTx { /// txid of the transaction in tx, just used to make comparison faster @@ -734,7 +720,11 @@ pub struct ChannelMonitor { broadcasted_remote_payment_script: Option<(Script, SecretKey)>, shutdown_script: Script, - onchain_detection: OnchainDetection, + keys: ChanSigner, + funding_info: Option<(OutPoint, Script)>, + current_remote_commitment_txid: Option, + prev_remote_commitment_txid: Option, + their_htlc_base_key: Option, their_delayed_payment_base_key: Option, funding_redeemscript: Option