@@ -191,7 +191,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
191
191
192
192
let network = network_graph. network_map . read ( ) . unwrap ( ) ;
193
193
let mut targets = BinaryHeap :: new ( ) ; //TODO: Do we care about switching to eg Fibbonaci heap?
194
- let mut dist = HashMap :: with_capacity ( network. nodes . len ( ) ) ;
194
+ let mut dist = HashMap :: with_capacity ( network. get_nodes ( ) . len ( ) ) ;
195
195
196
196
let mut first_hop_targets = HashMap :: with_capacity ( if first_hops. is_some ( ) { first_hops. as_ref ( ) . unwrap ( ) . len ( ) } else { 0 } ) ;
197
197
if let Some ( hops) = first_hops {
@@ -230,7 +230,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
230
230
let mut total_fee = $starting_fee_msat as u64 ;
231
231
let hm_entry = dist. entry( & $directional_info. src_node_id) ;
232
232
let old_entry = hm_entry. or_insert_with( || {
233
- let node = network. nodes . get( & $directional_info. src_node_id) . unwrap( ) ;
233
+ let node = network. get_nodes ( ) . get( & $directional_info. src_node_id) . unwrap( ) ;
234
234
let mut fee_base_msat = u32 :: max_value( ) ;
235
235
let mut fee_proportional_millionths = u32 :: max_value( ) ;
236
236
if let Some ( fees) = node. lowest_inbound_channel_fees {
@@ -292,7 +292,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
292
292
293
293
if !$node. features. requires_unknown_bits( ) {
294
294
for chan_id in $node. channels. iter( ) {
295
- let chan = network. channels . get( chan_id) . unwrap( ) ;
295
+ let chan = network. get_channels ( ) . get( chan_id) . unwrap( ) ;
296
296
if !chan. features. requires_unknown_bits( ) {
297
297
if chan. one_to_two. src_node_id == * $node_id {
298
298
// ie $node is one, ie next hop in A* is two, via the two_to_one channel
@@ -314,7 +314,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
314
314
} ;
315
315
}
316
316
317
- match network. nodes . get ( target) {
317
+ match network. get_nodes ( ) . get ( target) {
318
318
None => { } ,
319
319
Some ( node) => {
320
320
add_entries_to_cheapest_to_target_node ! ( node, target, 0 ) ;
@@ -323,7 +323,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
323
323
324
324
for hop in last_hops. iter ( ) {
325
325
if first_hops. is_none ( ) || hop. src_node_id != * our_node_id { // first_hop overrules last_hops
326
- if network. nodes . get ( & hop. src_node_id ) . is_some ( ) {
326
+ if network. get_nodes ( ) . get ( & hop. src_node_id ) . is_some ( ) {
327
327
if first_hops. is_some ( ) {
328
328
if let Some ( & ( ref first_hop, ref features) ) = first_hop_targets. get ( & hop. src_node_id ) {
329
329
// Currently there are no channel-context features defined, so we are a
@@ -346,7 +346,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
346
346
loop {
347
347
if let Some ( & ( _, ref features) ) = first_hop_targets. get ( & res. last ( ) . unwrap ( ) . pubkey ) {
348
348
res. last_mut ( ) . unwrap ( ) . node_features = NodeFeatures :: with_known_relevant_init_flags ( & features) ;
349
- } else if let Some ( node) = network. nodes . get ( & res. last ( ) . unwrap ( ) . pubkey ) {
349
+ } else if let Some ( node) = network. get_nodes ( ) . get ( & res. last ( ) . unwrap ( ) . pubkey ) {
350
350
res. last_mut ( ) . unwrap ( ) . node_features = node. features . clone ( ) ;
351
351
} else {
352
352
// We should be able to fill in features for everything except the last
@@ -375,7 +375,7 @@ pub fn get_route(our_node_id: &PublicKey, network_graph: &NetworkGraph, target:
375
375
return Ok ( route) ;
376
376
}
377
377
378
- match network. nodes . get ( & pubkey) {
378
+ match network. get_nodes ( ) . get ( & pubkey) {
379
379
None => { } ,
380
380
Some ( node) => {
381
381
add_entries_to_cheapest_to_target_node ! ( node, & pubkey, lowest_fee_to_node) ;
@@ -512,7 +512,7 @@ mod tests {
512
512
base_msat : 100 ,
513
513
proportional_millionths : 0
514
514
} ;
515
- network. nodes . insert ( node1. clone ( ) , NodeInfo {
515
+ network. add_node ( node1. clone ( ) , NodeInfo {
516
516
channels : vec ! ( NetworkMap :: get_key( 1 , zero_hash. clone( ) ) , NetworkMap :: get_key( 3 , zero_hash. clone( ) ) ) ,
517
517
lowest_inbound_channel_fees : Some ( lowest_routing_fees) ,
518
518
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 1 ) ) ,
@@ -522,7 +522,7 @@ mod tests {
522
522
addresses : Vec :: new ( ) ,
523
523
announcement_message : None ,
524
524
} ) ;
525
- network. channels . insert ( NetworkMap :: get_key ( 1 , zero_hash. clone ( ) ) , ChannelInfo {
525
+ network. add_channel ( NetworkMap :: get_key ( 1 , zero_hash. clone ( ) ) , ChannelInfo {
526
526
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 1 ) ) ,
527
527
one_to_two : DirectionalChannelInfo {
528
528
src_node_id : our_id. clone ( ) ,
@@ -550,7 +550,7 @@ mod tests {
550
550
base_msat : 0 ,
551
551
proportional_millionths : 0
552
552
} ;
553
- network. nodes . insert ( node2. clone ( ) , NodeInfo {
553
+ network. add_node ( node2. clone ( ) , NodeInfo {
554
554
channels : vec ! ( NetworkMap :: get_key( 2 , zero_hash. clone( ) ) , NetworkMap :: get_key( 4 , zero_hash. clone( ) ) ) ,
555
555
lowest_inbound_channel_fees : Some ( routing_fees. clone ( ) ) ,
556
556
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 2 ) ) ,
@@ -560,7 +560,7 @@ mod tests {
560
560
addresses : Vec :: new ( ) ,
561
561
announcement_message : None ,
562
562
} ) ;
563
- network. channels . insert ( NetworkMap :: get_key ( 2 , zero_hash. clone ( ) ) , ChannelInfo {
563
+ network. add_channel ( NetworkMap :: get_key ( 2 , zero_hash. clone ( ) ) , ChannelInfo {
564
564
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 2 ) ) ,
565
565
one_to_two : DirectionalChannelInfo {
566
566
src_node_id : our_id. clone ( ) ,
@@ -584,7 +584,7 @@ mod tests {
584
584
} ,
585
585
announcement_message : None ,
586
586
} ) ;
587
- network. nodes . insert ( node8. clone ( ) , NodeInfo {
587
+ network. add_node ( node8. clone ( ) , NodeInfo {
588
588
channels : vec ! ( NetworkMap :: get_key( 12 , zero_hash. clone( ) ) , NetworkMap :: get_key( 13 , zero_hash. clone( ) ) ) ,
589
589
lowest_inbound_channel_fees : Some ( routing_fees. clone ( ) ) ,
590
590
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 8 ) ) ,
@@ -594,7 +594,7 @@ mod tests {
594
594
addresses : Vec :: new ( ) ,
595
595
announcement_message : None ,
596
596
} ) ;
597
- network. channels . insert ( NetworkMap :: get_key ( 12 , zero_hash. clone ( ) ) , ChannelInfo {
597
+ network. add_channel ( NetworkMap :: get_key ( 12 , zero_hash. clone ( ) ) , ChannelInfo {
598
598
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 12 ) ) ,
599
599
one_to_two : DirectionalChannelInfo {
600
600
src_node_id : our_id. clone ( ) ,
@@ -618,7 +618,7 @@ mod tests {
618
618
} ,
619
619
announcement_message : None ,
620
620
} ) ;
621
- network. nodes . insert ( node3. clone ( ) , NodeInfo {
621
+ network. add_node ( node3. clone ( ) , NodeInfo {
622
622
channels : vec ! (
623
623
NetworkMap :: get_key( 3 , zero_hash. clone( ) ) ,
624
624
NetworkMap :: get_key( 4 , zero_hash. clone( ) ) ,
@@ -634,7 +634,7 @@ mod tests {
634
634
addresses : Vec :: new ( ) ,
635
635
announcement_message : None ,
636
636
} ) ;
637
- network. channels . insert ( NetworkMap :: get_key ( 3 , zero_hash. clone ( ) ) , ChannelInfo {
637
+ network. add_channel ( NetworkMap :: get_key ( 3 , zero_hash. clone ( ) ) , ChannelInfo {
638
638
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 3 ) ) ,
639
639
one_to_two : DirectionalChannelInfo {
640
640
src_node_id : node1. clone ( ) ,
@@ -658,7 +658,7 @@ mod tests {
658
658
} ,
659
659
announcement_message : None ,
660
660
} ) ;
661
- network. channels . insert ( NetworkMap :: get_key ( 4 , zero_hash. clone ( ) ) , ChannelInfo {
661
+ network. add_channel ( NetworkMap :: get_key ( 4 , zero_hash. clone ( ) ) , ChannelInfo {
662
662
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 4 ) ) ,
663
663
one_to_two : DirectionalChannelInfo {
664
664
src_node_id : node2. clone ( ) ,
@@ -682,7 +682,7 @@ mod tests {
682
682
} ,
683
683
announcement_message : None ,
684
684
} ) ;
685
- network. channels . insert ( NetworkMap :: get_key ( 13 , zero_hash. clone ( ) ) , ChannelInfo {
685
+ network. add_channel ( NetworkMap :: get_key ( 13 , zero_hash. clone ( ) ) , ChannelInfo {
686
686
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 13 ) ) ,
687
687
one_to_two : DirectionalChannelInfo {
688
688
src_node_id : node8. clone ( ) ,
@@ -706,7 +706,7 @@ mod tests {
706
706
} ,
707
707
announcement_message : None ,
708
708
} ) ;
709
- network. nodes . insert ( node4. clone ( ) , NodeInfo {
709
+ network. add_node ( node4. clone ( ) , NodeInfo {
710
710
channels : vec ! ( NetworkMap :: get_key( 5 , zero_hash. clone( ) ) , NetworkMap :: get_key( 11 , zero_hash. clone( ) ) ) ,
711
711
lowest_inbound_channel_fees : Some ( routing_fees. clone ( ) ) ,
712
712
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 4 ) ) ,
@@ -716,7 +716,7 @@ mod tests {
716
716
addresses : Vec :: new ( ) ,
717
717
announcement_message : None ,
718
718
} ) ;
719
- network. channels . insert ( NetworkMap :: get_key ( 5 , zero_hash. clone ( ) ) , ChannelInfo {
719
+ network. add_channel ( NetworkMap :: get_key ( 5 , zero_hash. clone ( ) ) , ChannelInfo {
720
720
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 5 ) ) ,
721
721
one_to_two : DirectionalChannelInfo {
722
722
src_node_id : node3. clone ( ) ,
@@ -740,7 +740,7 @@ mod tests {
740
740
} ,
741
741
announcement_message : None ,
742
742
} ) ;
743
- network. nodes . insert ( node5. clone ( ) , NodeInfo {
743
+ network. add_node ( node5. clone ( ) , NodeInfo {
744
744
channels : vec ! ( NetworkMap :: get_key( 6 , zero_hash. clone( ) ) , NetworkMap :: get_key( 11 , zero_hash. clone( ) ) ) ,
745
745
lowest_inbound_channel_fees : Some ( routing_fees. clone ( ) ) ,
746
746
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 5 ) ) ,
@@ -750,7 +750,7 @@ mod tests {
750
750
addresses : Vec :: new ( ) ,
751
751
announcement_message : None ,
752
752
} ) ;
753
- network. channels . insert ( NetworkMap :: get_key ( 6 , zero_hash. clone ( ) ) , ChannelInfo {
753
+ network. add_channel ( NetworkMap :: get_key ( 6 , zero_hash. clone ( ) ) , ChannelInfo {
754
754
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 6 ) ) ,
755
755
one_to_two : DirectionalChannelInfo {
756
756
src_node_id : node3. clone ( ) ,
@@ -771,7 +771,7 @@ mod tests {
771
771
} ,
772
772
announcement_message : None ,
773
773
} ) ;
774
- network. channels . insert ( NetworkMap :: get_key ( 11 , zero_hash. clone ( ) ) , ChannelInfo {
774
+ network. add_channel ( NetworkMap :: get_key ( 11 , zero_hash. clone ( ) ) , ChannelInfo {
775
775
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 11 ) ) ,
776
776
one_to_two : DirectionalChannelInfo {
777
777
src_node_id : node5. clone ( ) ,
@@ -792,7 +792,7 @@ mod tests {
792
792
} ,
793
793
announcement_message : None ,
794
794
} ) ;
795
- network. nodes . insert ( node6. clone ( ) , NodeInfo {
795
+ network. add_node ( node6. clone ( ) , NodeInfo {
796
796
channels : vec ! ( NetworkMap :: get_key( 7 , zero_hash. clone( ) ) ) ,
797
797
lowest_inbound_channel_fees : Some ( routing_fees. clone ( ) ) ,
798
798
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 6 ) ) ,
@@ -802,7 +802,7 @@ mod tests {
802
802
addresses : Vec :: new ( ) ,
803
803
announcement_message : None ,
804
804
} ) ;
805
- network. channels . insert ( NetworkMap :: get_key ( 7 , zero_hash. clone ( ) ) , ChannelInfo {
805
+ network. add_channel ( NetworkMap :: get_key ( 7 , zero_hash. clone ( ) ) , ChannelInfo {
806
806
features : ChannelFeatures :: from_le_bytes ( id_to_feature_flags ! ( 7 ) ) ,
807
807
one_to_two : DirectionalChannelInfo {
808
808
src_node_id : node3. clone ( ) ,
@@ -849,8 +849,8 @@ mod tests {
849
849
850
850
{ // Disable channels 4 and 12 by requiring unknown feature bits
851
851
let mut network = network_graph. network_map . write ( ) . unwrap ( ) ;
852
- network. channels . get_mut ( & NetworkMap :: get_key ( 4 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
853
- network. channels . get_mut ( & NetworkMap :: get_key ( 12 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
852
+ network. get_channel_mut ( & NetworkMap :: get_key ( 4 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
853
+ network. get_channel_mut ( & NetworkMap :: get_key ( 12 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
854
854
}
855
855
856
856
{ // If all the channels require some features we don't understand, route should fail
@@ -891,15 +891,15 @@ mod tests {
891
891
892
892
{ // Re-enable channels 4 and 12 by wiping the unknown feature bits
893
893
let mut network = network_graph. network_map . write ( ) . unwrap ( ) ;
894
- network. channels . get_mut ( & NetworkMap :: get_key ( 4 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
895
- network. channels . get_mut ( & NetworkMap :: get_key ( 12 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
894
+ network. get_channel_mut ( & NetworkMap :: get_key ( 4 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
895
+ network. get_channel_mut ( & NetworkMap :: get_key ( 12 , zero_hash. clone ( ) ) ) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
896
896
}
897
897
898
898
{ // Disable nodes 1, 2, and 8 by requiring unknown feature bits
899
899
let mut network = network_graph. network_map . write ( ) . unwrap ( ) ;
900
- network. nodes . get_mut ( & node1) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
901
- network. nodes . get_mut ( & node2) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
902
- network. nodes . get_mut ( & node8) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
900
+ network. get_node_mut ( & node1) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
901
+ network. get_node_mut ( & node2) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
902
+ network. get_node_mut ( & node8) . unwrap ( ) . features . set_require_unknown_bits ( ) ;
903
903
}
904
904
905
905
{ // If all nodes require some features we don't understand, route should fail
@@ -940,9 +940,9 @@ mod tests {
940
940
941
941
{ // Re-enable nodes 1, 2, and 8
942
942
let mut network = network_graph. network_map . write ( ) . unwrap ( ) ;
943
- network. nodes . get_mut ( & node1) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
944
- network. nodes . get_mut ( & node2) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
945
- network. nodes . get_mut ( & node8) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
943
+ network. get_node_mut ( & node1) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
944
+ network. get_node_mut ( & node2) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
945
+ network. get_node_mut ( & node8) . unwrap ( ) . features . clear_require_unknown_bits ( ) ;
946
946
}
947
947
948
948
// Note that we don't test disabling node 3 and failing to route to it, as we (somewhat
0 commit comments