diff --git a/script/research/pow/Cargo.toml b/script/research/pow/Cargo.toml index b28702fc8..6ef8cd4f0 100644 --- a/script/research/pow/Cargo.toml +++ b/script/research/pow/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] randomx = {git = "https://codeberg.org/darkrenaissance/RandomX"} -darkfi-serial = {path = "../../../src/serial"} +darkfi-serial = {version = "0.4.2", features = ["async", "crypto"]} darkfi-sdk = {path = "../../../src/sdk", features = ["async"]} darkfi = {path = "../../../", features = ["util", "async-serial"]} diff --git a/script/research/pow/src/main.rs b/script/research/pow/src/main.rs index a137a2c9a..ea4f0b8ac 100644 --- a/script/research/pow/src/main.rs +++ b/script/research/pow/src/main.rs @@ -87,7 +87,7 @@ struct BlockHeader { /// This value changes arbitrarily with mining. nonce: pallas::Base, /// The hash of the previous block in the blockchain - previous_hash: blake2b_simd::Hash, + previous_hash: [u8; HASH_LEN], /// The block timestamp timestamp: u64, /// Merkle tree of the transactions contained in this block @@ -154,7 +154,7 @@ fn median(v: &mut Vec) -> u64 { /// Verify a block's timestamp is valid and matches certain criteria. fn check_block_timestamp(block: &Block, timestamps: &mut Vec) -> bool { - if block.header.timestamp > Timestamp::current_time().0 + BLOCK_FUTURE_TIME_LIMIT { + if block.header.timestamp > Timestamp::current_time().inner() + BLOCK_FUTURE_TIME_LIMIT { return false } @@ -221,11 +221,14 @@ fn next_difficulty( fn main() -> Result<()> { // Construct the genesis block + let mut previous_hash = [0u8; HASH_LEN]; + previous_hash.copy_from_slice(GENESIS_HASH.as_bytes()); + let mut genesis_block = Block { header: BlockHeader { nonce: pallas::Base::ZERO, - previous_hash: *GENESIS_HASH, - timestamp: Timestamp::current_time().0, + previous_hash, + timestamp: Timestamp::current_time().inner(), txtree: MerkleTree::new(1), }, txs: vec![], @@ -277,11 +280,13 @@ fn main() -> Result<()> { let dataset = Arc::new(RandomXDataset::new(flags, powinput.as_bytes(), N_THREADS).unwrap()); // The miner creates a block + let mut previous_hash = [0u8; HASH_LEN]; + previous_hash.copy_from_slice(cur_block.hash()?.as_bytes()); let mut miner_block = Block { header: BlockHeader { nonce: pallas::Base::ZERO, - previous_hash: cur_block.hash()?, - timestamp: Timestamp::current_time().0, + previous_hash, + timestamp: Timestamp::current_time().inner(), txtree: MerkleTree::new(1), }, txs: vec![],