Move network::consensus_params to consensus::params

This commit is contained in:
Carl Dong 2018-09-02 22:18:57 -07:00
parent 7e9d393d03
commit 97937b1b5f
3 changed files with 26 additions and 6 deletions

21
src/consensus/mod.rs Normal file
View File

@ -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 <http://creativecommons.org/publicdomain/zero/1.0/>.
//
//! Consensus
//!
//! This module defines structures, functions, and traits which are needed to
//! conform to Bitcoin consensus.
//!
pub mod params;

View File

@ -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

View File

@ -23,7 +23,6 @@ use std::io;
use std::error;
pub mod constants;
pub mod consensus_params;
pub mod encodable;
pub mod serialize;