@@ -449,7 +449,7 @@ where
449
449
///
450
450
/// # Size-based persistence optimization
451
451
///
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),
453
453
/// this persister will always write the full monitor instead of individual updates. This avoids
454
454
/// the overhead of managing update files and later compaction for tiny monitors that don't benefit
455
455
/// from differential updates.
@@ -465,7 +465,7 @@ where
465
465
kv_store : K ,
466
466
logger : L ,
467
467
maximum_pending_updates : u64 ,
468
- minimum_monitor_size_for_updates : usize ,
468
+ min_monitor_size_for_updates_bytes : usize ,
469
469
entropy_source : ES ,
470
470
signer_provider : SP ,
471
471
broadcaster : BI ,
@@ -483,7 +483,7 @@ where
483
483
BI :: Target : BroadcasterInterface ,
484
484
FE :: Target : FeeEstimator ,
485
485
{
486
- /// Constructs a new [`MonitorUpdatingPersister`].
486
+ /// Constructs a new [`MonitorUpdatingPersister`] with a default minimum monitor size threshold .
487
487
///
488
488
/// The `maximum_pending_updates` parameter controls how many updates may be stored before a
489
489
/// [`MonitorUpdatingPersister`] consolidates updates by writing a full monitor. Note that
@@ -500,49 +500,49 @@ where
500
500
/// - [`MonitorUpdatingPersister`] will potentially have more listing to do if you need to run
501
501
/// [`MonitorUpdatingPersister::cleanup_stale_updates`].
502
502
///
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.
508
507
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 ,
512
510
) -> Self {
513
- MonitorUpdatingPersister {
511
+ Self :: new_with_monitor_size_threshold (
514
512
kv_store,
515
513
logger,
516
514
maximum_pending_updates,
517
- minimum_monitor_size_for_updates ,
515
+ 4096 ,
518
516
entropy_source,
519
517
signer_provider,
520
518
broadcaster,
521
519
fee_estimator,
522
- }
520
+ )
523
521
}
524
522
525
- /// Constructs a new [`MonitorUpdatingPersister`] with a default minimum monitor size threshold.
523
+ /// Constructs a new [`MonitorUpdatingPersister`] with a custom minimum monitor size threshold.
526
524
///
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.
530
529
///
531
530
/// 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 ,
535
535
) -> Self {
536
- Self :: new (
536
+ MonitorUpdatingPersister {
537
537
kv_store,
538
538
logger,
539
539
maximum_pending_updates,
540
- 4096 ,
540
+ min_monitor_size_for_updates_bytes ,
541
541
entropy_source,
542
542
signer_provider,
543
543
broadcaster,
544
544
fee_estimator,
545
- )
545
+ }
546
546
}
547
547
548
548
/// Reads all stored channel monitors, along with any stored updates for them.
@@ -793,7 +793,7 @@ where
793
793
if let Some ( update) = update {
794
794
// Check if monitor is too small for update-based persistence
795
795
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 ;
797
797
798
798
let persist_update = !use_full_persistence
799
799
&& update. update_id != LEGACY_CLOSED_CHANNEL_UPDATE_ID
@@ -1200,7 +1200,7 @@ mod tests {
1200
1200
kv_store : & TestStore :: new ( false ) ,
1201
1201
logger : & TestLogger :: new ( ) ,
1202
1202
maximum_pending_updates : persister_0_max_pending_updates,
1203
- minimum_monitor_size_for_updates : 0 ,
1203
+ min_monitor_size_for_updates_bytes : 0 ,
1204
1204
entropy_source : & chanmon_cfgs[ 0 ] . keys_manager ,
1205
1205
signer_provider : & chanmon_cfgs[ 0 ] . keys_manager ,
1206
1206
broadcaster : & chanmon_cfgs[ 0 ] . tx_broadcaster ,
@@ -1210,7 +1210,7 @@ mod tests {
1210
1210
kv_store : & TestStore :: new ( false ) ,
1211
1211
logger : & TestLogger :: new ( ) ,
1212
1212
maximum_pending_updates : persister_1_max_pending_updates,
1213
- minimum_monitor_size_for_updates : 0 ,
1213
+ min_monitor_size_for_updates_bytes : 0 ,
1214
1214
entropy_source : & chanmon_cfgs[ 1 ] . keys_manager ,
1215
1215
signer_provider : & chanmon_cfgs[ 1 ] . keys_manager ,
1216
1216
broadcaster : & chanmon_cfgs[ 1 ] . tx_broadcaster ,
@@ -1376,7 +1376,7 @@ mod tests {
1376
1376
kv_store : & TestStore :: new ( true ) ,
1377
1377
logger : & TestLogger :: new ( ) ,
1378
1378
maximum_pending_updates : 11 ,
1379
- minimum_monitor_size_for_updates : 0 ,
1379
+ min_monitor_size_for_updates_bytes : 0 ,
1380
1380
entropy_source : node_cfgs[ 0 ] . keys_manager ,
1381
1381
signer_provider : node_cfgs[ 0 ] . keys_manager ,
1382
1382
broadcaster : node_cfgs[ 0 ] . tx_broadcaster ,
@@ -1423,7 +1423,7 @@ mod tests {
1423
1423
kv_store : & TestStore :: new ( false ) ,
1424
1424
logger : & TestLogger :: new ( ) ,
1425
1425
maximum_pending_updates : test_max_pending_updates,
1426
- minimum_monitor_size_for_updates : 0 ,
1426
+ min_monitor_size_for_updates_bytes : 0 ,
1427
1427
entropy_source : & chanmon_cfgs[ 0 ] . keys_manager ,
1428
1428
signer_provider : & chanmon_cfgs[ 0 ] . keys_manager ,
1429
1429
broadcaster : & chanmon_cfgs[ 0 ] . tx_broadcaster ,
@@ -1433,7 +1433,7 @@ mod tests {
1433
1433
kv_store : & TestStore :: new ( false ) ,
1434
1434
logger : & TestLogger :: new ( ) ,
1435
1435
maximum_pending_updates : test_max_pending_updates,
1436
- minimum_monitor_size_for_updates : 0 ,
1436
+ min_monitor_size_for_updates_bytes : 0 ,
1437
1437
entropy_source : & chanmon_cfgs[ 1 ] . keys_manager ,
1438
1438
signer_provider : & chanmon_cfgs[ 1 ] . keys_manager ,
1439
1439
broadcaster : & chanmon_cfgs[ 1 ] . tx_broadcaster ,
@@ -1512,7 +1512,7 @@ mod tests {
1512
1512
kv_store : & TestStore :: new ( false ) ,
1513
1513
logger : & TestLogger :: new ( ) ,
1514
1514
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
1516
1516
entropy_source : & chanmon_cfgs[ 0 ] . keys_manager ,
1517
1517
signer_provider : & chanmon_cfgs[ 0 ] . keys_manager ,
1518
1518
broadcaster : & chanmon_cfgs[ 0 ] . tx_broadcaster ,
@@ -1525,7 +1525,7 @@ mod tests {
1525
1525
kv_store : & TestStore :: new ( false ) ,
1526
1526
logger : & TestLogger :: new ( ) ,
1527
1527
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
1529
1529
entropy_source : & chanmon_cfgs[ 1 ] . keys_manager ,
1530
1530
signer_provider : & chanmon_cfgs[ 1 ] . keys_manager ,
1531
1531
broadcaster : & chanmon_cfgs[ 1 ] . tx_broadcaster ,
0 commit comments