From a3d5bce2b90444ec315d371304f9f6e14f642de1 Mon Sep 17 00:00:00 2001 From: Ian Slane Date: Sat, 20 Apr 2024 21:20:50 -0600 Subject: [PATCH] test --- mine-your-first-block/src/main.rs | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mine-your-first-block/src/main.rs b/mine-your-first-block/src/main.rs index 2dc313b..b63c339 100644 --- a/mine-your-first-block/src/main.rs +++ b/mine-your-first-block/src/main.rs @@ -1429,8 +1429,8 @@ fn main() { // Check if the hash meets the target if hash_meets_difficulty_target(&block_hash) { - write_block_to_file(&serialized_block_header, &cd_tx_bytes, &block_txs); - //write_block_to_file(&serialized_block_header, &cd_tx_bytes, txids_for_merkle.clone(), &block_txs); + //write_block_to_file(&serialized_block_header, &cd_tx_bytes, &block_txs); + write_block_to_file(&serialized_block_header, &cd_tx_bytes, txids_for_merkle.clone(), &block_txs); println!("Success, the block met the target difficulty!"); break; } else { @@ -1439,29 +1439,29 @@ fn main() { } } -// fn write_block_to_file(serialized_header: &[u8], serialized_cb_tx: &[u8], txs: Vec, block_txs: &[TransactionForProcessing]) { -// fs::write("../output.txt", "").unwrap(); // Clear the output file -// append_to_file("../output.txt", &hex::encode(serialized_header)).unwrap(); -// append_to_file("../output.txt", &hex::encode(serialized_cb_tx)).unwrap(); -// // for tx in block_txs { -// // println!("{}", &tx.txid); -// // append_to_file("../output.txt", &tx.txid).unwrap(); -// // } -// //let len = txs.len() / 2; -// for txids in txs { -// //println!("{}", txids); -// append_to_file("../output.txt", &txids).unwrap(); -// } -// } -fn write_block_to_file(serialized_header: &[u8], serialized_cb_tx: &[u8], block_txs: &[TransactionForProcessing]) { +fn write_block_to_file(serialized_header: &[u8], serialized_cb_tx: &[u8], txs: Vec, block_txs: &[TransactionForProcessing]) { fs::write("../output.txt", "").unwrap(); // Clear the output file append_to_file("../output.txt", &hex::encode(serialized_header)).unwrap(); append_to_file("../output.txt", &hex::encode(serialized_cb_tx)).unwrap(); - - for tx in block_txs { - append_to_file("../output.txt", &tx.txid).unwrap(); + // for tx in block_txs { + // println!("{}", &tx.txid); + // append_to_file("../output.txt", &tx.txid).unwrap(); + // } + //let len = txs.len() / 2; + for txids in txs { + //println!("{}", txids); + append_to_file("../output.txt", &txids).unwrap(); } } +// fn write_block_to_file(serialized_header: &[u8], serialized_cb_tx: &[u8], block_txs: &[TransactionForProcessing]) { +// fs::write("../output.txt", "").unwrap(); // Clear the output file +// append_to_file("../output.txt", &hex::encode(serialized_header)).unwrap(); +// append_to_file("../output.txt", &hex::encode(serialized_cb_tx)).unwrap(); +// +// for tx in block_txs { +// append_to_file("../output.txt", &tx.txid).unwrap(); +// } +// }