diff --git a/src/consensus/mod.rs b/src/consensus/mod.rs new file mode 100644 index 00000000..d645b9d5 --- /dev/null +++ b/src/consensus/mod.rs @@ -0,0 +1,21 @@ +// Rust Bitcoin Library +// Written by +// The Rust Bitcoin developers +// +// To the extent possible under law, the author(s) have dedicated all +// copyright and related and neighboring rights to this software to +// the public domain worldwide. This software is distributed without +// any warranty. +// +// You should have received a copy of the CC0 Public Domain Dedication +// along with this software. +// If not, see . +// + +//! Consensus +//! +//! This module defines structures, functions, and traits which are needed to +//! conform to Bitcoin consensus. +//! + +pub mod params; diff --git a/src/network/consensus_params.rs b/src/consensus/params.rs similarity index 96% rename from src/network/consensus_params.rs rename to src/consensus/params.rs index 759b4ea8..f39f3a8e 100644 --- a/src/network/consensus_params.rs +++ b/src/consensus/params.rs @@ -44,7 +44,7 @@ const MAX_BITS_REGTEST: Uint256 = Uint256([ #[derive(Debug, Clone)] /// Parameters that influence chain consensus. -pub struct ConsensusParams { +pub struct Params { /// Network for which parameters are valid. pub network: Network, /// Time when BIP16 becomes active. @@ -73,11 +73,11 @@ pub struct ConsensusParams { pub no_pow_retargeting: bool, } -impl ConsensusParams { +impl Params { /// Creates parameters set for the given network. pub fn new(network: Network) -> Self { match network { - Network::Bitcoin => ConsensusParams { + Network::Bitcoin => Params { network: Network::Bitcoin, bip16_time: 1333238400, // Apr 1 2012 bip34_height: 227931, // 000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8 @@ -91,7 +91,7 @@ impl ConsensusParams { allow_min_difficulty_blocks: false, no_pow_retargeting: false, }, - Network::Testnet => ConsensusParams { + Network::Testnet => Params { network: Network::Testnet, bip16_time: 1333238400, // Apr 1 2012 bip34_height: 21111, // 0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8 @@ -105,7 +105,7 @@ impl ConsensusParams { allow_min_difficulty_blocks: true, no_pow_retargeting: false, }, - Network::Regtest => ConsensusParams { + Network::Regtest => Params { network: Network::Regtest, bip16_time: 1333238400, // Apr 1 2012 bip34_height: 100000000, // not activated on regtest diff --git a/src/network/mod.rs b/src/network/mod.rs index b19077a6..bf1fa340 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -23,7 +23,6 @@ use std::io; use std::error; pub mod constants; -pub mod consensus_params; pub mod encodable; pub mod serialize;