@@ -126,7 +126,7 @@ pub struct NetworkGraph<L: Deref> where L::Target: Logger {
126
126
secp_ctx : Secp256k1 < secp256k1:: VerifyOnly > ,
127
127
last_rapid_gossip_sync_timestamp : Mutex < Option < u32 > > ,
128
128
genesis_hash : BlockHash ,
129
- _logger : L ,
129
+ logger : L ,
130
130
// Lock order: channels -> nodes
131
131
channels : RwLock < BTreeMap < u64 , ChannelInfo > > ,
132
132
nodes : RwLock < BTreeMap < NodeId , NodeInfo > > ,
@@ -248,29 +248,27 @@ where C::Target: chain::Access, L::Target: Logger
248
248
}
249
249
}
250
250
251
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > EventHandler for ( & G , & L )
252
- where L :: Target : Logger {
251
+ impl < L : Deref > EventHandler for NetworkGraph < L > where L :: Target : Logger {
253
252
fn handle_event ( & self , event : & Event ) {
254
253
if let Event :: PaymentPathFailed { payment_hash : _, rejected_by_dest : _, network_update, .. } = event {
255
254
if let Some ( network_update) = network_update {
256
- let ( network_graph, logger) = self ;
257
255
match * network_update {
258
256
NetworkUpdate :: ChannelUpdateMessage { ref msg } => {
259
257
let short_channel_id = msg. contents . short_channel_id ;
260
258
let is_enabled = msg. contents . flags & ( 1 << 1 ) != ( 1 << 1 ) ;
261
259
let status = if is_enabled { "enabled" } else { "disabled" } ;
262
- log_debug ! ( logger, "Updating channel with channel_update from a payment failure. Channel {} is {}." , short_channel_id, status) ;
263
- let _ = network_graph . update_channel ( msg) ;
260
+ log_debug ! ( self . logger, "Updating channel with channel_update from a payment failure. Channel {} is {}." , short_channel_id, status) ;
261
+ let _ = self . update_channel ( msg) ;
264
262
} ,
265
263
NetworkUpdate :: ChannelFailure { short_channel_id, is_permanent } => {
266
264
let action = if is_permanent { "Removing" } else { "Disabling" } ;
267
- log_debug ! ( logger, "{} channel graph entry for {} due to a payment failure." , action, short_channel_id) ;
268
- network_graph . channel_failed ( short_channel_id, is_permanent) ;
265
+ log_debug ! ( self . logger, "{} channel graph entry for {} due to a payment failure." , action, short_channel_id) ;
266
+ self . channel_failed ( short_channel_id, is_permanent) ;
269
267
} ,
270
268
NetworkUpdate :: NodeFailure { ref node_id, is_permanent } => {
271
269
let action = if is_permanent { "Removing" } else { "Disabling" } ;
272
- log_debug ! ( logger, "{} node graph entry for {} due to a payment failure." , action, node_id) ;
273
- network_graph . node_failed ( node_id, is_permanent) ;
270
+ log_debug ! ( self . logger, "{} node graph entry for {} due to a payment failure." , action, node_id) ;
271
+ self . node_failed ( node_id, is_permanent) ;
274
272
} ,
275
273
}
276
274
}
@@ -984,7 +982,7 @@ impl<L: Deref> Writeable for NetworkGraph<L> where L::Target: Logger {
984
982
}
985
983
986
984
impl < L : Deref > ReadableArgs < L > for NetworkGraph < L > where L :: Target : Logger {
987
- fn read < R : io:: Read > ( reader : & mut R , _logger : L ) -> Result < NetworkGraph < L > , DecodeError > {
985
+ fn read < R : io:: Read > ( reader : & mut R , logger : L ) -> Result < NetworkGraph < L > , DecodeError > {
988
986
let _ver = read_ver_prefix ! ( reader, SERIALIZATION_VERSION ) ;
989
987
990
988
let genesis_hash: BlockHash = Readable :: read ( reader) ?;
@@ -1011,7 +1009,7 @@ impl<L: Deref> ReadableArgs<L> for NetworkGraph<L> where L::Target: Logger {
1011
1009
Ok ( NetworkGraph {
1012
1010
secp_ctx : Secp256k1 :: verification_only ( ) ,
1013
1011
genesis_hash,
1014
- _logger ,
1012
+ logger ,
1015
1013
channels : RwLock :: new ( channels) ,
1016
1014
nodes : RwLock :: new ( nodes) ,
1017
1015
last_rapid_gossip_sync_timestamp : Mutex :: new ( last_rapid_gossip_sync_timestamp) ,
@@ -1043,11 +1041,11 @@ impl<L: Deref> PartialEq for NetworkGraph<L> where L::Target: Logger {
1043
1041
1044
1042
impl < L : Deref > NetworkGraph < L > where L :: Target : Logger {
1045
1043
/// Creates a new, empty, network graph.
1046
- pub fn new ( genesis_hash : BlockHash , _logger : L ) -> NetworkGraph < L > {
1044
+ pub fn new ( genesis_hash : BlockHash , logger : L ) -> NetworkGraph < L > {
1047
1045
Self {
1048
1046
secp_ctx : Secp256k1 :: verification_only ( ) ,
1049
1047
genesis_hash,
1050
- _logger ,
1048
+ logger ,
1051
1049
channels : RwLock :: new ( BTreeMap :: new ( ) ) ,
1052
1050
nodes : RwLock :: new ( BTreeMap :: new ( ) ) ,
1053
1051
last_rapid_gossip_sync_timestamp : Mutex :: new ( None ) ,
@@ -2054,7 +2052,6 @@ mod tests {
2054
2052
let genesis_hash = genesis_block ( Network :: Testnet ) . header . block_hash ( ) ;
2055
2053
let network_graph = NetworkGraph :: new ( genesis_hash, & logger) ;
2056
2054
let secp_ctx = Secp256k1 :: new ( ) ;
2057
- let event_handler = ( & & network_graph, & & logger) ;
2058
2055
2059
2056
let node_1_privkey = & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ;
2060
2057
let node_2_privkey = & SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( ) ;
@@ -2076,7 +2073,7 @@ mod tests {
2076
2073
let valid_channel_update = get_signed_channel_update ( |_| { } , node_1_privkey, & secp_ctx) ;
2077
2074
assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
2078
2075
2079
- event_handler . handle_event ( & Event :: PaymentPathFailed {
2076
+ network_graph . handle_event ( & Event :: PaymentPathFailed {
2080
2077
payment_id : None ,
2081
2078
payment_hash : PaymentHash ( [ 0 ; 32 ] ) ,
2082
2079
rejected_by_dest : false ,
@@ -2103,7 +2100,7 @@ mod tests {
2103
2100
}
2104
2101
} ;
2105
2102
2106
- event_handler . handle_event ( & Event :: PaymentPathFailed {
2103
+ network_graph . handle_event ( & Event :: PaymentPathFailed {
2107
2104
payment_id : None ,
2108
2105
payment_hash : PaymentHash ( [ 0 ; 32 ] ) ,
2109
2106
rejected_by_dest : false ,
@@ -2128,7 +2125,7 @@ mod tests {
2128
2125
}
2129
2126
2130
2127
// Permanent closing deletes a channel
2131
- event_handler . handle_event ( & Event :: PaymentPathFailed {
2128
+ network_graph . handle_event ( & Event :: PaymentPathFailed {
2132
2129
payment_id : None ,
2133
2130
payment_hash : PaymentHash ( [ 0 ; 32 ] ) ,
2134
2131
rejected_by_dest : false ,
0 commit comments