@@ -5032,13 +5032,14 @@ mod benches {
5032
5032
}
5033
5033
5034
5034
fn generate_routes < S : Score > (
5035
- bench : & mut Bencher , graph : & NetworkGraph , scorer : S , features : InvoiceFeatures
5035
+ bench : & mut Bencher , graph : & NetworkGraph , mut scorer : S , features : InvoiceFeatures
5036
5036
) {
5037
5037
let nodes = graph. read_only ( ) . nodes ( ) . clone ( ) ;
5038
5038
let payer = payer_pubkey ( ) ;
5039
5039
5040
5040
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
5041
- let mut path_endpoints = Vec :: new ( ) ;
5041
+ let mut routes = Vec :: new ( ) ;
5042
+ let mut route_endpoints = Vec :: new ( ) ;
5042
5043
let mut seed: usize = 0xdeadbeef ;
5043
5044
' load_endpoints: for _ in 0 ..100 {
5044
5045
loop {
@@ -5049,17 +5050,33 @@ mod benches {
5049
5050
let payee = Payee :: from_node_id ( dst) . with_features ( features. clone ( ) ) ;
5050
5051
let first_hop = first_hop ( src) ;
5051
5052
let amt = seed as u64 % 1_000_000 ;
5052
- if get_route ( & payer, & payee, & graph, Some ( & [ & first_hop] ) , amt, 42 , & DummyLogger { } , & scorer) . is_ok ( ) {
5053
- path_endpoints. push ( ( first_hop, payee, amt) ) ;
5053
+ if let Ok ( route) = get_route ( & payer, & payee, & graph, Some ( & [ & first_hop] ) , amt, 42 , & DummyLogger { } , & scorer) {
5054
+ routes. push ( route) ;
5055
+ route_endpoints. push ( ( first_hop, payee, amt) ) ;
5054
5056
continue ' load_endpoints;
5055
5057
}
5056
5058
}
5057
5059
}
5058
5060
5061
+ // ...and seed the scorer with success and failure data...
5062
+ for route in routes {
5063
+ let amount = route. get_total_amount ( ) ;
5064
+ if amount < 250_000 {
5065
+ for path in route. paths {
5066
+ scorer. payment_path_successful ( & path. iter ( ) . collect :: < Vec < _ > > ( ) ) ;
5067
+ }
5068
+ } else if amount > 750_000 {
5069
+ for path in route. paths {
5070
+ let short_channel_id = path[ path. len ( ) / 2 ] . short_channel_id ;
5071
+ scorer. payment_path_failed ( & path. iter ( ) . collect :: < Vec < _ > > ( ) , short_channel_id) ;
5072
+ }
5073
+ }
5074
+ }
5075
+
5059
5076
// ...then benchmark finding paths between the nodes we learned.
5060
5077
let mut idx = 0 ;
5061
5078
bench. iter ( || {
5062
- let ( first_hop, payee, amt) = & path_endpoints [ idx % path_endpoints . len ( ) ] ;
5079
+ let ( first_hop, payee, amt) = & route_endpoints [ idx % route_endpoints . len ( ) ] ;
5063
5080
assert ! ( get_route( & payer, payee, & graph, Some ( & [ first_hop] ) , * amt, 42 , & DummyLogger { } , & scorer) . is_ok( ) ) ;
5064
5081
idx += 1 ;
5065
5082
} ) ;
0 commit comments