Skip to content

Commit

Permalink
Merge pull request #117 from TheBlueMatt/main
Browse files Browse the repository at this point in the history
Sweep Fixes
  • Loading branch information
tnull authored Aug 30, 2023
2 parents 5dc3629 + b5e80fb commit 9c5ced0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
18 changes: 13 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Writeable for UserOnionMessageContents {
}
}

pub(crate) async fn poll_for_user_input(
pub(crate) fn poll_for_user_input(
peer_manager: Arc<PeerManager>, channel_manager: Arc<ChannelManager>,
keys_manager: Arc<KeysManager>, network_graph: Arc<NetworkGraph>,
onion_messenger: Arc<OnionMessenger>, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
Expand Down Expand Up @@ -112,8 +112,12 @@ pub(crate) async fn poll_for_user_input(
continue;
}

if connect_peer_if_necessary(pubkey, peer_addr, peer_manager.clone())
.await
if tokio::runtime::Handle::current()
.block_on(connect_peer_if_necessary(
pubkey,
peer_addr,
peer_manager.clone(),
))
.is_err()
{
continue;
Expand Down Expand Up @@ -259,8 +263,12 @@ pub(crate) async fn poll_for_user_input(
continue;
}
};
if connect_peer_if_necessary(pubkey, peer_addr, peer_manager.clone())
.await
if tokio::runtime::Handle::current()
.block_on(connect_peer_if_necessary(
pubkey,
peer_addr,
peer_manager.clone(),
))
.is_ok()
{
println!("SUCCESS: connected to peer {}", pubkey);
Expand Down
32 changes: 19 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,19 +943,25 @@ async fn start_ldk() {
));

// Start the CLI.
let cli_poll = tokio::spawn(cli::poll_for_user_input(
Arc::clone(&peer_manager),
Arc::clone(&channel_manager),
Arc::clone(&keys_manager),
Arc::clone(&network_graph),
Arc::clone(&onion_messenger),
inbound_payments,
outbound_payments,
ldk_data_dir,
network,
Arc::clone(&logger),
Arc::clone(&persister),
));
let cli_channel_manager = Arc::clone(&channel_manager);
let cli_persister = Arc::clone(&persister);
let cli_logger = Arc::clone(&logger);
let cli_peer_manager = Arc::clone(&peer_manager);
let cli_poll = tokio::task::spawn_blocking(move || {
cli::poll_for_user_input(
cli_peer_manager,
cli_channel_manager,
keys_manager,
network_graph,
onion_messenger,
inbound_payments,
outbound_payments,
ldk_data_dir,
network,
cli_logger,
cli_persister,
)
});

// Exit if either CLI polling exits or the background processor exits (which shouldn't happen
// unless we fail to write to the filesystem).
Expand Down
2 changes: 1 addition & 1 deletion src/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) async fn periodic_sweep(
// Note that if you more tightly integrate your wallet with LDK you may not need to do this -
// these outputs can just be treated as normal outputs during coin selection.
let pending_spendables_dir =
format!("{}/{}", crate::PENDING_SPENDABLE_OUTPUT_DIR, ldk_data_dir);
format!("{}/{}", ldk_data_dir, crate::PENDING_SPENDABLE_OUTPUT_DIR);
let processing_spendables_dir = format!("{}/processing_spendable_outputs", ldk_data_dir);
let spendables_dir = format!("{}/spendable_outputs", ldk_data_dir);

Expand Down

0 comments on commit 9c5ced0

Please sign in to comment.