uahf: renamed magic -> network
This commit is contained in:
parent
2106846e9c
commit
4a37e74444
|
@ -11,7 +11,7 @@ pub const BITCOIN_CASH_FORK_BLOCK: u32 = 478559; // https://blockchair.com/bitco
|
|||
/// Parameters that influence chain consensus.
|
||||
pub struct ConsensusParams {
|
||||
/// Network.
|
||||
pub magic: Magic,
|
||||
pub network: Magic,
|
||||
/// Time when BIP16 becomes active.
|
||||
/// See https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
|
||||
pub bip16_time: u32,
|
||||
|
@ -59,7 +59,7 @@ impl ConsensusParams {
|
|||
pub fn new(magic: Magic, fork: ConsensusFork) -> Self {
|
||||
match magic {
|
||||
Magic::Mainnet | Magic::Other(_) => ConsensusParams {
|
||||
magic: magic,
|
||||
network: magic,
|
||||
bip16_time: 1333238400, // Apr 1 2012
|
||||
bip34_height: 227931, // 000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8
|
||||
bip65_height: 388381, // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
|
||||
|
@ -77,7 +77,7 @@ impl ConsensusParams {
|
|||
segwit_deployment: None,
|
||||
},
|
||||
Magic::Testnet => ConsensusParams {
|
||||
magic: magic,
|
||||
network: magic,
|
||||
bip16_time: 1333238400, // Apr 1 2012
|
||||
bip34_height: 21111, // 0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8
|
||||
bip65_height: 581885, // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
|
||||
|
@ -95,7 +95,7 @@ impl ConsensusParams {
|
|||
segwit_deployment: None,
|
||||
},
|
||||
Magic::Regtest | Magic::Unitest => ConsensusParams {
|
||||
magic: magic,
|
||||
network: magic,
|
||||
bip16_time: 1333238400, // Apr 1 2012
|
||||
bip34_height: 100000000, // not activated on regtest
|
||||
bip65_height: 1351,
|
||||
|
|
|
@ -89,7 +89,7 @@ pub fn create_local_sync_node(consensus: ConsensusParams, db: db::SharedStore, p
|
|||
use utils::SynchronizationState;
|
||||
use types::SynchronizationStateRef;
|
||||
|
||||
let network = consensus.magic;
|
||||
let network = consensus.network;
|
||||
let sync_client_config = SynchronizationConfig {
|
||||
// during regtests, peer is providing us with bad blocks => we shouldn't close connection because of this
|
||||
close_connection_on_bad_block: network != Magic::Regtest,
|
||||
|
|
|
@ -33,7 +33,7 @@ impl BackwardsCompatibleChainVerifier {
|
|||
fn verify_block(&self, block: &IndexedBlock) -> Result<(), Error> {
|
||||
let current_time = ::time::get_time().sec as u32;
|
||||
// first run pre-verification
|
||||
let chain_verifier = ChainVerifier::new(block, self.consensus.magic, current_time);
|
||||
let chain_verifier = ChainVerifier::new(block, self.consensus.network, current_time);
|
||||
chain_verifier.check()?;
|
||||
|
||||
assert_eq!(Some(self.store.best_block().hash), self.store.block_hash(self.store.best_block().number));
|
||||
|
@ -79,7 +79,7 @@ impl BackwardsCompatibleChainVerifier {
|
|||
// TODO: full verification
|
||||
let current_time = ::time::get_time().sec as u32;
|
||||
let header = IndexedBlockHeader::new(hash.clone(), header.clone());
|
||||
let header_verifier = HeaderVerifier::new(&header, self.consensus.magic, current_time);
|
||||
let header_verifier = HeaderVerifier::new(&header, self.consensus.network, current_time);
|
||||
header_verifier.check()
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn retarget_timespan(retarget_timestamp: u32, last_timestamp: u32) -> u32 {
|
|||
|
||||
/// Returns work required for given header
|
||||
pub fn work_required(parent_hash: H256, time: u32, height: u32, store: &BlockHeaderProvider, consensus: &ConsensusParams) -> Compact {
|
||||
let max_bits = consensus.magic.max_bits();
|
||||
let max_bits = consensus.network.max_bits();
|
||||
if height == 0 {
|
||||
return max_bits;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ pub fn work_required(parent_hash: H256, time: u32, height: u32, store: &BlockHea
|
|||
return work_required_retarget(max_bits, retarget_timestamp, last_timestamp, last_bits);
|
||||
}
|
||||
|
||||
if consensus.magic == Magic::Testnet {
|
||||
if consensus.network == Magic::Testnet {
|
||||
return work_required_testnet(parent_hash, time, height, store, Magic::Testnet)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue