@@ -46,7 +46,7 @@ use std::collections::{HashMap, hash_map, HashSet};
4646use std:: io:: Cursor ;
4747use std:: sync:: { Arc , Mutex , MutexGuard , RwLock } ;
4848use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
49- use std:: time:: { Instant , Duration } ;
49+ use std:: time:: Duration ;
5050
5151// We hold various information about HTLC relay in the HTLC objects in Channel itself:
5252//
@@ -247,7 +247,6 @@ pub(super) enum RAACommitmentOrder {
247247pub ( super ) struct ChannelHolder {
248248 pub ( super ) by_id : HashMap < [ u8 ; 32 ] , Channel > ,
249249 pub ( super ) short_to_id : HashMap < u64 , [ u8 ; 32 ] > ,
250- pub ( super ) next_forward : Instant ,
251250 /// short channel id -> forward infos. Key of 0 means payments received
252251 /// Note that while this is held in the same mutex as the channels themselves, no consistency
253252 /// guarantees are made about the existence of a channel with the short id here, nor the short
@@ -266,7 +265,6 @@ pub(super) struct ChannelHolder {
266265pub ( super ) struct MutChannelHolder < ' a > {
267266 pub ( super ) by_id : & ' a mut HashMap < [ u8 ; 32 ] , Channel > ,
268267 pub ( super ) short_to_id : & ' a mut HashMap < u64 , [ u8 ; 32 ] > ,
269- pub ( super ) next_forward : & ' a mut Instant ,
270268 pub ( super ) forward_htlcs : & ' a mut HashMap < u64 , Vec < HTLCForwardInfo > > ,
271269 pub ( super ) claimable_htlcs : & ' a mut HashMap < PaymentHash , Vec < ( u64 , HTLCPreviousHopData ) > > ,
272270 pub ( super ) pending_msg_events : & ' a mut Vec < events:: MessageSendEvent > ,
@@ -276,7 +274,6 @@ impl ChannelHolder {
276274 MutChannelHolder {
277275 by_id : & mut self . by_id ,
278276 short_to_id : & mut self . short_to_id ,
279- next_forward : & mut self . next_forward ,
280277 forward_htlcs : & mut self . forward_htlcs ,
281278 claimable_htlcs : & mut self . claimable_htlcs ,
282279 pending_msg_events : & mut self . pending_msg_events ,
@@ -549,7 +546,6 @@ impl ChannelManager {
549546 channel_state : Mutex :: new ( ChannelHolder {
550547 by_id : HashMap :: new ( ) ,
551548 short_to_id : HashMap :: new ( ) ,
552- next_forward : Instant :: now ( ) ,
553549 forward_htlcs : HashMap :: new ( ) ,
554550 claimable_htlcs : HashMap :: new ( ) ,
555551 pending_msg_events : Vec :: new ( ) ,
@@ -1184,10 +1180,6 @@ impl ChannelManager {
11841180 let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
11851181 let channel_state = channel_state_lock. borrow_parts ( ) ;
11861182
1187- if cfg ! ( not( feature = "fuzztarget" ) ) && Instant :: now ( ) < * channel_state. next_forward {
1188- return ;
1189- }
1190-
11911183 for ( short_chan_id, mut pending_forwards) in channel_state. forward_htlcs . drain ( ) {
11921184 if short_chan_id != 0 {
11931185 let forward_chan_id = match channel_state. short_to_id . get ( & short_chan_id) {
@@ -1467,8 +1459,7 @@ impl ChannelManager {
14671459
14681460 let mut forward_event = None ;
14691461 if channel_state_lock. forward_htlcs . is_empty ( ) {
1470- forward_event = Some ( Instant :: now ( ) + Duration :: from_millis ( ( ( rng:: rand_f32 ( ) * 4.0 + 1.0 ) * MIN_HTLC_RELAY_HOLDING_CELL_MILLIS as f32 ) as u64 ) ) ;
1471- channel_state_lock. next_forward = forward_event. unwrap ( ) ;
1462+ forward_event = Some ( Duration :: from_millis ( ( ( rng:: rand_f32 ( ) * 4.0 + 1.0 ) * MIN_HTLC_RELAY_HOLDING_CELL_MILLIS as f32 ) as u64 ) ) ;
14721463 }
14731464 match channel_state_lock. forward_htlcs . entry ( short_channel_id) {
14741465 hash_map:: Entry :: Occupied ( mut entry) => {
@@ -2077,8 +2068,7 @@ impl ChannelManager {
20772068 if !pending_forwards. is_empty ( ) {
20782069 let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
20792070 if channel_state. forward_htlcs . is_empty ( ) {
2080- forward_event = Some ( Instant :: now ( ) + Duration :: from_millis ( ( ( rng:: rand_f32 ( ) * 4.0 + 1.0 ) * MIN_HTLC_RELAY_HOLDING_CELL_MILLIS as f32 ) as u64 ) ) ;
2081- channel_state. next_forward = forward_event. unwrap ( ) ;
2071+ forward_event = Some ( Duration :: from_millis ( ( ( rng:: rand_f32 ( ) * 4.0 + 1.0 ) * MIN_HTLC_RELAY_HOLDING_CELL_MILLIS as f32 ) as u64 ) ) ;
20822072 }
20832073 for ( forward_info, prev_htlc_id) in pending_forwards. drain ( ..) {
20842074 match channel_state. forward_htlcs . entry ( forward_info. short_channel_id ) {
@@ -3087,7 +3077,6 @@ impl<'a, R : ::std::io::Read> ReadableArgs<R, ChannelManagerReadArgs<'a>> for (S
30873077 channel_state : Mutex :: new ( ChannelHolder {
30883078 by_id,
30893079 short_to_id,
3090- next_forward : Instant :: now ( ) ,
30913080 forward_htlcs,
30923081 claimable_htlcs,
30933082 pending_msg_events : Vec :: new ( ) ,
0 commit comments