@@ -275,34 +275,46 @@ impl<T: Time> Writeable for ScorerUsingTime<T> {
275
275
#[ inline]
276
276
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
277
277
self . params . write ( w) ?;
278
- self . channel_failures . write ( w)
278
+ self . channel_failures . write ( w) ?;
279
+ write_tlv_fields ! ( w, { } ) ;
279
280
}
280
281
}
281
282
282
283
impl < T : Time > Readable for ScorerUsingTime < T > {
283
284
#[ inline]
284
285
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
285
- Ok ( Self {
286
+ let res = Ok ( Self {
286
287
params : Readable :: read ( r) ?,
287
288
channel_failures : Readable :: read ( r) ?,
288
- } )
289
+ } ) ;
290
+ read_tlv_fields ! ( w, { } ) ;
291
+ res
289
292
}
290
293
}
291
294
292
295
impl < T : Time > Writeable for ChannelFailure < T > {
293
296
#[ inline]
294
297
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
295
- self . undecayed_penalty_msat . write ( w) ?;
296
- ( T :: duration_since_epoch ( ) - self . last_failed . elapsed ( ) ) . write ( w)
298
+ let duration_since_epoch = ( T :: duration_since_epoch ( ) - self . last_failed . elapsed ( ) ) ;
299
+ write_tlv_fields ! ( w, {
300
+ ( 0 , self . undecayed_penalty_msat, required) ,
301
+ ( 2 , duration_since_epoch, required) ,
302
+ } ) ;
297
303
}
298
304
}
299
305
300
306
impl < T : Time > Readable for ChannelFailure < T > {
301
307
#[ inline]
302
308
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
309
+ let mut undecayed_penalty_msat = 0 ;
310
+ let mut duration_since_epoch = Duration :: from_secs ( 0 ) ;
311
+ read_tlv_fields ! ( w, {
312
+ ( 0 , undecayed_penalty_msat, required) ,
313
+ ( 2 , duration_since_epoch, required) ,
314
+ } ) ;
303
315
Ok ( Self {
304
- undecayed_penalty_msat : Readable :: read ( r ) ? ,
305
- last_failed : T :: now ( ) - ( T :: duration_since_epoch ( ) - Readable :: read ( r ) ? ) ,
316
+ undecayed_penalty_msat,
317
+ last_failed : T :: now ( ) - ( T :: duration_since_epoch ( ) - duration_since_epoch ) ,
306
318
} )
307
319
}
308
320
}
0 commit comments