--geth prevent getTransactionReceipt from using pending. (#1325)
This mimics the fucntionality of Geth and the current unratified JSONRPC spec (but not the functionality of eth and the ratified spec).
This commit is contained in:
parent
8fad728e9b
commit
08522eec37
@ -385,9 +385,13 @@ impl MinerService for Miner {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn import_own_transaction<T>(&self, chain: &MiningBlockChainClient, transaction: SignedTransaction, fetch_account: T) ->
|
fn import_own_transaction<T>(
|
||||||
Result<TransactionImportResult, Error>
|
&self,
|
||||||
where T: Fn(&Address) -> AccountDetails {
|
chain: &MiningBlockChainClient,
|
||||||
|
transaction: SignedTransaction,
|
||||||
|
fetch_account: T
|
||||||
|
) -> Result<TransactionImportResult, Error> where T: Fn(&Address) -> AccountDetails {
|
||||||
|
|
||||||
let hash = transaction.hash();
|
let hash = transaction.hash();
|
||||||
trace!(target: "own_tx", "Importing transaction: {:?}", transaction);
|
trace!(target: "own_tx", "Importing transaction: {:?}", transaction);
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ impl TransactionQueue {
|
|||||||
|
|
||||||
/// Add signed transaction to queue to be verified and imported
|
/// Add signed transaction to queue to be verified and imported
|
||||||
pub fn add<T>(&mut self, tx: SignedTransaction, fetch_account: &T, origin: TransactionOrigin) -> Result<TransactionImportResult, Error>
|
pub fn add<T>(&mut self, tx: SignedTransaction, fetch_account: &T, origin: TransactionOrigin) -> Result<TransactionImportResult, Error>
|
||||||
where T: Fn(&Address) -> AccountDetails {
|
where T: Fn(&Address) -> AccountDetails {
|
||||||
|
|
||||||
trace!(target: "miner", "Importing: {:?}", tx.hash());
|
trace!(target: "miner", "Importing: {:?}", tx.hash());
|
||||||
|
|
||||||
|
@ -168,9 +168,10 @@ Virtual Machine Options:
|
|||||||
--jitvm Enable the JIT VM.
|
--jitvm Enable the JIT VM.
|
||||||
|
|
||||||
Legacy Options:
|
Legacy Options:
|
||||||
--geth Run in Geth-compatibility mode. Currently just sets
|
--geth Run in Geth-compatibility mode. Sets the IPC path
|
||||||
the IPC path to be the same as Geth's. Overrides
|
to be the same as Geth's. Overrides the --ipc-path
|
||||||
the --ipc-path/--ipcpath options.
|
and --ipcpath options. Alters RPCs to reflect Geth
|
||||||
|
bugs.
|
||||||
--testnet Geth-compatible testnet mode. Equivalent to --chain
|
--testnet Geth-compatible testnet mode. Equivalent to --chain
|
||||||
testnet --keys-path $HOME/parity/testnet-keys.
|
testnet --keys-path $HOME/parity/testnet-keys.
|
||||||
Overrides the --keys-path option.
|
Overrides the --keys-path option.
|
||||||
|
@ -222,6 +222,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
|||||||
external_miner: external_miner.clone(),
|
external_miner: external_miner.clone(),
|
||||||
logger: logger.clone(),
|
logger: logger.clone(),
|
||||||
settings: network_settings.clone(),
|
settings: network_settings.clone(),
|
||||||
|
allow_pending_receipt_query: !conf.args.flag_geth,
|
||||||
});
|
});
|
||||||
|
|
||||||
let dependencies = rpc::Dependencies {
|
let dependencies = rpc::Dependencies {
|
||||||
|
@ -88,6 +88,7 @@ pub struct Dependencies {
|
|||||||
pub external_miner: Arc<ExternalMiner>,
|
pub external_miner: Arc<ExternalMiner>,
|
||||||
pub logger: Arc<RotatingLogger>,
|
pub logger: Arc<RotatingLogger>,
|
||||||
pub settings: Arc<NetworkSettings>,
|
pub settings: Arc<NetworkSettings>,
|
||||||
|
pub allow_pending_receipt_query: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_modules(apis: &[Api]) -> BTreeMap<String, String> {
|
fn to_modules(apis: &[Api]) -> BTreeMap<String, String> {
|
||||||
@ -143,7 +144,7 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
|
|||||||
server.add_delegate(NetClient::new(&deps.sync).to_delegate());
|
server.add_delegate(NetClient::new(&deps.sync).to_delegate());
|
||||||
},
|
},
|
||||||
Api::Eth => {
|
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());
|
server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate());
|
||||||
|
|
||||||
if deps.signer_port.is_some() {
|
if deps.signer_port.is_some() {
|
||||||
|
@ -123,7 +123,7 @@ impl Configuration {
|
|||||||
accs.insert(Address::from(1), TestAccount::new("test"));
|
accs.insert(Address::from(1), TestAccount::new("test"));
|
||||||
let accounts = Arc::new(TestAccountProvider::new(accs));
|
let accounts = Arc::new(TestAccountProvider::new(accs));
|
||||||
let server = rpc::RpcServer::new();
|
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());
|
server.add_delegate(EthFilterClient::new(&client, &miner).to_delegate());
|
||||||
|
|
||||||
let url = format!("{}:{}", self.args.flag_jsonrpc_addr, self.args.flag_jsonrpc_port);
|
let url = format!("{}:{}", self.args.flag_jsonrpc_addr, self.args.flag_jsonrpc_port);
|
||||||
|
@ -54,6 +54,7 @@ pub struct EthClient<C, S, A, M, EM> where
|
|||||||
miner: Weak<M>,
|
miner: Weak<M>,
|
||||||
external_miner: Arc<EM>,
|
external_miner: Arc<EM>,
|
||||||
seed_compute: Mutex<SeedHashCompute>,
|
seed_compute: Mutex<SeedHashCompute>,
|
||||||
|
allow_pending_receipt_query: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
|
impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
|
||||||
@ -64,7 +65,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
|
|||||||
EM: ExternalMinerService {
|
EM: ExternalMinerService {
|
||||||
|
|
||||||
/// Creates new EthClient.
|
/// Creates new EthClient.
|
||||||
pub fn new(client: &Arc<C>, sync: &Arc<S>, accounts: &Arc<A>, miner: &Arc<M>, em: &Arc<EM>)
|
pub fn new(client: &Arc<C>, sync: &Arc<S>, accounts: &Arc<A>, miner: &Arc<M>, em: &Arc<EM>, allow_pending_receipt_query: bool)
|
||||||
-> EthClient<C, S, A, M, EM> {
|
-> EthClient<C, S, A, M, EM> {
|
||||||
EthClient {
|
EthClient {
|
||||||
client: Arc::downgrade(client),
|
client: Arc::downgrade(client),
|
||||||
@ -73,6 +74,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM> where
|
|||||||
accounts: Arc::downgrade(accounts),
|
accounts: Arc::downgrade(accounts),
|
||||||
external_miner: em.clone(),
|
external_miner: em.clone(),
|
||||||
seed_compute: Mutex::new(SeedHashCompute::new()),
|
seed_compute: Mutex::new(SeedHashCompute::new()),
|
||||||
|
allow_pending_receipt_query: allow_pending_receipt_query,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,8 +425,8 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM> where
|
|||||||
.and_then(|(hash,)| {
|
.and_then(|(hash,)| {
|
||||||
let miner = take_weak!(self.miner);
|
let miner = take_weak!(self.miner);
|
||||||
match miner.pending_receipts().get(&hash) {
|
match miner.pending_receipts().get(&hash) {
|
||||||
Some(receipt) => to_value(&Receipt::from(receipt.clone())),
|
Some(receipt) if self.allow_pending_receipt_query => to_value(&Receipt::from(receipt.clone())),
|
||||||
None => {
|
_ => {
|
||||||
let client = take_weak!(self.client);
|
let client = take_weak!(self.client);
|
||||||
let receipt = client.transaction_receipt(TransactionID::Hash(hash));
|
let receipt = client.transaction_receipt(TransactionID::Hash(hash));
|
||||||
to_value(&receipt.map(Receipt::from))
|
to_value(&receipt.map(Receipt::from))
|
||||||
|
@ -107,7 +107,8 @@ impl EthTester {
|
|||||||
&sync_provider,
|
&sync_provider,
|
||||||
&account_provider,
|
&account_provider,
|
||||||
&miner_service,
|
&miner_service,
|
||||||
&external_miner
|
&external_miner,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
let eth_sign = EthSigningUnsafeClient::new(
|
let eth_sign = EthSigningUnsafeClient::new(
|
||||||
&client,
|
&client,
|
||||||
|
@ -71,7 +71,7 @@ impl Default for EthTester {
|
|||||||
let miner = miner_service();
|
let miner = miner_service();
|
||||||
let hashrates = Arc::new(RwLock::new(HashMap::new()));
|
let hashrates = Arc::new(RwLock::new(HashMap::new()));
|
||||||
let external_miner = Arc::new(ExternalMiner::new(hashrates.clone()));
|
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 sign = EthSigningUnsafeClient::new(&client, &ap, &miner).to_delegate();
|
||||||
let io = IoHandler::new();
|
let io = IoHandler::new();
|
||||||
io.add_delegate(eth);
|
io.add_delegate(eth);
|
||||||
|
Loading…
Reference in New Issue
Block a user