Reorder transaction_by_hash to favour canon search (#2331)
* Reorder transaction_by_hash to favour canon search * Fix test.
This commit is contained in:
parent
16f3119547
commit
6f772a28e2
@ -348,11 +348,11 @@ impl BlockChainClient for TestBlockChainClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn transaction(&self, _id: TransactionID) -> Option<LocalizedTransaction> {
|
fn transaction(&self, _id: TransactionID) -> Option<LocalizedTransaction> {
|
||||||
unimplemented!();
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uncle(&self, _id: UncleID) -> Option<Bytes> {
|
fn uncle(&self, _id: UncleID) -> Option<Bytes> {
|
||||||
unimplemented!();
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transaction_receipt(&self, id: TransactionID) -> Option<LocalizedReceipt> {
|
fn transaction_receipt(&self, id: TransactionID) -> Option<LocalizedReceipt> {
|
||||||
|
@ -433,11 +433,14 @@ impl<C, S: ?Sized, M, EM> Eth for EthClient<C, S, M, EM> where
|
|||||||
try!(self.active());
|
try!(self.active());
|
||||||
from_params::<(RpcH256,)>(params)
|
from_params::<(RpcH256,)>(params)
|
||||||
.and_then(|(hash,)| {
|
.and_then(|(hash,)| {
|
||||||
let miner = take_weak!(self.miner);
|
|
||||||
let hash: H256 = hash.into();
|
let hash: H256 = hash.into();
|
||||||
match miner.transaction(&hash) {
|
let miner = take_weak!(self.miner);
|
||||||
Some(pending_tx) => to_value(&Transaction::from(pending_tx)),
|
let client = take_weak!(self.client);
|
||||||
None => self.transaction(TransactionID::Hash(hash))
|
let maybe_tx = client.transaction(TransactionID::Hash(hash)).map(Transaction::from)
|
||||||
|
.or_else(|| miner.transaction(&hash).map(Transaction::from));
|
||||||
|
match maybe_tx {
|
||||||
|
Some(t) => to_value(&t),
|
||||||
|
None => Ok(Value::Null),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user