diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index ef59de1ec..c5dff80d0 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -385,9 +385,13 @@ impl MinerService for Miner { .collect() } - fn import_own_transaction(&self, chain: &MiningBlockChainClient, transaction: SignedTransaction, fetch_account: T) -> - Result - where T: Fn(&Address) -> AccountDetails { + fn import_own_transaction( + &self, + chain: &MiningBlockChainClient, + transaction: SignedTransaction, + fetch_account: T + ) -> Result where T: Fn(&Address) -> AccountDetails { + let hash = transaction.hash(); trace!(target: "own_tx", "Importing transaction: {:?}", transaction); diff --git a/ethcore/src/miner/transaction_queue.rs b/ethcore/src/miner/transaction_queue.rs index 8f34d78d1..98aa492d1 100644 --- a/ethcore/src/miner/transaction_queue.rs +++ b/ethcore/src/miner/transaction_queue.rs @@ -425,7 +425,7 @@ impl TransactionQueue { /// Add signed transaction to queue to be verified and imported pub fn add(&mut self, tx: SignedTransaction, fetch_account: &T, origin: TransactionOrigin) -> Result - where T: Fn(&Address) -> AccountDetails { + where T: Fn(&Address) -> AccountDetails { trace!(target: "miner", "Importing: {:?}", tx.hash()); diff --git a/parity/cli.rs b/parity/cli.rs index 6fe38224a..38af6af4c 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -168,9 +168,10 @@ Virtual Machine Options: --jitvm Enable the JIT VM. Legacy Options: - --geth Run in Geth-compatibility mode. Currently just sets - the IPC path to be the same as Geth's. Overrides - the --ipc-path/--ipcpath options. + --geth Run in Geth-compatibility mode. Sets the IPC path + to be the same as Geth's. Overrides the --ipc-path + and --ipcpath options. Alters RPCs to reflect Geth + bugs. --testnet Geth-compatible testnet mode. Equivalent to --chain testnet --keys-path $HOME/parity/testnet-keys. Overrides the --keys-path option. diff --git a/parity/main.rs b/parity/main.rs index 973b1174f..cfa44f6ee 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -222,6 +222,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) external_miner: external_miner.clone(), logger: logger.clone(), settings: network_settings.clone(), + allow_pending_receipt_query: !conf.args.flag_geth, }); let dependencies = rpc::Dependencies { diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 016f347aa..feefc89c0 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -88,6 +88,7 @@ pub struct Dependencies { pub external_miner: Arc, pub logger: Arc, pub settings: Arc, + pub allow_pending_receipt_query: bool, } fn to_modules(apis: &[Api]) -> BTreeMap { @@ -143,7 +144,7 @@ pub fn setup_rpc(server: T, deps: Arc, apis: ApiSet server.add_delegate(NetClient::new(&deps.sync).to_delegate()); }, Api::Eth => { - server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate()); + server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner, deps.allow_pending_receipt_query).to_delegate()); server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate()); if deps.signer_port.is_some() { diff --git a/rpc/rpctest/src/main.rs b/rpc/rpctest/src/main.rs index 6cc747959..139514cb1 100644 --- a/rpc/rpctest/src/main.rs +++ b/rpc/rpctest/src/main.rs @@ -123,7 +123,7 @@ impl Configuration { accs.insert(Address::from(1), TestAccount::new("test")); let accounts = Arc::new(TestAccountProvider::new(accs)); let server = rpc::RpcServer::new(); - server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner).to_delegate()); + server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner, true).to_delegate()); server.add_delegate(EthFilterClient::new(&client, &miner).to_delegate()); let url = format!("{}:{}", self.args.flag_jsonrpc_addr, self.args.flag_jsonrpc_port); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index bd9384dfe..2c070cab9 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -54,6 +54,7 @@ pub struct EthClient where miner: Weak, external_miner: Arc, seed_compute: Mutex, + allow_pending_receipt_query: bool, } impl EthClient where @@ -64,7 +65,7 @@ impl EthClient where EM: ExternalMinerService { /// Creates new EthClient. - pub fn new(client: &Arc, sync: &Arc, accounts: &Arc, miner: &Arc, em: &Arc) + pub fn new(client: &Arc, sync: &Arc, accounts: &Arc, miner: &Arc, em: &Arc, allow_pending_receipt_query: bool) -> EthClient { EthClient { client: Arc::downgrade(client), @@ -73,6 +74,7 @@ impl EthClient where accounts: Arc::downgrade(accounts), external_miner: em.clone(), seed_compute: Mutex::new(SeedHashCompute::new()), + allow_pending_receipt_query: allow_pending_receipt_query, } } @@ -423,8 +425,8 @@ impl Eth for EthClient where .and_then(|(hash,)| { let miner = take_weak!(self.miner); match miner.pending_receipts().get(&hash) { - Some(receipt) => to_value(&Receipt::from(receipt.clone())), - None => { + Some(receipt) if self.allow_pending_receipt_query => to_value(&Receipt::from(receipt.clone())), + _ => { let client = take_weak!(self.client); let receipt = client.transaction_receipt(TransactionID::Hash(hash)); to_value(&receipt.map(Receipt::from)) diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index a7f7920ad..5d7c72ac0 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -107,7 +107,8 @@ impl EthTester { &sync_provider, &account_provider, &miner_service, - &external_miner + &external_miner, + true ); let eth_sign = EthSigningUnsafeClient::new( &client, diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 45f8bd366..2fcd8a266 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -71,7 +71,7 @@ impl Default for EthTester { let miner = miner_service(); let hashrates = Arc::new(RwLock::new(HashMap::new())); let external_miner = Arc::new(ExternalMiner::new(hashrates.clone())); - let eth = EthClient::new(&client, &sync, &ap, &miner, &external_miner).to_delegate(); + let eth = EthClient::new(&client, &sync, &ap, &miner, &external_miner, true).to_delegate(); let sign = EthSigningUnsafeClient::new(&client, &ap, &miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(eth);