@@ -6113,34 +6113,11 @@ where
6113
6113
}
6114
6114
}
6115
6115
6116
- /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
6117
- /// indicating whether persistence is necessary. Only one listener on
6118
- /// [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by
6119
- /// [`get_persistable_update_future`] is guaranteed to be woken up.
6116
+ /// Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted.
6120
6117
///
6121
- /// Note that this method is not available with the `no-std` feature.
6118
+ /// Note that callbacks registered on the [`Future`] MUST NOT call back into this
6119
+ /// [`ChannelManager`] and should instead register actions to be taken later.
6122
6120
///
6123
- /// [`await_persistable_update`]: Self::await_persistable_update
6124
- /// [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout
6125
- /// [`get_persistable_update_future`]: Self::get_persistable_update_future
6126
- #[ cfg( any( test, feature = "std" ) ) ]
6127
- pub fn await_persistable_update_timeout ( & self , max_wait : Duration ) -> bool {
6128
- self . persistence_notifier . wait_timeout ( max_wait)
6129
- }
6130
-
6131
- /// Blocks until ChannelManager needs to be persisted. Only one listener on
6132
- /// [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by
6133
- /// [`get_persistable_update_future`] is guaranteed to be woken up.
6134
- ///
6135
- /// [`await_persistable_update`]: Self::await_persistable_update
6136
- /// [`get_persistable_update_future`]: Self::get_persistable_update_future
6137
- pub fn await_persistable_update ( & self ) {
6138
- self . persistence_notifier . wait ( )
6139
- }
6140
-
6141
- /// Gets a [`Future`] that completes when a persistable update is available. Note that
6142
- /// callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
6143
- /// should instead register actions to be taken later.
6144
6121
pub fn get_persistable_update_future ( & self ) -> Future {
6145
6122
self . persistence_notifier . get_future ( )
6146
6123
}
@@ -7899,9 +7876,9 @@ mod tests {
7899
7876
7900
7877
// All nodes start with a persistable update pending as `create_network` connects each node
7901
7878
// with all other nodes to make most tests simpler.
7902
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7903
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7904
- assert ! ( nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7879
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7880
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7881
+ assert ! ( nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7905
7882
7906
7883
let mut chan = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
7907
7884
@@ -7915,28 +7892,28 @@ mod tests {
7915
7892
& nodes[ 0 ] . node . get_our_node_id ( ) ) . pop ( ) . unwrap ( ) ;
7916
7893
7917
7894
// The first two nodes (which opened a channel) should now require fresh persistence
7918
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7919
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7895
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7896
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7920
7897
// ... but the last node should not.
7921
- assert ! ( !nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7898
+ assert ! ( !nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7922
7899
// After persisting the first two nodes they should no longer need fresh persistence.
7923
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7924
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7900
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7901
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7925
7902
7926
7903
// Node 3, unrelated to the only channel, shouldn't care if it receives a channel_update
7927
7904
// about the channel.
7928
7905
nodes[ 2 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7929
7906
nodes[ 2 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7930
- assert ! ( !nodes[ 2 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7907
+ assert ! ( !nodes[ 2 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7931
7908
7932
7909
// The nodes which are a party to the channel should also ignore messages from unrelated
7933
7910
// parties.
7934
7911
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7935
7912
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7936
7913
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 0 ) ;
7937
7914
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 2 ] . node . get_our_node_id ( ) , & chan. 1 ) ;
7938
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7939
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7915
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7916
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7940
7917
7941
7918
// At this point the channel info given by peers should still be the same.
7942
7919
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
@@ -7953,17 +7930,17 @@ mod tests {
7953
7930
// persisted and that its channel info remains the same.
7954
7931
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_update) ;
7955
7932
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 0 ] . node . get_our_node_id ( ) , & bs_update) ;
7956
- assert ! ( !nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7957
- assert ! ( !nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7933
+ assert ! ( !nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7934
+ assert ! ( !nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7958
7935
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
7959
7936
assert_eq ! ( nodes[ 1 ] . node. list_channels( ) [ 0 ] , node_b_chan_info) ;
7960
7937
7961
7938
// Finally, deliver the other peers' message, ensuring each node needs to be persisted and
7962
7939
// the channel info has updated.
7963
7940
nodes[ 0 ] . node . handle_channel_update ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_update) ;
7964
7941
nodes[ 1 ] . node . handle_channel_update ( & nodes[ 0 ] . node . get_our_node_id ( ) , & as_update) ;
7965
- assert ! ( nodes[ 0 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7966
- assert ! ( nodes[ 1 ] . node. await_persistable_update_timeout ( Duration :: from_millis( 1 ) ) ) ;
7942
+ assert ! ( nodes[ 0 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7943
+ assert ! ( nodes[ 1 ] . node. get_persistable_update_future ( ) . wait_timeout ( Duration :: from_millis( 1 ) ) ) ;
7967
7944
assert_ne ! ( nodes[ 0 ] . node. list_channels( ) [ 0 ] , node_a_chan_info) ;
7968
7945
assert_ne ! ( nodes[ 1 ] . node. list_channels( ) [ 0 ] , node_b_chan_info) ;
7969
7946
}
0 commit comments