From dcef953f23ffa49f99ed9fb14922cafc1e33ddd0 Mon Sep 17 00:00:00 2001 From: Ian Slane Date: Sat, 20 Apr 2024 21:37:52 -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 4d1291a..a29090b 100644 --- a/mine-your-first-block/src/main.rs +++ b/mine-your-first-block/src/main.rs @@ -1441,8 +1441,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 { @@ -1451,29 +1451,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(); + } +}