From 129ce97ad57f21021873ea2e8651724d997cba1f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 23 Jun 2016 11:30:48 +0200 Subject: [PATCH] Constants for SF# and update. --- ethcore/src/block.rs | 3 ++- ethcore/src/client/mod.rs | 12 ++++++------ ethcore/src/env_info.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index ff05b5af1..f7288c85b 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -288,6 +288,7 @@ impl<'x> OpenBlock<'x> { /// Get the environment info concerning this block. pub fn env_info(&self) -> EnvInfo { // TODO: memoise. + const SOFT_FORK_BLOCK: u64 = 1775000; EnvInfo { number: self.block.base.header.number, author: self.block.base.header.author.clone(), @@ -296,7 +297,7 @@ impl<'x> OpenBlock<'x> { last_hashes: self.last_hashes.clone(), // TODO: should be a reference. gas_used: self.block.receipts.last().map_or(U256::zero(), |r| r.gas_used), gas_limit: self.block.base.header.gas_limit.clone(), - dao_rescue_block_gas_limit: if self.block.base.header.number == 1760000 { Some(self.block.base.header.gas_limit) } else { self.dao_rescue_block_gas_limit }, + dao_rescue_block_gas_limit: if self.block.base.header.number == SOFT_FORK_BLOCK { Some(self.block.base.header.gas_limit) } else { self.dao_rescue_block_gas_limit }, } } diff --git a/ethcore/src/client/mod.rs b/ethcore/src/client/mod.rs index 3ed56573a..86686cb4c 100644 --- a/ethcore/src/client/mod.rs +++ b/ethcore/src/client/mod.rs @@ -225,19 +225,19 @@ pub trait BlockChainClient : Sync + Send { } } - - /// Get `Some` gas limit of block 1_760_000, or `None` if chain is not yet that long. + /// Get `Some` gas limit of SOFT_FORK_BLOCK, or `None` if chain is not yet that long. fn dao_rescue_block_gas_limit(&self, chain_hash: H256) -> Option { + const SOFT_FORK_BLOCK: u64 = 1775000; // shortcut if the canon chain is already known. - if self.chain_info().best_block_number > 1_761_000 { - return self.block_header(BlockID::Number(1_760_000)).map(|header| HeaderView::new(&header).gas_limit()); + if self.chain_info().best_block_number > SOFT_FORK_BLOCK + 1000 { + return self.block_header(BlockID::Number(SOFT_FORK_BLOCK)).map(|header| HeaderView::new(&header).gas_limit()); } // otherwise check according to `chain_hash`. if let Some(mut header) = self.block_header(BlockID::Hash(chain_hash)) { - if HeaderView::new(&header).number() < 1_760_000 { + if HeaderView::new(&header).number() < SOFT_FORK_BLOCK { None } else { - while HeaderView::new(&header).number() != 1_760_000 { + while HeaderView::new(&header).number() != SOFT_FORK_BLOCK { header = self.block_header(BlockID::Hash(HeaderView::new(&header).parent_hash())).expect("chain is complete; parent of chain entry must be in chain; qed"); } Some(HeaderView::new(&header).gas_limit()) diff --git a/ethcore/src/env_info.rs b/ethcore/src/env_info.rs index a38a31ff7..8304fcc03 100644 --- a/ethcore/src/env_info.rs +++ b/ethcore/src/env_info.rs @@ -40,7 +40,7 @@ pub struct EnvInfo { /// The gas used. pub gas_used: U256, - /// Block gas limit at DAO rescue block #1760000 or None if not yet there. + /// Block gas limit at DAO rescue block SOFT_FORK_BLOCK or None if not yet there. pub dao_rescue_block_gas_limit: Option, }