Constants for SF# and update.

This commit is contained in:
Gav Wood
2016-06-23 11:30:48 +02:00
parent 4f39fb2551
commit 129ce97ad5
3 changed files with 9 additions and 8 deletions

View File

@@ -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<U256> {
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())