@@ -3062,8 +3062,8 @@ impl Writeable for PendingHTLCInfo {
30623062 }
30633063}
30643064
3065- impl < R : :: std :: io :: Read > Readable < R > for PendingHTLCInfo {
3066- fn read ( reader : & mut R ) -> Result < PendingHTLCInfo , DecodeError > {
3065+ impl Readable for PendingHTLCInfo {
3066+ fn read < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < PendingHTLCInfo , DecodeError > {
30673067 Ok ( PendingHTLCInfo {
30683068 onion_packet : Readable :: read ( reader) ?,
30693069 incoming_shared_secret : Readable :: read ( reader) ?,
@@ -3091,9 +3091,9 @@ impl Writeable for HTLCFailureMsg {
30913091 }
30923092}
30933093
3094- impl < R : :: std :: io :: Read > Readable < R > for HTLCFailureMsg {
3095- fn read ( reader : & mut R ) -> Result < HTLCFailureMsg , DecodeError > {
3096- match <u8 as Readable < R > >:: read ( reader) ? {
3094+ impl Readable for HTLCFailureMsg {
3095+ fn read < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < HTLCFailureMsg , DecodeError > {
3096+ match <u8 as Readable >:: read ( reader) ? {
30973097 0 => Ok ( HTLCFailureMsg :: Relay ( Readable :: read ( reader) ?) ) ,
30983098 1 => Ok ( HTLCFailureMsg :: Malformed ( Readable :: read ( reader) ?) ) ,
30993099 _ => Err ( DecodeError :: InvalidValue ) ,
@@ -3117,9 +3117,9 @@ impl Writeable for PendingHTLCStatus {
31173117 }
31183118}
31193119
3120- impl < R : :: std :: io :: Read > Readable < R > for PendingHTLCStatus {
3121- fn read ( reader : & mut R ) -> Result < PendingHTLCStatus , DecodeError > {
3122- match <u8 as Readable < R > >:: read ( reader) ? {
3120+ impl Readable for PendingHTLCStatus {
3121+ fn read < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < PendingHTLCStatus , DecodeError > {
3122+ match <u8 as Readable >:: read ( reader) ? {
31233123 0 => Ok ( PendingHTLCStatus :: Forward ( Readable :: read ( reader) ?) ) ,
31243124 1 => Ok ( PendingHTLCStatus :: Fail ( Readable :: read ( reader) ?) ) ,
31253125 _ => Err ( DecodeError :: InvalidValue ) ,
@@ -3151,9 +3151,9 @@ impl Writeable for HTLCSource {
31513151 }
31523152}
31533153
3154- impl < R : :: std :: io :: Read > Readable < R > for HTLCSource {
3155- fn read ( reader : & mut R ) -> Result < HTLCSource , DecodeError > {
3156- match <u8 as Readable < R > >:: read ( reader) ? {
3154+ impl Readable for HTLCSource {
3155+ fn read < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < HTLCSource , DecodeError > {
3156+ match <u8 as Readable >:: read ( reader) ? {
31573157 0 => Ok ( HTLCSource :: PreviousHopData ( Readable :: read ( reader) ?) ) ,
31583158 1 => Ok ( HTLCSource :: OutboundRoute {
31593159 route : Readable :: read ( reader) ?,
@@ -3182,9 +3182,9 @@ impl Writeable for HTLCFailReason {
31823182 }
31833183}
31843184
3185- impl < R : :: std :: io :: Read > Readable < R > for HTLCFailReason {
3186- fn read ( reader : & mut R ) -> Result < HTLCFailReason , DecodeError > {
3187- match <u8 as Readable < R > >:: read ( reader) ? {
3185+ impl Readable for HTLCFailReason {
3186+ fn read < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < HTLCFailReason , DecodeError > {
3187+ match <u8 as Readable >:: read ( reader) ? {
31883188 0 => Ok ( HTLCFailReason :: LightningError { err : Readable :: read ( reader) ? } ) ,
31893189 1 => Ok ( HTLCFailReason :: Reason {
31903190 failure_code : Readable :: read ( reader) ?,
@@ -3214,9 +3214,9 @@ impl Writeable for HTLCForwardInfo {
32143214 }
32153215}
32163216
3217- impl < R : :: std :: io :: Read > Readable < R > for HTLCForwardInfo {
3218- fn read ( reader : & mut R ) -> Result < HTLCForwardInfo , DecodeError > {
3219- match <u8 as Readable < R > >:: read ( reader) ? {
3217+ impl Readable for HTLCForwardInfo {
3218+ fn read < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < HTLCForwardInfo , DecodeError > {
3219+ match <u8 as Readable >:: read ( reader) ? {
32203220 0 => Ok ( HTLCForwardInfo :: AddHTLC {
32213221 prev_short_channel_id : Readable :: read ( reader) ?,
32223222 prev_htlc_id : Readable :: read ( reader) ?,
@@ -3353,14 +3353,29 @@ pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T:
33533353 pub channel_monitors : & ' a mut HashMap < OutPoint , & ' a mut ChannelMonitor < ChanSigner > > ,
33543354}
33553355
3356- impl < ' a , R : :: std:: io:: Read , ChanSigner : ChannelKeys + Readable < R > , M : Deref , T : Deref , K : Deref , F : Deref >
3357- ReadableArgs < R , ChannelManagerReadArgs < ' a , ChanSigner , M , T , K , F > > for ( Sha256dHash , ChannelManager < ChanSigner , M , T , K , F > )
3356+ // Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the
3357+ // SipmleArcChannelManager type:
3358+ impl < ' a , ChanSigner : ChannelKeys + Readable , M : Deref , T : Deref , K : Deref , F : Deref >
3359+ ReadableArgs < ChannelManagerReadArgs < ' a , ChanSigner , M , T , K , F > > for ( Sha256dHash , Arc < ChannelManager < ChanSigner , M , T , K , F > > )
33583360 where M :: Target : ManyChannelMonitor < ChanSigner > ,
33593361 T :: Target : BroadcasterInterface ,
33603362 K :: Target : KeysInterface < ChanKeySigner = ChanSigner > ,
33613363 F :: Target : FeeEstimator ,
33623364{
3363- fn read ( reader : & mut R , args : ChannelManagerReadArgs < ' a , ChanSigner , M , T , K , F > ) -> Result < Self , DecodeError > {
3365+ fn read < R : :: std:: io:: Read > ( reader : & mut R , args : ChannelManagerReadArgs < ' a , ChanSigner , M , T , K , F > ) -> Result < Self , DecodeError > {
3366+ let ( blockhash, chan_manager) = <( Sha256dHash , ChannelManager < ChanSigner , M , T , K , F > ) >:: read ( reader, args) ?;
3367+ Ok ( ( blockhash, Arc :: new ( chan_manager) ) )
3368+ }
3369+ }
3370+
3371+ impl < ' a , ChanSigner : ChannelKeys + Readable , M : Deref , T : Deref , K : Deref , F : Deref >
3372+ ReadableArgs < ChannelManagerReadArgs < ' a , ChanSigner , M , T , K , F > > for ( Sha256dHash , ChannelManager < ChanSigner , M , T , K , F > )
3373+ where M :: Target : ManyChannelMonitor < ChanSigner > ,
3374+ T :: Target : BroadcasterInterface ,
3375+ K :: Target : KeysInterface < ChanKeySigner = ChanSigner > ,
3376+ F :: Target : FeeEstimator ,
3377+ {
3378+ fn read < R : :: std:: io:: Read > ( reader : & mut R , args : ChannelManagerReadArgs < ' a , ChanSigner , M , T , K , F > ) -> Result < Self , DecodeError > {
33643379 let _ver: u8 = Readable :: read ( reader) ?;
33653380 let min_ver: u8 = Readable :: read ( reader) ?;
33663381 if min_ver > SERIALIZATION_VERSION {
0 commit comments