--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:
@@ -54,6 +54,7 @@ pub struct EthClient<C, S, A, M, EM> where
|
||||
miner: Weak<M>,
|
||||
external_miner: Arc<EM>,
|
||||
seed_compute: Mutex<SeedHashCompute>,
|
||||
allow_pending_receipt_query: bool,
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
/// 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 {
|
||||
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),
|
||||
external_miner: em.clone(),
|
||||
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,)| {
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user