Added pending transaction info to eth_getTransactionByHash (#4570)
* Return condition info for pending transactions * Fixed warnings
This commit is contained in:
parent
b9665c7cfe
commit
0aad8a87ae
@ -984,7 +984,7 @@ impl MinerService for Miner {
|
||||
}
|
||||
}
|
||||
|
||||
fn transaction(&self, best_block: BlockNumber, hash: &H256) -> Option<SignedTransaction> {
|
||||
fn transaction(&self, best_block: BlockNumber, hash: &H256) -> Option<PendingTransaction> {
|
||||
let queue = self.transaction_queue.lock();
|
||||
match self.options.pending_set {
|
||||
PendingSet::AlwaysQueue => queue.find(hash),
|
||||
@ -992,14 +992,14 @@ impl MinerService for Miner {
|
||||
self.from_pending_block(
|
||||
best_block,
|
||||
|| queue.find(hash),
|
||||
|sealing| sealing.transactions().iter().find(|t| &t.hash() == hash).cloned()
|
||||
|sealing| sealing.transactions().iter().find(|t| &t.hash() == hash).cloned().map(Into::into)
|
||||
)
|
||||
},
|
||||
PendingSet::AlwaysSealing => {
|
||||
self.from_pending_block(
|
||||
best_block,
|
||||
|| None,
|
||||
|sealing| sealing.transactions().iter().find(|t| &t.hash() == hash).cloned()
|
||||
|sealing| sealing.transactions().iter().find(|t| &t.hash() == hash).cloned().map(Into::into)
|
||||
)
|
||||
},
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ pub trait MinerService : Send + Sync {
|
||||
where F: FnOnce(&ClosedBlock) -> T, Self: Sized;
|
||||
|
||||
/// Query pending transactions for hash.
|
||||
fn transaction(&self, best_block: BlockNumber, hash: &H256) -> Option<SignedTransaction>;
|
||||
fn transaction(&self, best_block: BlockNumber, hash: &H256) -> Option<PendingTransaction>;
|
||||
|
||||
/// Get a list of all pending transactions in the queue.
|
||||
fn pending_transactions(&self) -> Vec<PendingTransaction>;
|
||||
|
@ -1137,8 +1137,8 @@ impl TransactionQueue {
|
||||
}
|
||||
|
||||
/// Finds transaction in the queue by hash (if any)
|
||||
pub fn find(&self, hash: &H256) -> Option<SignedTransaction> {
|
||||
self.by_hash.get(hash).map(|tx| tx.transaction.clone())
|
||||
pub fn find(&self, hash: &H256) -> Option<PendingTransaction> {
|
||||
self.by_hash.get(hash).map(|tx| PendingTransaction { transaction: tx.transaction.clone(), condition: tx.condition.clone() })
|
||||
}
|
||||
|
||||
/// Removes all elements (in any state) from the queue
|
||||
|
@ -200,8 +200,8 @@ impl MinerService for TestMinerService {
|
||||
Some(f(&open_block.close()))
|
||||
}
|
||||
|
||||
fn transaction(&self, _best_block: BlockNumber, hash: &H256) -> Option<SignedTransaction> {
|
||||
self.pending_transactions.lock().get(hash).cloned()
|
||||
fn transaction(&self, _best_block: BlockNumber, hash: &H256) -> Option<PendingTransaction> {
|
||||
self.pending_transactions.lock().get(hash).cloned().map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Vec<PendingTransaction> {
|
||||
|
@ -504,7 +504,6 @@ pub type H256FastSet = HashSet<H256, BuildHasherDefault<PlainHasher>>;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hash::*;
|
||||
use bigint::*;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
|
@ -556,7 +556,6 @@ impl Discovery {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::net::{SocketAddr};
|
||||
use util::sha3::Hashable;
|
||||
use util::FixedHash;
|
||||
use node_table::{Node, NodeId, NodeEndpoint};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user