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