Skip to content

Commit 82ec012

Browse files
make cancel optional
1 parent 97cc692 commit 82ec012

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

crates/cast/bin/cmd/logs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl LogsArgs {
101101
}
102102

103103
let mut stdout = io::stdout();
104-
cast.subscribe(filter, &mut stdout, json, ctrl_c_future()).await?;
104+
cast.subscribe(filter, &mut stdout, json, Some(ctrl_c_future())).await?;
105105

106106
Ok(())
107107
}

crates/cast/src/lib.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations};
1818
use eyre::{Context, Result};
1919
use foundry_common::{abi::encode_args, fmt::*, TransactionReceiptWithRevertReason};
2020
pub use foundry_evm::*;
21-
use futures::{future::Either, pin_mut, Future, FutureExt, StreamExt};
21+
use futures::{future::Either, Future, FutureExt, StreamExt};
2222
use rayon::prelude::*;
2323
pub use rusoto_core::{
2424
credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion,
@@ -891,7 +891,7 @@ where
891891
filter: Filter,
892892
output: &mut dyn io::Write,
893893
to_json: bool,
894-
cancel: F,
894+
cancel: Option<F>,
895895
) -> Result<()>
896896
where
897897
<M as Middleware>::Provider: PubsubClient,
@@ -915,7 +915,7 @@ where
915915
}
916916

917917
let mut first = true;
918-
pin_mut!(cancel);
918+
let mut cancel = cancel.map(Box::pin);
919919

920920
loop {
921921
tokio::select! {
@@ -948,8 +948,14 @@ where
948948
}
949949
},
950950
// Break on cancel signal, to allow for closing JSON bracket
951-
_ = &mut cancel => {
952-
break;
951+
_ = if let Some(ref mut cancel) = cancel {
952+
Either::Left(cancel)
953+
} else {
954+
Either::Right(futures::future::pending())
955+
} => {
956+
if cancel.is_some() {
957+
break;
958+
}
953959
},
954960
else => break,
955961
}

0 commit comments

Comments
 (0)