@@ -125,10 +125,10 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
125
125
let _ = self . network_graph . write ( ) . unwrap ( ) . update_channel ( msg, Some ( & self . secp_ctx ) ) ;
126
126
} ,
127
127
& msgs:: HTLCFailChannelUpdate :: ChannelClosed { ref short_channel_id, ref is_permanent } => {
128
- self . network_graph . write ( ) . unwrap ( ) . close_channel_from_update ( short_channel_id, & is_permanent) ;
128
+ self . network_graph . write ( ) . unwrap ( ) . close_channel_from_update ( * short_channel_id, * is_permanent) ;
129
129
} ,
130
130
& msgs:: HTLCFailChannelUpdate :: NodeFailure { ref node_id, ref is_permanent } => {
131
- self . network_graph . write ( ) . unwrap ( ) . fail_node ( node_id, & is_permanent) ;
131
+ self . network_graph . write ( ) . unwrap ( ) . fail_node ( node_id, * is_permanent) ;
132
132
} ,
133
133
}
134
134
}
@@ -505,6 +505,14 @@ impl NetworkGraph {
505
505
None
506
506
}
507
507
508
+ /// Creates a new, empty, network graph.
509
+ pub fn new ( ) -> NetworkGraph {
510
+ Self {
511
+ channels : BTreeMap :: new ( ) ,
512
+ nodes : BTreeMap :: new ( ) ,
513
+ }
514
+ }
515
+
508
516
/// For an already known node (from channel announcements), update its stored properties from a given node announcement
509
517
/// Announcement signatures are checked here only if Secp256k1 object is provided.
510
518
fn update_node_from_announcement ( & mut self , msg : & msgs:: NodeAnnouncement , secp_ctx : Option < & Secp256k1 < secp256k1:: VerifyOnly > > ) -> Result < bool , LightningError > {
@@ -615,10 +623,10 @@ impl NetworkGraph {
615
623
/// If permanent, removes a channel from the local storage.
616
624
/// May cause the removal of nodes too, if this was their last channel.
617
625
/// If not permanent, makes channels unavailable for routing.
618
- pub fn close_channel_from_update ( & mut self , short_channel_id : & u64 , is_permanent : & bool ) {
619
- if * is_permanent {
620
- if let Some ( chan) = self . channels . remove ( short_channel_id) {
621
- Self :: remove_channel_in_nodes ( & mut self . nodes , & chan, * short_channel_id) ;
626
+ pub fn close_channel_from_update ( & mut self , short_channel_id : u64 , is_permanent : bool ) {
627
+ if is_permanent {
628
+ if let Some ( chan) = self . channels . remove ( & short_channel_id) {
629
+ Self :: remove_channel_in_nodes ( & mut self . nodes , & chan, short_channel_id) ;
622
630
}
623
631
} else {
624
632
if let Some ( chan) = self . channels . get_mut ( & short_channel_id) {
@@ -632,8 +640,8 @@ impl NetworkGraph {
632
640
}
633
641
}
634
642
635
- fn fail_node ( & mut self , _node_id : & PublicKey , is_permanent : & bool ) {
636
- if * is_permanent {
643
+ fn fail_node ( & mut self , _node_id : & PublicKey , is_permanent : bool ) {
644
+ if is_permanent {
637
645
// TODO: Wholly remove the node
638
646
} else {
639
647
// TODO: downgrade the node
0 commit comments