@@ -202,6 +202,36 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
202
202
}
203
203
}
204
204
205
+ #[ derive( PartialEq , Debug ) ]
206
+ /// Details about the quality of a channel stored in a field within a DirectionalChannelInfo
207
+ /// object. Updates on PaymentSent/Failed events.
208
+ pub struct ChannelScore {
209
+ /// Increments on detection of a PaymentSent event occuring
210
+ pub successes : u64 ,
211
+ /// Increments on detection of a PaymentFailed event occurring
212
+ pub failures : u64 ,
213
+ // Many more to come...
214
+ }
215
+
216
+ impl Readable for ChannelScore {
217
+ fn read < R : :: std:: io:: Read > ( reader : & mut R ) -> Result < ChannelScore , DecodeError > {
218
+ let successes: u64 = Readable :: read ( reader) ?;
219
+ let failures: u64 = Readable :: read ( reader) ?;
220
+ Ok ( ChannelScore {
221
+ successes,
222
+ failures,
223
+ } )
224
+ }
225
+ }
226
+
227
+ impl Writeable for ChannelScore {
228
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
229
+ self . successes . write ( writer) ?;
230
+ self . failures . write ( writer) ?;
231
+ Ok ( ( ) )
232
+ }
233
+ }
234
+
205
235
#[ derive( PartialEq , Debug ) ]
206
236
/// Details about one direction of a channel. Received
207
237
/// within a channel update.
@@ -222,6 +252,9 @@ pub struct DirectionalChannelInfo {
222
252
/// Everything else is useful only for sending out for initial routing sync.
223
253
/// Not stored if contains excess data to prevent DoS.
224
254
pub last_update_message : Option < msgs:: ChannelUpdate > ,
255
+ /// Tracks a channel's performance over time. Gets updated on the detection of a
256
+ /// PaymentSent or PaymentFailed event
257
+ pub channel_score : ChannelScore ,
225
258
}
226
259
227
260
impl std:: fmt:: Display for DirectionalChannelInfo {
@@ -237,7 +270,8 @@ impl_writeable!(DirectionalChannelInfo, 0, {
237
270
cltv_expiry_delta,
238
271
htlc_minimum_msat,
239
272
fees,
240
- last_update_message
273
+ last_update_message,
274
+ channel_score
241
275
} ) ;
242
276
243
277
#[ derive( PartialEq ) ]
@@ -677,7 +711,11 @@ impl NetworkGraph {
677
711
base_msat: msg. contents. fee_base_msat,
678
712
proportional_millionths: msg. contents. fee_proportional_millionths,
679
713
} ,
680
- last_update_message
714
+ last_update_message,
715
+ channel_score: ChannelScore {
716
+ successes: 0 ,
717
+ failures: 0 ,
718
+ }
681
719
} ;
682
720
$target = Some ( updated_channel_dir_info) ;
683
721
}
0 commit comments