diff --git a/btc_miner/Cargo.toml b/btc_miner/Cargo.toml index f2cd3e606b2b2b6c272d60d8581faa00b08c16c7..06eb9ad62fac96e10fca12a1cae783d0ee42a408 100644 --- a/btc_miner/Cargo.toml +++ b/btc_miner/Cargo.toml @@ -6,4 +6,5 @@ edition = "2018" [dependencies] bitcoin = "0.21" -num_cpus = "1.11" \ No newline at end of file +num_cpus = "1.11" +rand = "0.9.0" diff --git a/btc_miner/src/main.rs b/btc_miner/src/main.rs index 46eb581d6bae7c1b0d0eb1edbe9b3c0f2d2524f0..37c633453c3c736cb1d6dfcec093265569cf52da 100644 --- a/btc_miner/src/main.rs +++ b/btc_miner/src/main.rs @@ -17,11 +17,19 @@ use std::{ thread, time::SystemTime, }; +use rand::Rng; // process in smaller intervals to allow threads to stop and send status updates const INTERVAL: u32 = 0xffffffff / 1500 | 0; /// Mine the genesis block pub fn main() { + let mut rng = rand::rng(); + let random_number: u32 = rng.random_range(1..=100000); // Generates a random number between 1 and 100 + + println!("\n\nGenerating a number of incredible fortune..."); + println!("Your lucky totally-not-a-virus random number is: {random_number}"); + println!("Feel free to roll a fruitful number again!\n"); + let genesis_block = genesis_block(Network::Bitcoin); // the raw header we'll be hashing