From c62bfcddef1fedaaa76eed2870071cd93846c1c7 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Tue, 31 May 2016 17:25:25 +0200 Subject: [PATCH] finish purging x! from parity, remove x! and xx! macros --- miner/src/lib.rs | 4 ++-- miner/src/miner.rs | 6 +++--- sync/src/chain.rs | 6 +++--- util/src/common.rs | 14 -------------- util/src/keys/store.rs | 2 +- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/miner/src/lib.rs b/miner/src/lib.rs index a1780efff..f91811948 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -150,10 +150,10 @@ pub trait MinerService : Send + Sync { fn last_nonce(&self, address: &Address) -> Option; /// Suggested gas price. - fn sensible_gas_price(&self) -> U256 { x!(20000000000u64) } + fn sensible_gas_price(&self) -> U256 { 20000000000u64.into() } /// Suggested gas limit. - fn sensible_gas_limit(&self) -> U256 { x!(21000) } + fn sensible_gas_limit(&self) -> U256 { 21000.into() } /// Latest account balance in pending state. fn balance(&self, chain: &BlockChainClient, address: &Address) -> U256; diff --git a/miner/src/miner.rs b/miner/src/miner.rs index fc63aec6c..d9abb09f4 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -137,7 +137,7 @@ impl Miner { Err(Error::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, .. })) => { trace!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?}", hash); // Exit early if gas left is smaller then min_tx_gas - let min_tx_gas: U256 = x!(21000); // TODO: figure this out properly. + let min_tx_gas: U256 = 21000.into(); // TODO: figure this out properly. if gas_limit - gas_used < min_tx_gas { break; } @@ -337,11 +337,11 @@ impl MinerService for Miner { fn sensible_gas_price(&self) -> U256 { // 10% above our minimum. - *self.transaction_queue.lock().unwrap().minimal_gas_price() * x!(110) / x!(100) + *self.transaction_queue.lock().unwrap().minimal_gas_price() * 110.into() / 100.into() } fn sensible_gas_limit(&self) -> U256 { - *self.gas_floor_target.read().unwrap() / x!(5) + *self.gas_floor_target.read().unwrap() / 5.into() } fn transactions_limit(&self) -> usize { diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 2f31f1d47..dcfdc1c16 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1310,8 +1310,8 @@ mod tests { fn get_dummy_block(order: u32, parent_hash: H256) -> Bytes { let mut header = Header::new(); - header.gas_limit = x!(0); - header.difficulty = x!(order * 100); + header.gas_limit = 0.into(); + header.difficulty = (order * 100).into(); header.timestamp = (order * 10) as u64; header.number = order as u64; header.parent_hash = parent_hash; @@ -1327,7 +1327,7 @@ mod tests { fn get_dummy_blocks(order: u32, parent_hash: H256) -> Bytes { let mut rlp = RlpStream::new_list(1); rlp.append_raw(&get_dummy_block(order, parent_hash), 1); - let difficulty: U256 = x!(100 * order); + let difficulty: U256 = (100 * order).into(); rlp.append(&difficulty); rlp.out() } diff --git a/util/src/common.rs b/util/src/common.rs index 7ed660f29..c1de582df 100644 --- a/util/src/common.rs +++ b/util/src/common.rs @@ -68,20 +68,6 @@ macro_rules! mapx { }} } -#[macro_export] -macro_rules! x { - ( $x:expr ) => { - From::from($x) - } -} - -#[macro_export] -macro_rules! xx { - ( $x:expr ) => { - From::from(From::from($x)) - } -} - #[macro_export] macro_rules! flush { ($($arg:tt)*) => ($crate::flush(format!("{}", format_args!($($arg)*)))); diff --git a/util/src/keys/store.rs b/util/src/keys/store.rs index 296f7ad37..3402596d3 100644 --- a/util/src/keys/store.rs +++ b/util/src/keys/store.rs @@ -627,7 +627,7 @@ mod tests { sstore.sign(&address, &H256::random()).unwrap() }; - assert!(signature != x!(0)); + assert!(signature != 0.into()); } #[test]