From: Matt Corallo Date: Thu, 18 Feb 2021 21:20:43 +0000 (-0500) Subject: Change Persist's Sign from an associated type to a generic param X-Git-Tag: v0.0.13~23^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=523fcb6f3f16b8cd79cd2c5f21c4f92923ccc0e3;p=rust-lightning Change Persist's Sign from an associated type to a generic param --- diff --git a/background-processor/src/lib.rs b/background-processor/src/lib.rs index 06a2c00e2..0a09ae95c 100644 --- a/background-processor/src/lib.rs +++ b/background-processor/src/lib.rs @@ -54,7 +54,7 @@ impl BackgroundProcessor { /// [`FilesystemPersister::persist_manager`]: ../lightning_persister/struct.FilesystemPersister.html#impl pub fn start(persist_manager: PM, manager: Arc, Arc, Arc, Arc, Arc>>, logger: Arc) -> Self where Signer: 'static + Sign, - M: 'static + chain::Watch, + M: 'static + chain::Watch, T: 'static + BroadcasterInterface, K: 'static + KeysInterface, F: 'static + FeeEstimator, @@ -275,7 +275,7 @@ mod tests { // Test that if we encounter an error during manager persistence, the thread panics. fn persist_manager(_data: &ChannelManager, Arc, Arc, Arc, Arc>) -> Result<(), std::io::Error> where Signer: 'static + Sign, - M: 'static + chain::Watch, + M: 'static + chain::Watch, T: 'static + BroadcasterInterface, K: 'static + KeysInterface, F: 'static + FeeEstimator, diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index 24b7bf90c..e180805f2 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -108,9 +108,7 @@ impl TestChainMonitor { } } } -impl chain::Watch for TestChainMonitor { - type ChanSigner = EnforcingSigner; - +impl chain::Watch for TestChainMonitor { fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> { let mut ser = VecWriter(Vec::new()); monitor.write(&mut ser).unwrap(); diff --git a/lightning-persister/src/lib.rs b/lightning-persister/src/lib.rs index 218366e7d..cb7223a42 100644 --- a/lightning-persister/src/lib.rs +++ b/lightning-persister/src/lib.rs @@ -51,7 +51,7 @@ impl DiskWriteable for ChannelMonitor { } impl DiskWriteable for ChannelManager, Arc, Arc, Arc, Arc> -where M: chain::Watch, +where M: chain::Watch, T: BroadcasterInterface, K: KeysInterface, F: FeeEstimator, @@ -82,7 +82,7 @@ impl FilesystemPersister { manager: &ChannelManager, Arc, Arc, Arc, Arc> ) -> Result<(), std::io::Error> where Signer: Sign, - M: chain::Watch, + M: chain::Watch, T: BroadcasterInterface, K: KeysInterface, F: FeeEstimator, diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index cb2d4b47b..1923d0020 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -140,15 +140,14 @@ where C::Target: chain::Filter, } } -impl chain::Watch for ChainMonitor +impl +chain::Watch for ChainMonitor where C::Target: chain::Filter, T::Target: BroadcasterInterface, F::Target: FeeEstimator, L::Target: Logger, P::Target: channelmonitor::Persist, { - type ChanSigner = ChanSigner; - /// Adds the monitor that watches the channel referred to by the given outpoint. /// /// Calls back to [`chain::Filter`] with the funding transaction and outputs to watch. diff --git a/lightning/src/chain/mod.rs b/lightning/src/chain/mod.rs index 98fc857e9..c7957f0ac 100644 --- a/lightning/src/chain/mod.rs +++ b/lightning/src/chain/mod.rs @@ -67,10 +67,7 @@ pub trait Access: Send + Sync { /// [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html /// [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html /// [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure -pub trait Watch: Send + Sync { - /// Keys needed by monitors for creating and signing transactions. - type ChanSigner: Sign; - +pub trait Watch: Send + Sync { /// Watches a channel identified by `funding_txo` using `monitor`. /// /// Implementations are responsible for watching the chain for the funding transaction along @@ -80,7 +77,7 @@ pub trait Watch: Send + Sync { /// [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch /// [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected /// [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected - fn watch_channel(&self, funding_txo: OutPoint, monitor: ChannelMonitor) -> Result<(), ChannelMonitorUpdateErr>; + fn watch_channel(&self, funding_txo: OutPoint, monitor: ChannelMonitor) -> Result<(), ChannelMonitorUpdateErr>; /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. /// diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 21ee32b0f..a759443d8 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -398,7 +398,7 @@ pub type SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, M, T, F, L> = ChannelManage /// SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when /// you're using lightning-net-tokio. pub struct ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -745,7 +745,7 @@ macro_rules! maybe_break_monitor_err { } impl ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3102,7 +3102,7 @@ impl ChannelMana } impl MessageSendEventsProvider for ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3121,7 +3121,7 @@ impl MessageSend } impl EventsProvider for ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3140,7 +3140,7 @@ impl EventsProvi } impl ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3320,7 +3320,7 @@ impl ChannelMana impl ChannelMessageHandler for ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3833,7 +3833,7 @@ impl Readable for HTLCForwardInfo { } impl Writeable for ChannelManager - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3916,7 +3916,7 @@ impl Writeable f /// 5) Move the ChannelMonitors into your local chain::Watch. /// 6) Disconnect/connect blocks on the ChannelManager. pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3966,7 +3966,7 @@ pub struct ChannelManagerReadArgs<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManagerReadArgs<'a, Signer, M, T, K, F, L> - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -3988,7 +3988,7 @@ impl<'a, Signer: 'a + Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> // SipmleArcChannelManager type: impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ReadableArgs> for (BlockHash, Arc>) - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, @@ -4002,7 +4002,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ReadableArgs> for (BlockHash, ChannelManager) - where M::Target: chain::Watch, + where M::Target: chain::Watch, T::Target: BroadcasterInterface, K::Target: KeysInterface, F::Target: FeeEstimator, diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 4b4012343..f0743c1f0 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -98,9 +98,7 @@ impl<'a> TestChainMonitor<'a> { } } } -impl<'a> chain::Watch for TestChainMonitor<'a> { - type ChanSigner = EnforcingSigner; - +impl<'a> chain::Watch for TestChainMonitor<'a> { fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> { // At every point where we get a monitor update, we should be able to send a useful monitor // to a watchtower and disk...