From c7f8ae05151941c51d06caca7cc6ad5d2b0e044d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 27 Jan 2020 10:38:13 -0500 Subject: [PATCH] Impl ReadableArgs for Arc, not just ChannelManager. This provides a simple wrapper for deserializing right into an Arc, which improves UX a tiny bit when working with SimpleArcChannelManager types. --- lightning/src/ln/channelmanager.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 63e32c1a5..476d5be89 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -3353,6 +3353,21 @@ pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T: pub channel_monitors: &'a mut HashMap>, } +// Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the +// SipmleArcChannelManager type: +impl<'a, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: Deref> + ReadableArgs> for (Sha256dHash, Arc>) + where M::Target: ManyChannelMonitor, + T::Target: BroadcasterInterface, + K::Target: KeysInterface, + F::Target: FeeEstimator, +{ + fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, ChanSigner, M, T, K, F>) -> Result { + let (blockhash, chan_manager) = <(Sha256dHash, ChannelManager)>::read(reader, args)?; + Ok((blockhash, Arc::new(chan_manager))) + } +} + impl<'a, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: Deref> ReadableArgs> for (Sha256dHash, ChannelManager) where M::Target: ManyChannelMonitor, -- 2.39.5