@@ -98,6 +98,9 @@ pub const OUTPUT_SWEEPER_PERSISTENCE_KEY: &str = "output_sweeper";
9898/// updates applied to be current) with another implementation.
9999pub const MONITOR_UPDATING_PERSISTER_PREPEND_SENTINEL : & [ u8 ] = & [ 0xFF ; 2 ] ;
100100
101+ /// The default size of monitor where persistence is switched to update based.
102+ pub const DEFAULT_MONITOR_SIZE_FOR_UPDATES_BYTES : usize = 8192 ;
103+
101104/// Provides an interface that allows storage and retrieval of persisted values that are associated
102105/// with given keys.
103106///
@@ -502,42 +505,19 @@ where
502505 ///
503506 /// This sets `min_monitor_size_for_updates_bytes` to 8192 bytes (8 KiB), which is a reasonable
504507 /// default for most use cases. Monitors smaller than this will be persisted in full rather than
505- /// using update-based persistence. Use [`MonitorUpdatingPersister::new_with_monitor_size_threshold`]
508+ /// using update-based persistence. Pass a custom value for `min_monitor_size_for_updates_bytes`
506509 /// if you need a custom threshold.
507510 pub fn new (
508511 kv_store : K , logger : L , maximum_pending_updates : u64 , entropy_source : ES ,
509512 signer_provider : SP , broadcaster : BI , fee_estimator : FE ,
510- ) -> Self {
511- Self :: new_with_monitor_size_threshold (
512- kv_store,
513- logger,
514- maximum_pending_updates,
515- 8192 ,
516- entropy_source,
517- signer_provider,
518- broadcaster,
519- fee_estimator,
520- )
521- }
522-
523- /// Constructs a new [`MonitorUpdatingPersister`] with a custom minimum monitor size threshold.
524- ///
525- /// The `min_monitor_size_for_updates_bytes` parameter sets the minimum serialized size (in bytes)
526- /// for a [`ChannelMonitor`] to use update-based persistence. Monitors smaller than this threshold
527- /// will always be persisted in full, avoiding the overhead of managing update files for tiny
528- /// monitors. Set to 0 to always use update-based persistence regardless of size.
529- ///
530- /// For other parameters, see [`MonitorUpdatingPersister::new`].
531- pub fn new_with_monitor_size_threshold (
532- kv_store : K , logger : L , maximum_pending_updates : u64 ,
533- min_monitor_size_for_updates_bytes : usize , entropy_source : ES , signer_provider : SP ,
534- broadcaster : BI , fee_estimator : FE ,
513+ min_monitor_size_for_updates_bytes : Option < usize > ,
535514 ) -> Self {
536515 MonitorUpdatingPersister {
537516 kv_store,
538517 logger,
539518 maximum_pending_updates,
540- min_monitor_size_for_updates_bytes,
519+ min_monitor_size_for_updates_bytes : min_monitor_size_for_updates_bytes
520+ . unwrap_or ( DEFAULT_MONITOR_SIZE_FOR_UPDATES_BYTES ) ,
541521 entropy_source,
542522 signer_provider,
543523 broadcaster,
@@ -1433,21 +1413,25 @@ mod tests {
14331413 & chanmon_cfgs[ 0 ] . keys_manager ,
14341414 & chanmon_cfgs[ 0 ] . tx_broadcaster ,
14351415 & chanmon_cfgs[ 0 ] . fee_estimator ,
1416+ None ,
14361417 ) ;
14371418 // Test the custom threshold constructor with zero threshold
1438- let persister_1 = MonitorUpdatingPersister :: new_with_monitor_size_threshold (
1419+ let persister_1 = MonitorUpdatingPersister :: new (
14391420 & store_1,
14401421 & logger_1,
14411422 test_max_pending_updates,
1442- 0 , // 0 byte threshold for maximum update usage
14431423 & chanmon_cfgs[ 1 ] . keys_manager ,
14441424 & chanmon_cfgs[ 1 ] . keys_manager ,
14451425 & chanmon_cfgs[ 1 ] . tx_broadcaster ,
14461426 & chanmon_cfgs[ 1 ] . fee_estimator ,
1427+ Some ( 0 ) , // 0 byte threshold for maximum update usage
14471428 ) ;
14481429
14491430 // Verify the constructors set the thresholds correctly
1450- assert_eq ! ( persister_0. min_monitor_size_for_updates_bytes, 8192 ) ;
1431+ assert_eq ! (
1432+ persister_0. min_monitor_size_for_updates_bytes,
1433+ DEFAULT_MONITOR_SIZE_FOR_UPDATES_BYTES
1434+ ) ;
14511435 assert_eq ! ( persister_1. min_monitor_size_for_updates_bytes, 0 ) ;
14521436 let mut node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
14531437 let chain_mon_0 = test_utils:: TestChainMonitor :: new (
@@ -1521,30 +1505,30 @@ mod tests {
15211505
15221506 // Create a persister with a huge minimum size threshold (100KB)
15231507 // This should force all monitors to use full persistence instead of updates
1524- // Test the new_with_monitor_size_threshold constructor with large threshold
1525- let large_threshold_persister = MonitorUpdatingPersister :: new_with_monitor_size_threshold (
1508+ // Test the new constructor with large threshold
1509+ let large_threshold_persister = MonitorUpdatingPersister :: new (
15261510 & store_0,
15271511 & logger_0,
15281512 5 ,
1529- 100_000 ,
15301513 & chanmon_cfgs[ 0 ] . keys_manager ,
15311514 & chanmon_cfgs[ 0 ] . keys_manager ,
15321515 & chanmon_cfgs[ 0 ] . tx_broadcaster ,
15331516 & chanmon_cfgs[ 0 ] . fee_estimator ,
1517+ Some ( 100_000 ) ,
15341518 ) ;
15351519
15361520 // Create a persister with zero minimum size threshold
15371521 // This should allow all monitors to use update-based persistence
1538- // Test the new_with_monitor_size_threshold constructor with zero threshold
1539- let small_threshold_persister = MonitorUpdatingPersister :: new_with_monitor_size_threshold (
1522+ // Test the new constructor with zero threshold
1523+ let small_threshold_persister = MonitorUpdatingPersister :: new (
15401524 & store_1,
15411525 & logger_1,
15421526 5 ,
1543- 0 , // allows all monitors to use updates
15441527 & chanmon_cfgs[ 1 ] . keys_manager ,
15451528 & chanmon_cfgs[ 1 ] . keys_manager ,
15461529 & chanmon_cfgs[ 1 ] . tx_broadcaster ,
15471530 & chanmon_cfgs[ 1 ] . fee_estimator ,
1531+ Some ( 0 ) , // allows all monitors to use updates
15481532 ) ;
15491533
15501534 // Verify the constructors set the thresholds correctly
0 commit comments