From 849820e626b06f8e99f2e88b1391d101bca3640c Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 23 Apr 2024 14:00:33 +0100 Subject: Refactor action dispatching to run_actions() --- src/main.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 0173eb8..6006348 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ mod config; mod message; mod wallets; -use crate::actions::get_actions; +use crate::actions::{get_actions, run_actions}; use crate::message::MessageParams; use crate::{ blockchain::BlockchainState, @@ -63,14 +63,6 @@ fn set_signal_handlers() -> Result<()> { Ok(()) } -async fn run_test_actions(actions: &[&(dyn Action<'_> + Sync)]) { - TokioScope::scope_and_block(|s| { - for &action in actions { - s.spawn(action.run(None)); - } - }); -} - fn get_and_handle_new_txs( wallet_info: &SafeWalletInfo, actions: &[&(dyn Action<'_> + Sync)], @@ -80,13 +72,7 @@ fn get_and_handle_new_txs( TokioScope::scope_and_block(|s| { for tx in txs.iter() { let params = MessageParams::new(tx, &locked_wallet_info); - s.spawn(async move { - TokioScope::scope_and_block(|s| { - for &action in actions { - s.spawn(action.run(Some(¶ms))); - } - }); - }); + s.spawn(run_actions(actions, Some(params))); } }); Ok(()) @@ -148,7 +134,7 @@ async fn do_main() -> Result<()> { let actions_ref = actions.iter().map(Box::as_ref).collect::>(); if args.test() { - run_test_actions(&actions_ref).await; + run_actions(&actions_ref, None).await; return Ok(()); } -- cgit v1.2.3-70-g09d2