Skip to content

Commit

Permalink
cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Jul 5, 2024
1 parent e485963 commit f65071f
Show file tree
Hide file tree
Showing 5 changed files with 488 additions and 460 deletions.
92 changes: 46 additions & 46 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,56 +44,56 @@ impl RpcApiWrapper for Client {
}
}

/// Dumps complete ledger to a string and returns it. This can help identify
/// bugs as it draws the big picture of the mock blockchain.
pub fn dump_ledger(rpc: Client, pretty: bool) -> String {
dump_ledger_inner(rpc.ledger, pretty)
}
/// Parent of `dump_ledger`. This function accepts private `Ledger` struct. This
/// useful for only crate tests.
pub fn dump_ledger_inner(ledger: Ledger, pretty: bool) -> String {
let mut dump = String::new();
// / Dumps complete ledger to a string and returns it. This can help identify
// / bugs as it draws the big picture of the mock blockchain.
// pub fn dump_ledger(rpc: Client, pretty: bool) -> String {
// dump_ledger_inner(rpc.ledger, pretty)
// }
// / Parent of `dump_ledger`. This function accepts private `Ledger` struct. This
// / useful for only crate tests.
// pub fn dump_ledger_inner(ledger: Ledger, pretty: bool) -> String {
// let mut dump = String::new();

const DELIMETER: &str = "\n-----\n";
// const DELIMETER: &str = "\n-----\n";

let utxos = ledger.get_user_utxos();
let transactions = ledger.get_transactions();
let credentials = ledger.get_credentials();
// let utxos = ledger.get_user_utxos();
// let transactions = ledger.get_transactions();
// let credentials = ledger.get_credentials();

if pretty {
dump += format!("UTXOs: {:#?}", utxos).as_str();
dump += DELIMETER;
dump += format!("Transactions: {:#?}", transactions).as_str();
dump += DELIMETER;
dump += format!(
"Txids: {:#?}",
transactions
.iter()
.map(|tx| tx.compute_txid())
.collect::<Vec<Txid>>()
)
.as_str();
dump += DELIMETER;
dump += format!("Credentials: {:#?}", credentials).as_str();
} else {
dump += format!("UTXOs: {:?}", utxos).as_str();
dump += DELIMETER;
dump += format!("Transactions: {:?}", transactions).as_str();
dump += DELIMETER;
dump += format!(
"Txids: {:?}",
transactions
.iter()
.map(|tx| tx.compute_txid())
.collect::<Vec<Txid>>()
)
.as_str();
dump += DELIMETER;
dump += format!("Credentials: {:?}", credentials).as_str();
}
// if pretty {
// dump += format!("UTXOs: {:#?}", utxos).as_str();
// dump += DELIMETER;
// dump += format!("Transactions: {:#?}", transactions).as_str();
// dump += DELIMETER;
// dump += format!(
// "Txids: {:#?}",
// transactions
// .iter()
// .map(|tx| tx.compute_txid())
// .collect::<Vec<Txid>>()
// )
// .as_str();
// dump += DELIMETER;
// dump += format!("Credentials: {:#?}", credentials).as_str();
// } else {
// dump += format!("UTXOs: {:?}", utxos).as_str();
// dump += DELIMETER;
// dump += format!("Transactions: {:?}", transactions).as_str();
// dump += DELIMETER;
// dump += format!(
// "Txids: {:?}",
// transactions
// .iter()
// .map(|tx| tx.compute_txid())
// .collect::<Vec<Txid>>()
// )
// .as_str();
// dump += DELIMETER;
// dump += format!("Credentials: {:?}", credentials).as_str();
// }

dump
}
// dump
// }

#[cfg(test)]
mod tests {
Expand Down
Loading

0 comments on commit f65071f

Please sign in to comment.