Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ tempdir = "0.3"
winapi = "0.2"

[target.'cfg(not(windows))'.dependencies]
daemonize = "0.2"
daemonize = { git = "https://github.com/paritytech/daemonize" }

[features]
default = ["ui-precompiled"]
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/state/account.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct Account {
storage_changes: HashMap<H256, H256>,
// Code hash of the account.
code_hash: H256,
// Size of the accoun code.
// Size of the account code.
code_size: Option<usize>,
// Code cache of the account.
code_cache: Arc<Bytes>,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl Account {
}

/// Get (and cache) the contents of the trie's storage at `key`.
/// Takes modifed storage into account.
/// Takes modified storage into account.
pub fn storage_at(&self, db: &HashDB, key: &H256) -> trie::Result<H256> {
if let Some(value) = self.cached_storage_at(key) {
return Ok(value);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/state/mod.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl<B: Backend> State<B> {
pub fn new(mut db: B, account_start_nonce: U256, factories: Factories) -> State<B> {
let mut root = H256::new();
{
// init trie and reset root too null
// init trie and reset root to null
let _ = factories.trie.create(db.as_hashdb_mut(), &mut root);
}

Expand Down Expand Up @@ -553,8 +553,8 @@ impl<B: Backend> State<B> {
// 2. If there's an entry for the account in the global cache check for the key or load it into that account.
// 3. If account is missing in the global cache load it into the local cache and cache the key there.

// check local cache first without updating
{
// check local cache first without updating
let local_cache = self.cache.borrow_mut();
let mut local_account = None;
if let Some(maybe_acc) = local_cache.get(address) {
Expand Down
12 changes: 6 additions & 6 deletions ethcore/src/state_db.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,6 @@ impl state::Backend for StateDB {
cache.accounts.get_mut(addr).map(|a| a.as_ref().map(|a| a.clone_basic()))
}

fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>> {
let mut cache = self.code_cache.lock();

cache.get_mut(hash).map(|code| code.clone())
}

fn get_cached<F, U>(&self, a: &Address, f: F) -> Option<U>
where F: FnOnce(Option<&mut Account>) -> U {
let mut cache = self.account_cache.lock();
Expand All @@ -455,6 +449,12 @@ impl state::Backend for StateDB {
cache.accounts.get_mut(a).map(|c| f(c.as_mut()))
}

fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>> {
let mut cache = self.code_cache.lock();

cache.get_mut(hash).map(|code| code.clone())
}

fn note_non_null_account(&self, address: &Address) {
trace!(target: "account_bloom", "Note account bloom: {:?}", address);
let mut bloom = self.account_bloom.lock();
Expand Down
8 changes: 7 additions & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,12 @@ impl Configuration {
let ui = self.ui_config();
let http = self.http_config()?;

let support_token_api =
// never enabled for public node
!self.args.flag_public_node
// enabled when not unlocking unless the ui is forced
&& (self.args.arg_unlock.is_none() || ui.enabled);

let conf = WsConfiguration {
enabled: self.ws_enabled(),
interface: self.ws_interface(),
Expand All @@ -899,7 +905,7 @@ impl Configuration {
hosts: self.ws_hosts(),
origins: self.ws_origins(),
signer_path: self.directories().signer.into(),
support_token_api: !self.args.flag_public_node,
support_token_api,
ui_address: ui.address(),
dapps_address: http.address(),
};
Expand Down
2 changes: 1 addition & 1 deletion parity/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
let allowed_hosts = into_domains(with_domain(conf.hosts, domain, &Some(url.clone().into()), &None));

let signer_path;
let path = match conf.support_token_api && conf.ui_address.is_some() {
let path = match conf.support_token_api {
true => {
signer_path = ::signer::codes_path(&conf.signer_path);
Some(signer_path.as_path())
Expand Down
4 changes: 2 additions & 2 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger
let rpc_stats = Arc::new(informant::RpcStats::default());

// the dapps server
let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.ui_conf, &cmd.logger_config));
let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.logger_config));
let (node_health, dapps_deps) = {
let contract_client = ::dapps::LightRegistrar {
client: client.clone(),
Expand Down Expand Up @@ -716,7 +716,7 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
false => Some(account_provider.clone())
};

let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.ui_conf, &cmd.logger_config));
let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.logger_config));

// the dapps server
let (node_health, dapps_deps) = {
Expand Down
29 changes: 22 additions & 7 deletions parity/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ pub struct NewToken {
pub message: String,
}

pub fn new_service(ws_conf: &rpc::WsConfiguration, ui_conf: &rpc::UiConfiguration, logger_config: &LogConfig) -> rpc_apis::SignerService {
let signer_path = ws_conf.signer_path.clone();
pub fn new_service(ws_conf: &rpc::WsConfiguration, logger_config: &LogConfig) -> rpc_apis::SignerService {
let logger_config_color = logger_config.color;
let signer_enabled = ui_conf.enabled;
let signer_path = ws_conf.signer_path.clone();
let signer_enabled = ws_conf.support_token_api;

rpc_apis::SignerService::new(move || {
generate_new_token(&signer_path, logger_config_color).map_err(|e| format!("{:?}", e))
Expand All @@ -56,6 +56,24 @@ pub fn execute(ws_conf: rpc::WsConfiguration, ui_conf: rpc::UiConfiguration, log
pub fn generate_token_and_url(ws_conf: &rpc::WsConfiguration, ui_conf: &rpc::UiConfiguration, logger_config: &LogConfig) -> Result<NewToken, String> {
let code = generate_new_token(&ws_conf.signer_path, logger_config.color).map_err(|err| format!("Error generating token: {:?}", err))?;
let auth_url = format!("http://{}:{}/#/auth?token={}", ui_conf.interface, ui_conf.port, code);
let colored = |s: String| match logger_config.color {
true => format!("{}", White.bold().paint(s)),
false => s,
};

if !ui_conf.enabled {
return Ok(NewToken {
token: code.clone(),
url: auth_url.clone(),
message: format!(
r#"
Generated token:
{}
"#,
colored(code)
),
})
}

// And print in to the console
Ok(NewToken {
Expand All @@ -67,10 +85,7 @@ Open: {}
to authorize your browser.
Or use the generated token:
{}"#,
match logger_config.color {
true => format!("{}", White.bold().paint(auth_url)),
false => auth_url
},
colored(auth_url),
code
)
})
Expand Down