fn run_engine(filepath: Option<String>) -> Result<()> {
    let gen_random_tx = filepath.is_none();

    let mut transactions = get_transaction_stream(&filepath)?;
    let total_transactions = transactions.size_hint().1.unwrap_or(1);
    let before = Instant::now();
    let (wallets, tx_log) = engine::run(&mut transactions);
    let runtime = before.elapsed().as_secs_f32();

    if !gen_random_tx {
        wallets.print_balances().map_err(|e| {
            eprintln!("Could not serialize wallet balances ({})", e);
            error::Error::SerializeError
        })?;
    } else {
        println!(
            "Executed {} successfull transactions ({}%) out of {} in {:.04}s",
            tx_log.len(),
            ((100 * tx_log.len()) / total_transactions),
            total_transactions,
            runtime
        );
    }
    Ok(())
}
/// If a file is given, open it and parse it as CSV.
/// Otherwise, generate random transactions
If a file is given, open it and parse it as CSV.
Otherwise, generate random transactions
If a file is given open it and parse it as CSV . Otherwise generate random transactions
fn run_engine(filepath: Option<String>) -> Result<()> {
    let gen_random_tx = filepath.is_none();
    let mut transactions = get_transaction_stream(&filepath)?;
    let total_transactions = transactions.size_hint().1.unwrap_or(1);
    let before = Instant::now();
    let (wallets, tx_log) = engine::run(&mut transactions);
    let runtime = before.elapsed().as_secs_f32();
    if !gen_random_tx {
        wallets.print_balances().map_err(|e| {
            eprintln!("Could not serialize wallet balances ({})", e);
            error::Error::SerializeError
        })?;
    } else {
        println!(
            "Executed {} successfull transactions ({}%) out of {} in {:.04}s",
            tx_log.len(),
            ((100 * tx_log.len()) / total_transactions),
            total_transactions,
            runtime
        );
    }
    Ok(())
}
fn run_engine ( filepath : Option < String > ) -> Result < ( ) > { let gen_random_tx = filepath . is_none ( ) ; let mut transactions = get_transaction_stream ( & filepath ) ? ; let total_transactions = transactions . size_hint ( ) . 1 . unwrap_or ( 1 ) ; let before = Instant :: now ( ) ; let ( wallets , tx_log ) = engine :: run ( & mut transactions ) ; let runtime = before . elapsed ( ) . as_secs_f32 ( ) ; if ! gen_random_tx { wallets . print_balances ( ) . map_err ( | e | { eprintln ! ( " " e ) ; error :: Error :: SerializeError } ) ? ; } else { println ! ( " " tx_log len ( ) ( ( 100 tx_log len ( ) ) total_transactions ) total_transactions runtime ) ; } Ok ( ( ) ) }
If a file is given, open it and parse it as CSV.
If a file is given open it and parse it as CSV .
filepath
Option<String>
filepath
Option<String>