Skip to content

Commit

Permalink
f log on start/end of migration
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinewallace committed May 29, 2024
1 parent 6a47cd3 commit f94cbd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ async fn start_ldk() {
tokio::spawn(sweep::migrate_deprecated_spendable_outputs(
ldk_data_dir.clone(),
Arc::clone(&keys_manager),
Arc::clone(&logger),
Arc::clone(&persister),
Arc::clone(&output_sweeper),
));
Expand Down
13 changes: 11 additions & 2 deletions src/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use std::sync::Arc;
use std::{fs, io};

use lightning::sign::{EntropySource, KeysManager, SpendableOutputDescriptor};
use lightning::util::logger::Logger;
use lightning::util::persist::KVStore;
use lightning::util::ser::{Readable, WithoutLength, Writeable};

use lightning_persister::fs_store::FilesystemStore;

use crate::disk::FilesystemLogger;
use crate::hex_utils;
use crate::OutputSweeper;

Expand All @@ -17,9 +19,10 @@ const DEPRECATED_PENDING_SPENDABLE_OUTPUT_DIR: &'static str = "pending_spendable
/// We updated to use LDK's OutputSweeper as part of upgrading to LDK 0.0.123, so migrate away from
/// the old sweep persistence.
pub(crate) async fn migrate_deprecated_spendable_outputs(
ldk_data_dir: String, keys_manager: Arc<KeysManager>, persister: Arc<FilesystemStore>,
sweeper: Arc<OutputSweeper>,
ldk_data_dir: String, keys_manager: Arc<KeysManager>, logger: Arc<FilesystemLogger>,
persister: Arc<FilesystemStore>, sweeper: Arc<OutputSweeper>,
) {
lightning::log_info!(&*logger, "Beginning migration of deprecated spendable outputs");
let pending_spendables_dir =
format!("{}/{}", ldk_data_dir, DEPRECATED_PENDING_SPENDABLE_OUTPUT_DIR);
let processing_spendables_dir = format!("{}/processing_spendable_outputs", ldk_data_dir);
Expand Down Expand Up @@ -82,4 +85,10 @@ pub(crate) async fn migrate_deprecated_spendable_outputs(

fs::remove_dir_all(&spendables_dir).unwrap();
fs::remove_dir_all(&pending_spendables_dir).unwrap();

lightning::log_info!(
&*logger,
"Successfully migrated {} deprecated spendable outputs",
outputs.len()
);
}

0 comments on commit f94cbd7

Please sign in to comment.