@@ -6147,34 +6147,11 @@ where
6147
6147
}
6148
6148
}
6149
6149
6150
- /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
6151
- /// indicating whether persistence is necessary. Only one listener on
6152
- /// [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by
6153
- /// [`get_persistable_update_future`] is guaranteed to be woken up.
6150
+ /// Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted.
6154
6151
///
6155
- /// Note that this method is not available with the `no-std` feature.
6152
+ /// Note that callbacks registered on the [`Future`] MUST NOT call back into this
6153
+ /// [`ChannelManager`] and should instead register actions to be taken later.
6156
6154
///
6157
- /// [`await_persistable_update`]: Self::await_persistable_update
6158
- /// [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout
6159
- /// [`get_persistable_update_future`]: Self::get_persistable_update_future
6160
- #[ cfg( any( test, feature = "std" ) ) ]
6161
- pub fn await_persistable_update_timeout ( & self , max_wait : Duration ) -> bool {
6162
- self . persistence_notifier . wait_timeout ( max_wait)
6163
- }
6164
-
6165
- /// Blocks until ChannelManager needs to be persisted. Only one listener on
6166
- /// [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by
6167
- /// [`get_persistable_update_future`] is guaranteed to be woken up.
6168
- ///
6169
- /// [`await_persistable_update`]: Self::await_persistable_update
6170
- /// [`get_persistable_update_future`]: Self::get_persistable_update_future
6171
- pub fn await_persistable_update ( & self ) {
6172
- self . persistence_notifier . wait ( )
6173
- }
6174
-
6175
- /// Gets a [`Future`] that completes when a persistable update is available. Note that
6176
- /// callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
6177
- /// should instead register actions to be taken later.
6178
6155
pub fn get_persistable_update_future ( & self ) -> Future {
6179
6156
self . persistence_notifier . get_future ( )
6180
6157
}
@@ -7954,9 +7931,9 @@ mod tests {
7954
7931
7955
7932
// All nodes start with a persistable update pending as `create_network` connects each node
7956
7933
// with all other nodes to make most tests simpler.
7957
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7958
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7959
- assert ! ( nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7934
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7935
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7936
+ assert ! ( nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7960
7937
7961
7938
let mut chan = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
7962
7939
@@ -7970,28 +7947,28 @@ mod tests {
7970
7947
& nodes[ 0 ] . node . get_our_node_id ( ) ) . pop ( ) . unwrap ( ) ;
7971
7948
7972
7949
// The first two nodes (which opened a channel) should now require fresh persistence
7973
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7974
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7950
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7951
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7975
7952
// ... but the last node should not.
7976
- assert ! ( !nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7953
+ assert ! ( !nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7977
7954
// After persisting the first two nodes they should no longer need fresh persistence.
7978
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7979
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7955
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7956
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7980
7957
7981
7958
// Node 3, unrelated to the only channel, shouldn't care if it receives a channel_update
7982
7959
// about the channel.
7983
7960
nodes[ 2 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7984
7961
nodes[ 2 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7985
- assert ! ( !nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7962
+ assert ! ( !nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7986
7963
7987
7964
// The nodes which are a party to the channel should also ignore messages from unrelated
7988
7965
// parties.
7989
7966
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7990
7967
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7991
7968
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7992
7969
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7993
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7994
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7970
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7971
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7995
7972
7996
7973
// At this point the channel info given by peers should still be the same.
7997
7974
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
@@ -8008,17 +7985,17 @@ mod tests {
8008
7985
// persisted and that its channel info remains the same.
8009
7986
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_update) ;
8010
7987
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 0 ] . node . get_our_node_id ( ) , & bs_update) ;
8011
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
8012
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7988
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7989
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
8013
7990
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
8014
7991
assert_eq ! ( nodes[ 1 ] . node. list_channels( ) [ 0 ] , node_b_chan_info) ;
8015
7992
8016
7993
// Finally, deliver the other peers' message, ensuring each node needs to be persisted and
8017
7994
// the channel info has updated.
8018
7995
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_update) ;
8019
7996
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 0 ] . node . get_our_node_id ( ) , & as_update) ;
8020
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
8021
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7997
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7998
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
8022
7999
assert_ne ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
8023
8000
assert_ne ! ( nodes[ 1 ] . node. list_channels( ) [ 0 ] , node_b_chan_info) ;
8024
8001
}
0 commit comments