Skip to content

Commit 49aec32

Browse files
committed
Drop various bounds on types passed to MonitorUpdatingPersister
The new `MonitorUpdatingPersister` has a few redundant type bounds (re-specified on functions after having been specified on the struct itself), which we remove here. Further, it requires a `Deref<FeeEstimator>` which is `Clone`able. This is generally fine in rust, but annoying in bindings, so we simply elide it in favor if a `&Deref<FeeEstimator>`.
1 parent 14c723c commit 49aec32

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ where C::Target: chain::Filter,
755755
Some(monitor_state) => {
756756
let monitor = &monitor_state.monitor;
757757
log_trace!(self.logger, "Updating ChannelMonitor for channel {}", log_funding_info!(monitor));
758-
let update_res = monitor.update_monitor(update, &self.broadcaster, &*self.fee_estimator, &self.logger);
758+
let update_res = monitor.update_monitor(update, &self.broadcaster, &self.fee_estimator, &self.logger);
759759
if update_res.is_err() {
760760
log_error!(self.logger, "Failed to update ChannelMonitor for channel {}.", log_funding_info!(monitor));
761761
}

lightning/src/chain/channelmonitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
13111311
&self,
13121312
updates: &ChannelMonitorUpdate,
13131313
broadcaster: &B,
1314-
fee_estimator: F,
1314+
fee_estimator: &F,
13151315
logger: &L,
13161316
) -> Result<(), ()>
13171317
where
@@ -2593,7 +2593,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25932593
self.pending_monitor_events.push(MonitorEvent::HolderForceClosed(self.funding_info.0));
25942594
}
25952595

2596-
pub fn update_monitor<B: Deref, F: Deref, L: Deref>(&mut self, updates: &ChannelMonitorUpdate, broadcaster: &B, fee_estimator: F, logger: &L) -> Result<(), ()>
2596+
pub fn update_monitor<B: Deref, F: Deref, L: Deref>(&mut self, updates: &ChannelMonitorUpdate, broadcaster: &B, fee_estimator: &F, logger: &L) -> Result<(), ()>
25972597
where B::Target: BroadcasterInterface,
25982598
F::Target: FeeEstimator,
25992599
L::Target: Logger,
@@ -2633,7 +2633,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
26332633
panic!("Attempted to apply ChannelMonitorUpdates out of order, check the update_id before passing an update to update_monitor!");
26342634
}
26352635
let mut ret = Ok(());
2636-
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(&*fee_estimator);
2636+
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(&**fee_estimator);
26372637
for update in updates.updates.iter() {
26382638
match update {
26392639
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, claimed_htlcs, nondust_htlc_sources } => {

lightning/src/util/persist.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,7 @@ where
397397
pub fn new(
398398
kv_store: K, logger: L, maximum_pending_updates: u64, entropy_source: ES,
399399
signer_provider: SP,
400-
) -> Self
401-
where
402-
ES::Target: EntropySource + Sized,
403-
SP::Target: SignerProvider + Sized,
404-
{
400+
) -> Self {
405401
MonitorUpdatingPersister {
406402
kv_store,
407403
logger,
@@ -416,12 +412,10 @@ where
416412
/// It is extremely important that your [`KVStore::read`] implementation uses the
417413
/// [`io::ErrorKind::NotFound`] variant correctly. For more information, please see the
418414
/// documentation for [`MonitorUpdatingPersister`].
419-
pub fn read_all_channel_monitors_with_updates<B: Deref, F: Deref + Clone>(
420-
&self, broadcaster: B, fee_estimator: F,
415+
pub fn read_all_channel_monitors_with_updates<B: Deref, F: Deref>(
416+
&self, broadcaster: &B, fee_estimator: &F,
421417
) -> Result<Vec<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::Signer>)>, io::Error>
422418
where
423-
ES::Target: EntropySource + Sized,
424-
SP::Target: SignerProvider + Sized,
425419
B::Target: BroadcasterInterface,
426420
F::Target: FeeEstimator,
427421
{
@@ -432,8 +426,8 @@ where
432426
let mut res = Vec::with_capacity(monitor_list.len());
433427
for monitor_key in monitor_list {
434428
res.push(self.read_channel_monitor_with_updates(
435-
&broadcaster,
436-
fee_estimator.clone(),
429+
broadcaster,
430+
fee_estimator,
437431
monitor_key,
438432
)?)
439433
}
@@ -457,12 +451,10 @@ where
457451
///
458452
/// Loading a large number of monitors will be faster if done in parallel. You can use this
459453
/// function to accomplish this. Take care to limit the number of parallel readers.
460-
pub fn read_channel_monitor_with_updates<B: Deref, F: Deref + Clone>(
461-
&self, broadcaster: &B, fee_estimator: F, monitor_key: String,
454+
pub fn read_channel_monitor_with_updates<B: Deref, F: Deref>(
455+
&self, broadcaster: &B, fee_estimator: &F, monitor_key: String,
462456
) -> Result<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::Signer>), io::Error>
463457
where
464-
ES::Target: EntropySource + Sized,
465-
SP::Target: SignerProvider + Sized,
466458
B::Target: BroadcasterInterface,
467459
F::Target: FeeEstimator,
468460
{
@@ -484,7 +476,7 @@ where
484476
Err(err) => return Err(err),
485477
};
486478

487-
monitor.update_monitor(&update, broadcaster, fee_estimator.clone(), &self.logger)
479+
monitor.update_monitor(&update, broadcaster, fee_estimator, &self.logger)
488480
.map_err(|e| {
489481
log_error!(
490482
self.logger,

0 commit comments

Comments
 (0)