@@ -6086,34 +6086,11 @@ where
6086
6086
}
6087
6087
}
6088
6088
6089
- /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
6090
- /// indicating whether persistence is necessary. Only one listener on
6091
- /// [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by
6092
- /// [`get_persistable_update_future`] is guaranteed to be woken up.
6089
+ /// Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted.
6093
6090
///
6094
- /// Note that this method is not available with the `no-std` feature.
6091
+ /// Note that callbacks registered on the [`Future`] MUST NOT call back into this
6092
+ /// [`ChannelManager`] and should instead register actions to be taken later.
6095
6093
///
6096
- /// [`await_persistable_update`]: Self::await_persistable_update
6097
- /// [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout
6098
- /// [`get_persistable_update_future`]: Self::get_persistable_update_future
6099
- #[ cfg( any( test, feature = "std" ) ) ]
6100
- pub fn await_persistable_update_timeout ( & self , max_wait : Duration ) -> bool {
6101
- self . persistence_notifier . wait_timeout ( max_wait)
6102
- }
6103
-
6104
- /// Blocks until ChannelManager needs to be persisted. Only one listener on
6105
- /// [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by
6106
- /// [`get_persistable_update_future`] is guaranteed to be woken up.
6107
- ///
6108
- /// [`await_persistable_update`]: Self::await_persistable_update
6109
- /// [`get_persistable_update_future`]: Self::get_persistable_update_future
6110
- pub fn await_persistable_update ( & self ) {
6111
- self . persistence_notifier . wait ( )
6112
- }
6113
-
6114
- /// Gets a [`Future`] that completes when a persistable update is available. Note that
6115
- /// callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
6116
- /// should instead register actions to be taken later.
6117
6094
pub fn get_persistable_update_future ( & self ) -> Future {
6118
6095
self . persistence_notifier . get_future ( )
6119
6096
}
@@ -7870,9 +7847,9 @@ mod tests {
7870
7847
7871
7848
// All nodes start with a persistable update pending as `create_network` connects each node
7872
7849
// with all other nodes to make most tests simpler.
7873
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7874
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7875
- assert ! ( nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7850
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7851
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7852
+ assert ! ( nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7876
7853
7877
7854
let mut chan = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
7878
7855
@@ -7886,28 +7863,28 @@ mod tests {
7886
7863
& nodes[ 0 ] . node . get_our_node_id ( ) ) . pop ( ) . unwrap ( ) ;
7887
7864
7888
7865
// The first two nodes (which opened a channel) should now require fresh persistence
7889
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7890
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7866
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7867
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7891
7868
// ... but the last node should not.
7892
- assert ! ( !nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7869
+ assert ! ( !nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7893
7870
// After persisting the first two nodes they should no longer need fresh persistence.
7894
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7895
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7871
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7872
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7896
7873
7897
7874
// Node 3, unrelated to the only channel, shouldn't care if it receives a channel_update
7898
7875
// about the channel.
7899
7876
nodes[ 2 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7900
7877
nodes[ 2 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7901
- assert ! ( !nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7878
+ assert ! ( !nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7902
7879
7903
7880
// The nodes which are a party to the channel should also ignore messages from unrelated
7904
7881
// parties.
7905
7882
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7906
7883
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7907
7884
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7908
7885
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7909
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7910
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7886
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7887
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7911
7888
7912
7889
// At this point the channel info given by peers should still be the same.
7913
7890
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
@@ -7924,17 +7901,17 @@ mod tests {
7924
7901
// persisted and that its channel info remains the same.
7925
7902
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_update) ;
7926
7903
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 0 ] . node . get_our_node_id ( ) , & bs_update) ;
7927
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7928
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7904
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7905
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7929
7906
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
7930
7907
assert_eq ! ( nodes[ 1 ] . node. list_channels( ) [ 0 ] , node_b_chan_info) ;
7931
7908
7932
7909
// Finally, deliver the other peers' message, ensuring each node needs to be persisted and
7933
7910
// the channel info has updated.
7934
7911
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_update) ;
7935
7912
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 0 ] . node . get_our_node_id ( ) , & as_update) ;
7936
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7937
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7913
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7914
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7938
7915
assert_ne ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
7939
7916
assert_ne ! ( nodes[ 1 ] . node. list_channels( ) [ 0 ] , node_b_chan_info) ;
7940
7917
}
0 commit comments