From: Matt Corallo Date: Mon, 27 Jan 2020 15:38:13 +0000 (-0500) Subject: Impl ReadableArgs for Arc, not just ChannelManager. X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=c7f8ae05151941c51d06caca7cc6ad5d2b0e044d;p=rust-lightning 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. --- 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,