Fix several RPCs (#1926)

* Fix up pending receipts details.

* Add support for additional params and registry over RPC.

* Fix tests.

* Add test, additional fix.

Fixes #1932.

* Fix up tests.

* Fix test.

* Fix test.
This commit is contained in:
Gav Wood
2016-08-17 19:25:02 +02:00
committed by GitHub
parent bcf6b0b7d8
commit ccdf80f4dc
19 changed files with 163 additions and 39 deletions

View File

@@ -107,7 +107,7 @@ impl<C, S: ?Sized, M, EM> EthClient<C, S, M, EM> where
let view = block_view.header_view();
let block = Block {
hash: Some(view.sha3().into()),
size: Some(bytes.len()),
size: Some(bytes.len().into()),
parent_hash: view.parent_hash().into(),
uncles_hash: view.uncles_hash().into(),
author: view.author().into(),
@@ -460,8 +460,8 @@ impl<C, S: ?Sized, M, EM> Eth for EthClient<C, S, M, EM> where
.and_then(|(hash,)| {
let miner = take_weak!(self.miner);
let hash: H256 = hash.into();
match miner.pending_receipts().get(&hash) {
Some(receipt) if self.options.allow_pending_receipt_query => to_value(&Receipt::from(receipt.clone())),
match (miner.pending_receipt(&hash), self.options.allow_pending_receipt_query) {
(Some(receipt), true) => to_value(&Receipt::from(receipt)),
_ => {
let client = take_weak!(self.client);
let receipt = client.transaction_receipt(TransactionID::Hash(hash));

View File

@@ -15,10 +15,11 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Ethcore-specific rpc implementation.
use util::{RotatingLogger, KeyPair};
use util::misc::version_data;
use std::sync::{Arc, Weak};
use std::str::FromStr;
use std::collections::{BTreeMap};
use util::{RotatingLogger, KeyPair, Address};
use util::misc::version_data;
use ethstore::random_phrase;
use ethsync::{SyncProvider, ManageNetwork};
@@ -56,7 +57,7 @@ impl<C, M, S: ?Sized> EthcoreClient<C, M, S> where C: MiningBlockChainClient, M:
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
queue: Option<Arc<ConfirmationsQueue>>
) -> Self {
) -> Self {
EthcoreClient {
client: Arc::downgrade(client),
miner: Arc::downgrade(miner),
@@ -152,6 +153,17 @@ impl<C, M, S: ?Sized> Ethcore for EthcoreClient<C, M, S> where M: MinerService +
to_value(&self.settings.name)
}
fn registry_address(&self, params: Params) -> Result<Value, Error> {
try!(self.active());
try!(expect_no_params(params));
let r = take_weak!(self.client)
.additional_params()
.get("registrar")
.and_then(|s| Address::from_str(s).ok())
.map(|s| H160::from(s));
to_value(&r)
}
fn rpc_settings(&self, params: Params) -> Result<Value, Error> {
try!(self.active());
try!(expect_no_params(params));