@@ -449,7 +449,7 @@ where
449449///
450450/// # Size-based persistence optimization
451451///
452- /// For small channel monitors (below `minimum_monitor_size_for_updates ` bytes when serialized),
452+ /// For small channel monitors (below `min_monitor_size_for_updates_bytes ` bytes when serialized),
453453/// this persister will always write the full monitor instead of individual updates. This avoids
454454/// the overhead of managing update files and later compaction for tiny monitors that don't benefit
455455/// from differential updates.
@@ -465,7 +465,7 @@ where
465465 kv_store : K ,
466466 logger : L ,
467467 maximum_pending_updates : u64 ,
468- minimum_monitor_size_for_updates : usize ,
468+ min_monitor_size_for_updates_bytes : usize ,
469469 entropy_source : ES ,
470470 signer_provider : SP ,
471471 broadcaster : BI ,
@@ -483,7 +483,7 @@ where
483483 BI :: Target : BroadcasterInterface ,
484484 FE :: Target : FeeEstimator ,
485485{
486- /// Constructs a new [`MonitorUpdatingPersister`].
486+ /// Constructs a new [`MonitorUpdatingPersister`] with a default minimum monitor size threshold .
487487 ///
488488 /// The `maximum_pending_updates` parameter controls how many updates may be stored before a
489489 /// [`MonitorUpdatingPersister`] consolidates updates by writing a full monitor. Note that
@@ -500,49 +500,49 @@ where
500500 /// - [`MonitorUpdatingPersister`] will potentially have more listing to do if you need to run
501501 /// [`MonitorUpdatingPersister::cleanup_stale_updates`].
502502 ///
503- /// The `minimum_monitor_size_for_updates` parameter sets the minimum serialized size (in bytes)
504- /// for a [`ChannelMonitor`] to use update-based persistence. Monitors smaller than this threshold
505- /// will always be persisted in full, avoiding the overhead of managing update files for tiny
506- /// monitors. A reasonable default is 4096 bytes (4 KiB). Set to 0 to always use update-based
507- /// persistence regardless of size.
503+ /// This sets `min_monitor_size_for_updates_bytes` to 4096 bytes (4 KiB), which is a reasonable
504+ /// 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`]
506+ /// if you need a custom threshold.
508507 pub fn new (
509- kv_store : K , logger : L , maximum_pending_updates : u64 ,
510- minimum_monitor_size_for_updates : usize , entropy_source : ES , signer_provider : SP ,
511- broadcaster : BI , fee_estimator : FE ,
508+ kv_store : K , logger : L , maximum_pending_updates : u64 , entropy_source : ES ,
509+ signer_provider : SP , broadcaster : BI , fee_estimator : FE ,
512510 ) -> Self {
513- MonitorUpdatingPersister {
511+ Self :: new_with_monitor_size_threshold (
514512 kv_store,
515513 logger,
516514 maximum_pending_updates,
517- minimum_monitor_size_for_updates ,
515+ 4096 ,
518516 entropy_source,
519517 signer_provider,
520518 broadcaster,
521519 fee_estimator,
522- }
520+ )
523521 }
524522
525- /// Constructs a new [`MonitorUpdatingPersister`] with a default minimum monitor size threshold.
523+ /// Constructs a new [`MonitorUpdatingPersister`] with a custom minimum monitor size threshold.
526524 ///
527- /// This is a convenience method that sets `minimum_monitor_size_for_updates` to 4096 bytes (4 KiB),
528- /// which is a reasonable default for most use cases. Monitors smaller than this will be persisted
529- /// in full rather than using update-based persistence.
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.
530529 ///
531530 /// For other parameters, see [`MonitorUpdatingPersister::new`].
532- pub fn new_with_default_threshold (
533- kv_store : K , logger : L , maximum_pending_updates : u64 , entropy_source : ES ,
534- signer_provider : SP , broadcaster : BI , fee_estimator : FE ,
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 ,
535535 ) -> Self {
536- Self :: new (
536+ MonitorUpdatingPersister {
537537 kv_store,
538538 logger,
539539 maximum_pending_updates,
540- 4096 ,
540+ min_monitor_size_for_updates_bytes ,
541541 entropy_source,
542542 signer_provider,
543543 broadcaster,
544544 fee_estimator,
545- )
545+ }
546546 }
547547
548548 /// Reads all stored channel monitors, along with any stored updates for them.
@@ -793,7 +793,7 @@ where
793793 if let Some ( update) = update {
794794 // Check if monitor is too small for update-based persistence
795795 let monitor_size = monitor. serialized_length ( ) ;
796- let use_full_persistence = monitor_size < self . minimum_monitor_size_for_updates ;
796+ let use_full_persistence = monitor_size < self . min_monitor_size_for_updates_bytes ;
797797
798798 let persist_update = !use_full_persistence
799799 && update. update_id != LEGACY_CLOSED_CHANNEL_UPDATE_ID
@@ -1200,7 +1200,7 @@ mod tests {
12001200 kv_store : & TestStore :: new ( false ) ,
12011201 logger : & TestLogger :: new ( ) ,
12021202 maximum_pending_updates : persister_0_max_pending_updates,
1203- minimum_monitor_size_for_updates : 0 ,
1203+ min_monitor_size_for_updates_bytes : 0 ,
12041204 entropy_source : & chanmon_cfgs[ 0 ] . keys_manager ,
12051205 signer_provider : & chanmon_cfgs[ 0 ] . keys_manager ,
12061206 broadcaster : & chanmon_cfgs[ 0 ] . tx_broadcaster ,
@@ -1210,7 +1210,7 @@ mod tests {
12101210 kv_store : & TestStore :: new ( false ) ,
12111211 logger : & TestLogger :: new ( ) ,
12121212 maximum_pending_updates : persister_1_max_pending_updates,
1213- minimum_monitor_size_for_updates : 0 ,
1213+ min_monitor_size_for_updates_bytes : 0 ,
12141214 entropy_source : & chanmon_cfgs[ 1 ] . keys_manager ,
12151215 signer_provider : & chanmon_cfgs[ 1 ] . keys_manager ,
12161216 broadcaster : & chanmon_cfgs[ 1 ] . tx_broadcaster ,
@@ -1376,7 +1376,7 @@ mod tests {
13761376 kv_store : & TestStore :: new ( true ) ,
13771377 logger : & TestLogger :: new ( ) ,
13781378 maximum_pending_updates : 11 ,
1379- minimum_monitor_size_for_updates : 0 ,
1379+ min_monitor_size_for_updates_bytes : 0 ,
13801380 entropy_source : node_cfgs[ 0 ] . keys_manager ,
13811381 signer_provider : node_cfgs[ 0 ] . keys_manager ,
13821382 broadcaster : node_cfgs[ 0 ] . tx_broadcaster ,
@@ -1423,7 +1423,7 @@ mod tests {
14231423 kv_store : & TestStore :: new ( false ) ,
14241424 logger : & TestLogger :: new ( ) ,
14251425 maximum_pending_updates : test_max_pending_updates,
1426- minimum_monitor_size_for_updates : 0 ,
1426+ min_monitor_size_for_updates_bytes : 0 ,
14271427 entropy_source : & chanmon_cfgs[ 0 ] . keys_manager ,
14281428 signer_provider : & chanmon_cfgs[ 0 ] . keys_manager ,
14291429 broadcaster : & chanmon_cfgs[ 0 ] . tx_broadcaster ,
@@ -1433,7 +1433,7 @@ mod tests {
14331433 kv_store : & TestStore :: new ( false ) ,
14341434 logger : & TestLogger :: new ( ) ,
14351435 maximum_pending_updates : test_max_pending_updates,
1436- minimum_monitor_size_for_updates : 0 ,
1436+ min_monitor_size_for_updates_bytes : 0 ,
14371437 entropy_source : & chanmon_cfgs[ 1 ] . keys_manager ,
14381438 signer_provider : & chanmon_cfgs[ 1 ] . keys_manager ,
14391439 broadcaster : & chanmon_cfgs[ 1 ] . tx_broadcaster ,
@@ -1512,7 +1512,7 @@ mod tests {
15121512 kv_store : & TestStore :: new ( false ) ,
15131513 logger : & TestLogger :: new ( ) ,
15141514 maximum_pending_updates : 5 ,
1515- minimum_monitor_size_for_updates : 100_000 , // 100KB threshold - way larger than any monitor
1515+ min_monitor_size_for_updates_bytes : 100_000 , // 100KB threshold - way larger than any monitor
15161516 entropy_source : & chanmon_cfgs[ 0 ] . keys_manager ,
15171517 signer_provider : & chanmon_cfgs[ 0 ] . keys_manager ,
15181518 broadcaster : & chanmon_cfgs[ 0 ] . tx_broadcaster ,
@@ -1525,7 +1525,7 @@ mod tests {
15251525 kv_store : & TestStore :: new ( false ) ,
15261526 logger : & TestLogger :: new ( ) ,
15271527 maximum_pending_updates : 5 ,
1528- minimum_monitor_size_for_updates : 0 , // 0 byte threshold - allows all monitors to use updates
1528+ min_monitor_size_for_updates_bytes : 0 , // 0 byte threshold - allows all monitors to use updates
15291529 entropy_source : & chanmon_cfgs[ 1 ] . keys_manager ,
15301530 signer_provider : & chanmon_cfgs[ 1 ] . keys_manager ,
15311531 broadcaster : & chanmon_cfgs[ 1 ] . tx_broadcaster ,
0 commit comments