Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
slanesuke committed Apr 21, 2024
1 parent edfef57 commit dcef953
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions mine-your-first-block/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -1451,29 +1451,29 @@ fn main() {
}
}

fn write_block_to_file(serialized_header: &[u8], serialized_cb_tx: &[u8], txs: Vec<String>, 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<String>, 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();
}
}



Expand Down

0 comments on commit dcef953

Please sign in to comment.