From 6ebd5009fc967c5c9b444007d67c6d7e8d3ecc04 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 9 Apr 2016 12:58:13 -0700 Subject: [PATCH 1/3] --unlock is comma-delimited. --- parity/main.rs | 20 +++++++++++--------- rpc/src/v1/impls/eth.rs | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index 8ee9c6f63..287392d4e 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -104,7 +104,8 @@ Protocol Options: --identity NAME Specify your node's name. Account Options: - --unlock ACCOUNT Unlock ACCOUNT for the duration of the execution. + --unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution. + ACCOUNTS is a comma-delimited list of addresses. --password FILE Provide a file containing a password for unlocking an account. @@ -213,7 +214,7 @@ struct Args { flag_chain: String, flag_db_path: String, flag_identity: String, - flag_unlock: Vec, + flag_unlock: Option, flag_password: Vec, flag_cache: Option, flag_keys_path: String, @@ -617,14 +618,15 @@ impl Configuration { .collect::>() .into_iter() }).collect::>(); - let account_service = AccountService::new_in(Path::new(&self.keys_path())); - for d in &self.args.flag_unlock { - let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| { - die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d) - }); - if passwords.iter().find(|p| account_service.unlock_account_no_expire(&a, p).is_ok()).is_none() { - die!("No password given to unlock account {}. Pass the password using `--password`.", a); + if let Some(ref unlocks) = self.args.flag_unlock { + for d in unlocks.split(',') { + let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| { + die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d) + }); + if passwords.iter().find(|p| account_service.unlock_account_no_expire(&a, p).is_ok()).is_none() { + die!("No password given to unlock account {}. Pass the password using `--password`.", a); + } } } account_service diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index ad4b037df..5ecbfefa2 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -465,7 +465,7 @@ impl Eth for EthClient fn submit_work(&self, params: Params) -> Result { from_params::<(H64, H256, H256)>(params).and_then(|(nonce, pow_hash, mix_hash)| { -// trace!("Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash); + trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash); let miner = take_weak!(self.miner); let client = take_weak!(self.client); let seal = vec![encode(&mix_hash).to_vec(), encode(&nonce).to_vec()]; From fed853593bc7863a0d16b4146181f1fe72d962f0 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Sun, 10 Apr 2016 20:42:03 +0200 Subject: [PATCH 2/3] fixed eth_getLogs (#915) * fixed eth_getLogs * removed empty lines --- rpc/src/v1/helpers/poll_manager.rs | 1 - rpc/src/v1/impls/eth.rs | 23 +++++++++++++++++++++-- rpc/src/v1/traits/eth.rs | 5 ++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/rpc/src/v1/helpers/poll_manager.rs b/rpc/src/v1/helpers/poll_manager.rs index 9735d7d5d..bc3518830 100644 --- a/rpc/src/v1/helpers/poll_manager.rs +++ b/rpc/src/v1/helpers/poll_manager.rs @@ -61,7 +61,6 @@ impl PollManager where T: Timer { } // Implementation is always using `poll_mut` - #[cfg(test)] /// Get a reference to stored poll filter pub fn poll(&mut self, id: &PollId) -> Option<&F> { self.polls.prune(); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index ad4b037df..8e1ca72fb 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -636,10 +636,11 @@ impl EthFilter for EthFilterClient to_value(&diff) }, - PollFilter::Logs(ref mut block_number, ref mut filter) => { + PollFilter::Logs(ref mut block_number, ref filter) => { + let mut filter = filter.clone(); filter.from_block = BlockId::Number(*block_number); filter.to_block = BlockId::Latest; - let logs = client.logs(filter.clone()) + let logs = client.logs(filter) .into_iter() .map(From::from) .collect::>(); @@ -654,6 +655,24 @@ impl EthFilter for EthFilterClient }) } + fn filter_logs(&self, params: Params) -> Result { + from_params::<(Index,)>(params) + .and_then(|(index,)| { + let mut polls = self.polls.lock().unwrap(); + match polls.poll(&index.value()) { + Some(&PollFilter::Logs(ref _block_number, ref filter)) => { + let logs = take_weak!(self.client).logs(filter.clone()) + .into_iter() + .map(From::from) + .collect::>(); + to_value(&logs) + }, + // just empty array + _ => Ok(Value::Array(vec![] as Vec)), + } + }) + } + fn uninstall_filter(&self, params: Params) -> Result { from_params::<(Index,)>(params) .and_then(|(index,)| { diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 5d36da670..a28f72c5c 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -190,6 +190,9 @@ pub trait EthFilter: Sized + Send + Sync + 'static { /// Returns filter changes since last poll. fn filter_changes(&self, _: Params) -> Result { rpc_unimplemented!() } + /// Returns all logs matching given filter (in a range 'from' - 'to'). + fn filter_logs(&self, _: Params) -> Result { rpc_unimplemented!() } + /// Uninstalls filter. fn uninstall_filter(&self, _: Params) -> Result { rpc_unimplemented!() } @@ -200,7 +203,7 @@ pub trait EthFilter: Sized + Send + Sync + 'static { delegate.add_method("eth_newBlockFilter", EthFilter::new_block_filter); delegate.add_method("eth_newPendingTransactionFilter", EthFilter::new_pending_transaction_filter); delegate.add_method("eth_getFilterChanges", EthFilter::filter_changes); - delegate.add_method("eth_getFilterLogs", EthFilter::filter_changes); + delegate.add_method("eth_getFilterLogs", EthFilter::filter_logs); delegate.add_method("eth_uninstallFilter", EthFilter::uninstall_filter); delegate } From 6c35c5e604ae6efe512a3933f8b270eb4060b7dd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 10 Apr 2016 14:01:41 -0700 Subject: [PATCH 3/3] --unlock is comma-delimited. (#916) --- parity/main.rs | 20 +++++++++++--------- rpc/src/v1/impls/eth.rs | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index 8ee9c6f63..287392d4e 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -104,7 +104,8 @@ Protocol Options: --identity NAME Specify your node's name. Account Options: - --unlock ACCOUNT Unlock ACCOUNT for the duration of the execution. + --unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution. + ACCOUNTS is a comma-delimited list of addresses. --password FILE Provide a file containing a password for unlocking an account. @@ -213,7 +214,7 @@ struct Args { flag_chain: String, flag_db_path: String, flag_identity: String, - flag_unlock: Vec, + flag_unlock: Option, flag_password: Vec, flag_cache: Option, flag_keys_path: String, @@ -617,14 +618,15 @@ impl Configuration { .collect::>() .into_iter() }).collect::>(); - let account_service = AccountService::new_in(Path::new(&self.keys_path())); - for d in &self.args.flag_unlock { - let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| { - die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d) - }); - if passwords.iter().find(|p| account_service.unlock_account_no_expire(&a, p).is_ok()).is_none() { - die!("No password given to unlock account {}. Pass the password using `--password`.", a); + if let Some(ref unlocks) = self.args.flag_unlock { + for d in unlocks.split(',') { + let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| { + die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d) + }); + if passwords.iter().find(|p| account_service.unlock_account_no_expire(&a, p).is_ok()).is_none() { + die!("No password given to unlock account {}. Pass the password using `--password`.", a); + } } } account_service diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 8e1ca72fb..1d973f933 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -465,7 +465,7 @@ impl Eth for EthClient fn submit_work(&self, params: Params) -> Result { from_params::<(H64, H256, H256)>(params).and_then(|(nonce, pow_hash, mix_hash)| { -// trace!("Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash); + trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash); let miner = take_weak!(self.miner); let client = take_weak!(self.client); let seal = vec![encode(&mix_hash).to_vec(), encode(&nonce).to_vec()];