Change block nonce to u32

This commit is contained in:
x
2025-12-24 10:52:57 +00:00
parent b38512a982
commit 57717ecf3c
4 changed files with 9 additions and 9 deletions

View File

@@ -445,7 +445,7 @@ impl DarkfiNode {
// Sign the DarkFi block
let mut block = blocktemplate.block.clone();
block.header.nonce = *nonce as u64;
block.header.nonce = *nonce as u32;
block.sign(&blocktemplate.secret);
info!(
target: "darkfid::rpc::miner_submit_solution",

View File

@@ -52,7 +52,7 @@ pub struct BlockRecord {
/// Block creation timestamp
pub timestamp: Timestamp,
/// The block's nonce. This value changes arbitrarily with mining.
pub nonce: u64,
pub nonce: u32,
/// Merkle tree root of the transactions hashes contained in this block
pub transactions_root: String,
/// Contracts states Monotree(SMT) root this block commits to

View File

@@ -97,7 +97,7 @@ pub struct Header {
/// Block creation timestamp
pub timestamp: Timestamp,
/// The block's nonce. This value changes arbitrarily with mining.
pub nonce: u64,
pub nonce: u32,
/// Merkle tree root of the transactions hashes contained in this block
pub transactions_root: MerkleNode,
/// Contracts states Monotree(SMT) root this block commits to
@@ -109,7 +109,7 @@ pub struct Header {
impl Header {
/// Generates a new header with default transactions and state root,
/// using DarkFi native Proof of Work data.
pub fn new(previous: HeaderHash, height: u32, timestamp: Timestamp, nonce: u64) -> Self {
pub fn new(previous: HeaderHash, height: u32, timestamp: Timestamp, nonce: u32) -> Self {
let version = block_version(height);
let transactions_root = MerkleTree::new(1).root(0).unwrap();
let state_root = *EMPTY_HASH;
@@ -187,7 +187,7 @@ impl Default for Header {
HeaderHash::new(blake3::hash(b"Let there be dark!").into()),
0u32,
Timestamp::current_time(),
0u64,
0u32,
)
}
}

View File

@@ -18,7 +18,7 @@
use std::{
sync::{
atomic::{AtomicBool, AtomicU64, Ordering},
atomic::{AtomicBool, AtomicU32, Ordering},
Arc,
},
thread,
@@ -572,10 +572,10 @@ pub fn mine_block(
debug!(target: "validator::pow::randomx_vms_mine", "[MINER] Initializing mining threads...");
let mut handles = Vec::with_capacity(vms.len());
let atomic_nonce = Arc::new(AtomicU64::new(0));
let atomic_nonce = Arc::new(AtomicU32::new(0));
let found_header = Arc::new(AtomicBool::new(false));
let found_nonce = Arc::new(AtomicU64::new(0));
let threads = vms.len() as u64;
let found_nonce = Arc::new(AtomicU32::new(0));
let threads = vms.len() as u32;
let mining_start = Instant::now();
for t in 0..threads {
// Check if stop signal is received