Skip to content

Commit ea44a5d

Browse files
committed
Merge branch 'feat/dash-spv-client-interface' into feat/quorum-lookup-validation
2 parents a28f0cc + c586be9 commit ea44a5d

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

dash-spv-ffi/src/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -889,24 +889,24 @@ pub unsafe extern "C" fn dash_spv_ffi_client_sync_to_tip_with_progress(
889889
let (_command_sender, command_receiver) = tokio::sync::mpsc::unbounded_channel();
890890
let run_token = shutdown_token_sync.clone();
891891
let (abort_handle, abort_registration) = AbortHandle::new_pair();
892-
let mut run_future = Box::pin(Abortable::new(
893-
spv_client.run(command_receiver, run_token),
892+
let mut monitor_future = Box::pin(Abortable::new(
893+
spv_client.monitor_network(command_receiver, run_token),
894894
abort_registration,
895895
));
896896
let result = tokio::select! {
897-
res = &mut run_future => match res {
897+
res = &mut monitor_future => match res {
898898
Ok(inner) => inner,
899899
Err(_) => Ok(()),
900900
},
901901
_ = shutdown_token_sync.cancelled() => {
902902
abort_handle.abort();
903-
match run_future.as_mut().await {
903+
match monitor_future.as_mut().await {
904904
Ok(inner) => inner,
905905
Err(_) => Ok(()),
906906
}
907907
}
908908
};
909-
drop(run_future);
909+
drop(monitor_future);
910910
let mut guard = inner.lock().unwrap();
911911
*guard = Some(spv_client);
912912
result

dash-spv/examples/filter_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4848
let (_command_sender, command_receiver) = tokio::sync::mpsc::unbounded_channel();
4949
let shutdown_token = CancellationToken::new();
5050

51-
client.run_until_shutdown(command_receiver, shutdown_token).await?;
51+
client.run(command_receiver, shutdown_token).await?;
5252

5353
println!("Done!");
5454
Ok(())

dash-spv/examples/simple_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5151
let (_command_sender, command_receiver) = tokio::sync::mpsc::unbounded_channel();
5252
let shutdown_token = CancellationToken::new();
5353

54-
client.run_until_shutdown(command_receiver, shutdown_token).await?;
54+
client.run(command_receiver, shutdown_token).await?;
5555

5656
println!("Done!");
5757
Ok(())

dash-spv/examples/spv_with_wallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5252
let (_command_sender, command_receiver) = tokio::sync::mpsc::unbounded_channel();
5353
let shutdown_token = CancellationToken::new();
5454

55-
client.run_until_shutdown(command_receiver, shutdown_token).await?;
55+
client.run(command_receiver, shutdown_token).await?;
5656

5757
println!("Done!");
5858
Ok(())

dash-spv/src/client/sync_coordinator.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ impl<
6868
///
6969
/// This is the sole network message receiver to prevent race conditions.
7070
/// All sync operations coordinate through this monitoring loop.
71-
pub async fn run(
71+
pub async fn monitor_network(
7272
&mut self,
73-
mut receiver: UnboundedReceiver<DashSpvClientCommand>,
73+
mut command_receiver: UnboundedReceiver<DashSpvClientCommand>,
7474
token: CancellationToken,
7575
) -> Result<()> {
7676
let running = self.running.read().await;
@@ -482,7 +482,7 @@ impl<
482482
}
483483

484484
tokio::select! {
485-
received = receiver.recv() => {
485+
received = command_receiver.recv() => {
486486
match received {
487487
None => {tracing::warn!("DashSpvClientCommand channel closed.");},
488488
Some(command) => {
@@ -570,15 +570,15 @@ impl<
570570
Ok(())
571571
}
572572

573-
pub async fn run_until_shutdown(
573+
pub async fn run(
574574
mut self,
575-
receiver: UnboundedReceiver<DashSpvClientCommand>,
575+
command_receiver: UnboundedReceiver<DashSpvClientCommand>,
576576
shutdown_token: CancellationToken,
577577
) -> Result<()> {
578578
let client_token = shutdown_token.clone();
579579

580580
let client_task = tokio::spawn(async move {
581-
let result = self.run(receiver, client_token).await;
581+
let result = self.monitor_network(command_receiver, client_token).await;
582582
if let Err(e) = &result {
583583
tracing::error!("Error running client: {}", e);
584584
}
@@ -589,7 +589,9 @@ impl<
589589
});
590590

591591
let shutdown_task = tokio::spawn(async move {
592-
let _ = tokio::signal::ctrl_c().await;
592+
if let Err(e) = tokio::signal::ctrl_c().await {
593+
tracing::error!("Error waiting for ctrl_c: {}", e);
594+
}
593595
tracing::debug!("Shutdown signal received");
594596
shutdown_token.cancel();
595597
});

dash-spv/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ async fn run_client<S: dash_spv::storage::StorageManager + Send + Sync + 'static
633633
let (_command_sender, command_receiver) = tokio::sync::mpsc::unbounded_channel();
634634
let shutdown_token = CancellationToken::new();
635635

636-
client.run_until_shutdown(command_receiver, shutdown_token).await?;
636+
client.run(command_receiver, shutdown_token).await?;
637637

638638
Ok(())
639639
}

0 commit comments

Comments
 (0)