if $channel_manager.get_cm().get_and_clear_needs_persistence() {
log_trace!($logger, "Persisting ChannelManager...");
- $persister.persist_manager(&$channel_manager)?;
+ $persister.persist_manager($channel_manager.get_cm())?;
log_trace!($logger, "Done persisting ChannelManager.");
}
if $timer_elapsed(&mut last_freshness_call, FRESHNESS_TIMER) {
// After we exit, ensure we persist the ChannelManager one final time - this avoids
// some races where users quit while channel updates were in-flight, with
// ChannelMonitor update(s) persisted without a corresponding ChannelManager update.
- $persister.persist_manager(&$channel_manager)?;
+ $persister.persist_manager($channel_manager.get_cm())?;
// Persist Scorer on exit
if let Some(ref scorer) = $scorer {
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>,
- CM::Target: AChannelManager + Send + Sync,
+ PS::Target: 'static + Persister<'a, <<CM as Deref>::Target as AChannelManager>::M, <<CM as Deref>::Target as AChannelManager>::T, <<CM as Deref>::Target as AChannelManager>::ES, <<CM as Deref>::Target as AChannelManager>::NS, <<CM as Deref>::Target as AChannelManager>::SP, <<CM as Deref>::Target as AChannelManager>::F, <<CM as Deref>::Target as AChannelManager>::R, L, SC>,
+ CM::Target: AChannelManager<L = L> + Send + Sync,
PM::Target: APeerManager + Send + Sync,
{
let stop_thread = Arc::new(AtomicBool::new(false));
fn list(&self, primary_namespace: &str, secondary_namespace: &str) -> Result<Vec<String>, io::Error>;
}
+
/// 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>>
-where
- CM::Target: 'static + AChannelManager,
- L::Target: 'static + Logger,
+pub trait Persister<'a, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref, S: WriteableScore<'a>>
+ where M::Target: 'static + chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
+ T::Target: 'static + BroadcasterInterface,
+ ES::Target: 'static + EntropySource,
+ NS::Target: 'static + crate::sign::NodeSigner,
+ SP::Target: 'static + SignerProvider,
+ F::Target: 'static + FeeEstimator,
+ R::Target: 'static + crate::routing::router::Router,
+ L::Target: 'static + Logger,
{
/// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
///
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
- fn persist_manager(&self, channel_manager: &CM) -> Result<(), io::Error>;
+ fn persist_manager(&self, channel_manager: &crate::ln::channelmanager::ChannelManager<M, T, ES, NS, SP, F, R, L>) -> Result<(), io::Error>;
/// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
fn persist_graph(&self, network_graph: &NetworkGraph<L>) -> Result<(), io::Error>;
fn persist_scorer(&self, scorer: &S) -> Result<(), io::Error>;
}
-
-impl<'a, A: KVStore + ?Sized, CM: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, CM, L, S> for A
-where
- CM::Target: 'static + AChannelManager,
- L::Target: 'static + Logger,
+impl<'a, A: KVStore + ?Sized, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref, S: WriteableScore<'a>> Persister<'a, M, T, ES, NS, SP, F, R, L, S> for A
+ where M::Target: 'static + chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
+ T::Target: 'static + BroadcasterInterface,
+ ES::Target: 'static + EntropySource,
+ NS::Target: 'static + crate::sign::NodeSigner,
+ SP::Target: 'static + SignerProvider,
+ F::Target: 'static + FeeEstimator,
+ R::Target: 'static + crate::routing::router::Router,
+ L::Target: 'static + Logger,
{
- fn persist_manager(&self, channel_manager: &CM) -> Result<(), io::Error> {
+ fn persist_manager(&self, channel_manager: &crate::ln::channelmanager::ChannelManager<M, T, ES, NS, SP, F, R, L>) -> Result<(), io::Error> {
self.write(CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE,
CHANNEL_MANAGER_PERSISTENCE_KEY,