Skip to content

Commit 68b668e

Browse files
Add cpunet prefix to PoW function and update CPUNET type in param.rs
Signed-off-by: Calisto Abel Mathias <[email protected]>
1 parent 1478c1a commit 68b668e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

bitcoin/src/network/params.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
//! # }
6868
//! ```
6969
70+
use primitives::Block;
7071
use units::{BlockHeight, BlockInterval};
7172

7273
use crate::network::Network;
@@ -254,11 +255,11 @@ impl Params {
254255
pub const CPUNET: Params = Params {
255256
network: Network::CPUNet,
256257
bip16_time: 1333238400, // Apr 1 2012
257-
bip34_height: 1,
258-
bip65_height: 1,
259-
bip66_height: 1,
260-
rule_change_activation_threshold: 1512, // 75%
261-
miner_confirmation_window: 2016,
258+
bip34_height: BlockHeight::from_u32(1),
259+
bip65_height: BlockHeight::from_u32(1),
260+
bip66_height: BlockHeight::from_u32(1),
261+
rule_change_activation_threshold: BlockInterval::from_u32(1512), // 75%
262+
miner_confirmation_window: BlockInterval::from_u32(2016),
262263
pow_limit: Target::MAX_ATTAINABLE_MAINNET,
263264
max_attainable_target: Target::MAX_ATTAINABLE_MAINNET,
264265
pow_target_spacing: 10 * 60, // 10 minutes.

primitives/src/block.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ impl Header {
196196
// This is the same as `Encodable` but done manually because `Encodable` isn't in `primitives`.
197197
pub fn block_hash(&self) -> BlockHash {
198198
let mut engine = sha256d::Hash::engine();
199+
engine.input("cpunet\0".as_bytes());
199200
engine.input(&self.version.to_consensus().to_le_bytes());
200201
engine.input(self.prev_blockhash.as_byte_array());
201202
engine.input(self.merkle_root.as_byte_array());

0 commit comments

Comments
 (0)