]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Bound `Persister`'s `WriteableScore` by `Deref` 2024-08-more-deref
authorMatt Corallo <git@bluematt.me>
Tue, 20 Aug 2024 20:39:41 +0000 (20:39 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 21 Aug 2024 13:48:19 +0000 (13:48 +0000)
This makes the trait marginally more flexible, but more importantly
matches our normal structure which makes the bindings generator a
bit happier.

lightning-background-processor/src/lib.rs
lightning/src/util/persist.rs

index 5dee91f5ff2e6776eefd1235e5c01758df1f8140..6547742524840290f5b001230b9dadc2b190d849 100644 (file)
@@ -764,7 +764,7 @@ where
        F::Target: 'static + FeeEstimator,
        L::Target: 'static + Logger,
        P::Target: 'static + Persist<<CM::Target as AChannelManager>::Signer>,
-       PS::Target: 'static + Persister<'a, CM, L, SC>,
+       PS::Target: 'static + Persister<'a, CM, L, S>,
        CM::Target: AChannelManager + Send + Sync,
        OM::Target: AOnionMessenger + Send + Sync,
        PM::Target: APeerManager + Send + Sync,
@@ -786,7 +786,7 @@ where
                                if let Some(duration_since_epoch) = fetch_time() {
                                        if update_scorer(scorer, &event, duration_since_epoch) {
                                                log_trace!(logger, "Persisting scorer after update");
-                                               if let Err(e) = persister.persist_scorer(&scorer) {
+                                               if let Err(e) = persister.persist_scorer(&*scorer) {
                                                        log_error!(logger, "Error: Failed to persist scorer, check your disk and permissions {}", e);
                                                        // We opt not to abort early on persistence failure here as persisting
                                                        // the scorer is non-critical and we still hope that it will have
@@ -935,7 +935,7 @@ impl BackgroundProcessor {
                F::Target: 'static + FeeEstimator,
                L::Target: 'static + Logger,
                P::Target: 'static + Persist<<CM::Target as AChannelManager>::Signer>,
-               PS::Target: 'static + Persister<'a, CM, L, SC>,
+               PS::Target: 'static + Persister<'a, CM, L, S>,
                CM::Target: AChannelManager + Send + Sync,
                OM::Target: AOnionMessenger + Send + Sync,
                PM::Target: APeerManager + Send + Sync,
index 00b1c2462f4840bd4b59e6f296ca2d71dc9a8b3f..c30d13b31873999e9ec0bb3e7606b3310599ea33 100644 (file)
@@ -157,10 +157,11 @@ pub trait KVStore {
 /// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
 ///
 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
-pub trait Persister<'a, CM: Deref, L: Deref, S: WriteableScore<'a>>
+pub trait Persister<'a, CM: Deref, L: Deref, S: Deref>
 where
        CM::Target: 'static + AChannelManager,
        L::Target: 'static + Logger,
+       S::Target: WriteableScore<'a>,
 {
        /// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
        ///
@@ -175,10 +176,11 @@ where
 }
 
 
-impl<'a, A: KVStore + ?Sized, CM: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, CM, L, S> for A
+impl<'a, A: KVStore + ?Sized, CM: Deref, L: Deref, S: Deref> Persister<'a, CM, L, S> for A
 where
        CM::Target: 'static + AChannelManager,
        L::Target: 'static + Logger,
+       S::Target: WriteableScore<'a>,
 {
        fn persist_manager(&self, channel_manager: &CM) -> Result<(), io::Error> {
                self.write(CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,