Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Jul 3, 2018
1 parent a02d32a commit 7a504ab
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
3 changes: 1 addition & 2 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ impl miner::MinerService for Miner {
self.transaction_queue.all_transactions()
}

fn pending_transactions_hashes<C>(&self, chain: &C) -> BTreeSet<H256> where
fn pending_transaction_hashes<C>(&self, chain: &C) -> BTreeSet<H256> where
C: ChainInfo + Sync,
{
let chain_info = chain.chain_info();
Expand Down Expand Up @@ -1107,7 +1107,6 @@ impl miner::MinerService for Miner {
let gas_limit = *chain.best_block_header().gas_limit();
self.update_transaction_queue_limits(gas_limit);


// Then import all transactions...
let client = self.pool_client(chain);
{
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ pub trait MinerService : Send + Sync {
fn next_nonce<C>(&self, chain: &C, address: &Address) -> U256
where C: Nonce + Sync;

/// Get a set of all pending transactions hashes.
/// Get a set of all pending transaction hashes.
///
/// Depending on the settings may look in transaction pool or only in pending block.
fn pending_transactions_hashes<C>(&self, chain: &C) -> BTreeSet<H256> where
fn pending_transaction_hashes<C>(&self, chain: &C) -> BTreeSet<H256> where
C: ChainInfo + Sync;

/// Get a list of all ready transactions either ordered by priority or unordered (cheaper).
Expand Down
5 changes: 5 additions & 0 deletions miner/src/pool/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ impl txpool::Ready<VerifiedTransaction> for Condition {
}
}

/// Readiness checker that only relies on nonce cache (does actually go to state).
///
/// Checks readiness of transactions by comparing the nonce to state nonce. If nonce
/// isn't found in provided state nonce store, defaults to the tx nonce and updates
/// the nonce store. Useful for using with a state nonce cache when false positives are allowed.
pub struct OptionalState<C> {
nonces: HashMap<Address, U256>,
state: C,
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/helpers/poll_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl SyncPollFilter {
pub enum PollFilter {
/// Number of last block which client was notified about.
Block(BlockNumber),
/// Hashes of all transactions which client was notified about.
/// Hashes of all pending transactions the client knows about.
PendingTransaction(BTreeSet<H256>),
/// Number of From block number, last seen block hash, pending logs and log filter itself.
Logs(BlockNumber, Option<H256>, HashSet<Log>, Filter)
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>> {
Box::new(future::ok(match num {
BlockNumber::Pending =>
Some(self.miner.pending_transactions_hashes(&*self.client).len().into()),
Some(self.miner.pending_transaction_hashes(&*self.client).len().into()),
_ =>
self.client.block(block_number_to_id(num)).map(|block| block.transactions_count().into())
}))
Expand Down
10 changes: 5 additions & 5 deletions rpc/src/v1/impls/eth_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait Filterable {
fn block_hash(&self, id: BlockId) -> Option<H256>;

/// pending transaction hashes at the given block (unordered).
fn pending_transactions_hashes(&self) -> BTreeSet<H256>;
fn pending_transaction_hashes(&self) -> BTreeSet<H256>;

/// Get logs that match the given filter.
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>>;
Expand Down Expand Up @@ -87,8 +87,8 @@ impl<C, M> Filterable for EthFilterClient<C, M> where
self.client.block_hash(id)
}

fn pending_transactions_hashes(&self) -> BTreeSet<H256> {
self.miner.pending_transactions_hashes(&*self.client)
fn pending_transaction_hashes(&self) -> BTreeSet<H256> {
self.miner.pending_transaction_hashes(&*self.client)
}

fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>> {
Expand Down Expand Up @@ -153,7 +153,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {

fn new_pending_transaction_filter(&self) -> Result<RpcU256> {
let mut polls = self.polls().lock();
let pending_transactions = self.pending_transactions_hashes();
let pending_transactions = self.pending_transaction_hashes();
let id = polls.create_poll(SyncPollFilter::new(PollFilter::PendingTransaction(pending_transactions)));
Ok(id.into())
}
Expand All @@ -179,7 +179,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
},
PollFilter::PendingTransaction(ref mut previous_hashes) => {
// get hashes of pending transactions
let current_hashes = self.pending_transactions_hashes();
let current_hashes = self.pending_transaction_hashes();

let new_hashes = {
// find all new hashes
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/impls/light/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl<T: LightChainClient + 'static> Filterable for EthClient<T> {
self.client.block_hash(id)
}

fn pending_transactions_hashes(&self) -> BTreeSet<::ethereum_types::H256> {
fn pending_transaction_hashes(&self) -> BTreeSet<::ethereum_types::H256> {
BTreeSet::new()
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/helpers/miner_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl MinerService for TestMinerService {
self.queued_transactions()
}

fn pending_transactions_hashes<C>(&self, _chain: &C) -> BTreeSet<H256> {
fn pending_transaction_hashes<C>(&self, _chain: &C) -> BTreeSet<H256> {
self.queued_transactions().into_iter().map(|tx| tx.signed().hash()).collect()
}

Expand Down

0 comments on commit 7a504ab

Please sign in to comment.