@@ -58,6 +58,11 @@ pub const CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
58
58
/// The primary namespace under which [`ChannelMonitorUpdate`]s will be persisted.
59
59
pub const CHANNEL_MONITOR_UPDATE_PERSISTENCE_PRIMARY_NAMESPACE : & str = "monitor_updates" ;
60
60
61
+ /// The primary namespace under which [`ChannelMonitor`]s will be persisted.
62
+ pub const PRUNED_CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE : & str = "pruned_monitors" ;
63
+ /// The secondary namespace under which [`ChannelMonitor`]s will be persisted.
64
+ pub const PRUNED_CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE : & str = "" ;
65
+
61
66
/// The primary namespace under which the [`NetworkGraph`] will be persisted.
62
67
pub const NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE : & str = "" ;
63
68
/// The secondary namespace under which the [`NetworkGraph`] will be persisted.
@@ -241,6 +246,18 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner, K: KVStore> Persist<ChannelSign
241
246
Err ( _) => chain:: ChannelMonitorUpdateStatus :: UnrecoverableError
242
247
}
243
248
}
249
+
250
+ fn prune_persisted_channel ( & self , funding_txo : OutPoint ) -> bool {
251
+ let key = format ! ( "{}_{}" , funding_txo. txid. to_string( ) , funding_txo. index) ;
252
+ match self . remove (
253
+ CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE ,
254
+ CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE ,
255
+ & key, false )
256
+ {
257
+ Ok ( ( ) ) => true ,
258
+ Err ( _) => false
259
+ }
260
+ }
244
261
}
245
262
246
263
impl < ChannelSigner : WriteableEcdsaChannelSigner > Persist < ChannelSigner > for dyn KVStore + Send + Sync {
@@ -272,6 +289,18 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> Persist<ChannelSigner> for dyn
272
289
Err ( _) => chain:: ChannelMonitorUpdateStatus :: UnrecoverableError
273
290
}
274
291
}
292
+
293
+ fn prune_persisted_channel ( & self , funding_txo : OutPoint ) -> bool {
294
+ let key = format ! ( "{}_{}" , funding_txo. txid. to_string( ) , funding_txo. index) ;
295
+ match self . remove (
296
+ CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE ,
297
+ CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE ,
298
+ & key, false )
299
+ {
300
+ Ok ( ( ) ) => true ,
301
+ Err ( _) => false
302
+ }
303
+ }
275
304
}
276
305
277
306
/// Read previously persisted [`ChannelMonitor`]s from the store.
@@ -778,6 +807,29 @@ where
778
807
self . persist_new_channel ( funding_txo, monitor, monitor_update_call_id)
779
808
}
780
809
}
810
+
811
+ fn prune_persisted_channel ( & self , funding_txo : OutPoint ) -> bool {
812
+ let monitor_name = MonitorName :: from ( funding_txo) ;
813
+ match self . kv_store . remove (
814
+ CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE ,
815
+ CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE ,
816
+ monitor_name. as_str ( ) ,
817
+ false ,
818
+ ) {
819
+ Ok ( ( ) ) => true ,
820
+ Err ( e) => {
821
+ log_error ! (
822
+ self . logger,
823
+ "Failed to remove ChannelMonitor {}/{}/{} reason: {}" ,
824
+ CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE ,
825
+ CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE ,
826
+ monitor_name. as_str( ) ,
827
+ e
828
+ ) ;
829
+ false
830
+ }
831
+ }
832
+ }
781
833
}
782
834
783
835
impl < K : Deref , L : Deref , ES : Deref , SP : Deref > MonitorUpdatingPersister < K , L , ES , SP >
0 commit comments