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

Commit

Permalink
Clean-up and parallelize.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Feb 23, 2018
1 parent 620e6be commit 5a6cdf5
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 338 deletions.
112 changes: 78 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ num = "0.1"
num_cpus = "1.2"
parity-machine = { path = "../machine" }
parking_lot = "0.5"
rayon = "0.8"
rayon = "1.0"
rand = "0.4"
rlp = { path = "../util/rlp" }
rlp_compress = { path = "../util/rlp_compress" }
Expand All @@ -60,7 +60,6 @@ rustc-hex = "1.0"
stats = { path = "../util/stats" }
time = "0.1"
using_queue = { path = "../util/using_queue" }
table = { path = "../util/table" }
vm = { path = "vm" }
wasm = { path = "wasm" }
keccak-hash = { path = "../util/hash" }
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ extern crate stats;
extern crate stop_guard;
extern crate time;
extern crate using_queue;
extern crate table;
extern crate vm;
extern crate wasm;
extern crate memory_cache;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/miner/blockchain_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a> pool::client::Client for BlockChainClient<'a> {
fn transaction_type(&self, tx: &SignedTransaction) -> pool::client::TransactionType {
match self.service_transaction_checker {
None => pool::client::TransactionType::Regular,
Some(ref checker) => match checker.check(self, &tx.sender()) {
Some(ref checker) => match checker.check(self, &tx.sender(), &tx.hash()) {
Ok(true) => pool::client::TransactionType::Service,
Ok(false) => pool::client::TransactionType::Regular,
Err(e) => {
Expand Down
34 changes: 18 additions & 16 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ use std::collections::{BTreeMap, HashSet};
use std::sync::Arc;

use ansi_term::Colour;
use ethereum_types::{H256, U256, Address};
use parking_lot::{Mutex, RwLock};
use bytes::Bytes;
use engines::{EthEngine, Seal};
use error::{Error, ExecutionError};
use ethcore_miner::gas_pricer::GasPricer;
use ethcore_miner::pool::{self, TransactionQueue, VerifiedTransaction, QueueStatus};
use ethcore_miner::work_notify::{WorkPoster, NotifyWork};
use ethcore_miner::gas_pricer::GasPricer;
use ethereum_types::{H256, U256, Address};
use parking_lot::{Mutex, RwLock};
use rayon::prelude::*;
use timer::PerfTimer;
use transaction::{
self,
Expand Down Expand Up @@ -1012,19 +1013,20 @@ impl MinerService for Miner {
// Then import all transactions...
let client = self.client(chain);
{
// TODO [ToDr] Parallelize
for hash in retracted {
let block = chain.block(BlockId::Hash(*hash))
.expect("Client is sending message after commit to db and inserting to chain; the block is available; qed");
let txs = block.transactions()
.into_iter()
.map(pool::verifier::Transaction::Retracted)
.collect();
let _ = self.transaction_queue.import(
client.clone(),
txs,
);
}
retracted
.par_iter()
.for_each(|hash| {
let block = chain.block(BlockId::Hash(*hash))
.expect("Client is sending message after commit to db and inserting to chain; the block is available; qed");
let txs = block.transactions()
.into_iter()
.map(pool::verifier::Transaction::Retracted)
.collect();
let _ = self.transaction_queue.import(
client.clone(),
txs,
);
});
}

// ...and at the end remove the old ones
Expand Down
9 changes: 5 additions & 4 deletions miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ ethabi-derive = "5.0"
ethash = { path = "../ethash" }
ethcore-transaction = { path = "../ethcore/transaction" }
ethereum-types = "0.2"
ethkey = { path = "../ethkey" }
futures = "0.1"
heapsize = "0.4"
keccak-hash = { path = "../util/hash" }
linked-hash-map = "0.5"
log = "0.3"
parking_lot = "0.5"
price-info = { path = "../price-info" }
rustc-hex = "1.0"
table = { path = "../util/table" }
rayon = "1.0"
transaction-pool = { path = "../transaction-pool" }
transient-hashmap = "0.4"

[dev-dependencies]
ethkey = { path = "../ethkey" }
rustc-hex = "1.0"

0 comments on commit 5a6cdf5

Please sign in to comment.