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