Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
removed additional_params method (#10818)
Browse files Browse the repository at this point in the history
  • Loading branch information
debris authored and dvdplm committed Jun 29, 2019
1 parent c1b3d5f commit 8fc504e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 48 deletions.
7 changes: 1 addition & 6 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use std::cmp;
use std::collections::{HashSet, BTreeMap, VecDeque};
use std::str::FromStr;
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
use std::sync::{Arc, Weak};
use std::time::{Instant, Duration};
Expand Down Expand Up @@ -753,7 +752,7 @@ impl Client {

let importer = Importer::new(&config, engine.clone(), message_channel.clone(), miner)?;

let registrar_address = engine.additional_params().get("registrar").and_then(|s| Address::from_str(s).ok());
let registrar_address = engine.machine().params().registrar;
if let Some(ref addr) = registrar_address {
trace!(target: "client", "Found registrar at {}", addr);
}
Expand Down Expand Up @@ -1982,10 +1981,6 @@ impl BlockChainClient for Client {
self.importer.block_queue.clear();
}

fn additional_params(&self) -> BTreeMap<String, String> {
self.engine.additional_params().into_iter().collect()
}

fn logs(&self, filter: Filter) -> Result<Vec<LocalizedLogEntry>, BlockId> {
let chain = self.chain.read();

Expand Down
4 changes: 0 additions & 4 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,6 @@ impl BlockChainClient for TestBlockChainClient {
fn clear_queue(&self) {
}

fn additional_params(&self) -> BTreeMap<String, String> {
Default::default()
}

fn filter_traces(&self, _filter: TraceFilter) -> Option<Vec<LocalizedTrace>> {
self.traces.read().clone()
}
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ pub trait BlockChainClient : Sync + Send + AccountData + BlockChain + CallContra
/// Clear block queue and abort all import activity.
fn clear_queue(&self);

/// Get the registrar address, if it exists.
fn additional_params(&self) -> BTreeMap<String, String>;

/// Returns logs matching given filter. If one of the filtering block cannot be found, returns the block id that caused the error.
fn logs(&self, filter: Filter) -> Result<Vec<LocalizedLogEntry>, BlockId>;

Expand Down
7 changes: 1 addition & 6 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use types::engines::ForkChoice;
pub use types::engines::epoch::{self, Transition as EpochTransition};

use std::sync::{Weak, Arc};
use std::collections::{BTreeMap, HashMap};
use std::collections::BTreeMap;
use std::{fmt, error};

use builtin::Builtin;
Expand Down Expand Up @@ -543,11 +543,6 @@ pub trait Engine: Sync + Send {
self.machine().verify_transaction_basic(t, header)
}

/// Additional information.
fn additional_params(&self) -> HashMap<String, String> {
self.machine().additional_params()
}

/// Performs pre-validation of RLP decoded transaction before other processing
fn decode_transaction(&self, transaction: &[u8]) -> Result<UnverifiedTransaction, transaction::Error> {
self.machine().decode_transaction(transaction)
Expand Down
9 changes: 1 addition & 8 deletions ethcore/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Ethereum-like state machine definition.

use std::collections::{BTreeMap, HashMap};
use std::collections::BTreeMap;
use std::cmp;
use std::sync::Arc;

Expand Down Expand Up @@ -385,13 +385,6 @@ impl Machine {
Ok(())
}

/// Additional params.
pub fn additional_params(&self) -> HashMap<String, String> {
hash_map![
"registrar".to_owned() => format!("{:x}", self.params.registrar)
]
}

/// Performs pre-validation of RLP decoded transaction before other processing
pub fn decode_transaction(&self, transaction: &[u8]) -> Result<UnverifiedTransaction, transaction::Error> {
let rlp = Rlp::new(&transaction);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub struct CommonParams {
/// Gas limit bound divisor (how much gas limit can change per block)
pub gas_limit_bound_divisor: U256,
/// Registrar contract address.
pub registrar: Address,
pub registrar: Option<Address>,
/// Node permission managing contract address.
pub node_permission_contract: Option<Address>,
/// Maximum contract code size that can be deployed.
Expand Down Expand Up @@ -315,7 +315,7 @@ impl From<ethjson::spec::Params> for CommonParams {
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
registrar: p.registrar.map_or_else(Address::zero, Into::into),
registrar: p.registrar.map(Into::into),
node_permission_contract: p.node_permission_contract.map(Into::into),
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
max_transaction_size: p.max_transaction_size.map_or(MAX_TRANSACTION_SIZE, Into::into),
Expand Down
7 changes: 2 additions & 5 deletions ethcore/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ fn should_return_registrar() {
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();
let params = client.additional_params();
let address = &params["registrar"];

assert_eq!(address.len(), 40);
assert!(U256::from_str(address).is_ok());
let address = client.registrar_address();
assert_eq!(address, Some("52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d".parse().unwrap()));
}

#[test]
Expand Down
7 changes: 1 addition & 6 deletions rpc/src/v1/impls/light/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,7 @@ where
}

fn registry_address(&self) -> Result<Option<H160>> {
let reg = self.light_dispatch.client.engine().params().registrar;
if reg == Default::default() {
Ok(None)
} else {
Ok(Some(reg))
}
Ok(self.light_dispatch.client.engine().params().registrar)
}

fn rpc_settings(&self) -> Result<RpcSettings> {
Expand Down
10 changes: 2 additions & 8 deletions rpc/src/v1/impls/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

//! Parity-specific rpc implementation.
use std::sync::Arc;
use std::str::FromStr;
use std::collections::BTreeMap;

use crypto::DEFAULT_MAC;
use ethereum_types::{Address, H64, H160, H256, H512, U64, U256};
use ethereum_types::{H64, H160, H256, H512, U64, U256};
use ethcore::client::{BlockChainClient, StateClient, Call};
use ethcore::miner::{self, MinerService, FilterOptions};
use ethcore::snapshot::{SnapshotService, RestorationStatus};
Expand Down Expand Up @@ -165,12 +164,7 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
}

fn registry_address(&self) -> Result<Option<H160>> {
Ok(
self.client
.additional_params()
.get("registrar")
.and_then(|s| Address::from_str(s).ok())
)
Ok(self.client.registrar_address())
}

fn rpc_settings(&self) -> Result<RpcSettings> {
Expand Down

0 comments on commit 8fc504e

Please sign in to comment.