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

Commit

Permalink
Manual port of #10995
Browse files Browse the repository at this point in the history
  • Loading branch information
s3krit committed Sep 12, 2019
1 parent 42b6db5 commit d9159d6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion ethcore/private-tx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tiny-keccak = "1.4"
transaction-pool = "2.0"
transaction-pool = "2.0.1"
url = "1"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub use vm::{LastHashes, EnvInfo};
pub use error::TransactionImportError;
pub use verification::VerifierType;

mod traits;
pub mod traits;

mod chain_notify;
mod private_notify;
22 changes: 17 additions & 5 deletions ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use engines::{Engine, Seal};
use machine::Machine;
use types::header::{Header, ExtendedHeader};
use block::ExecutedBlock;
use std::sync::atomic::{AtomicU64, Ordering};

/// `InstantSeal` params.
#[derive(Default, Debug, PartialEq)]
Expand All @@ -39,13 +40,16 @@ impl From<::ethjson::spec::InstantSealParams> for InstantSealParams {
pub struct InstantSeal<M> {
params: InstantSealParams,
machine: M,
last_sealed_block: AtomicU64,
}

impl<M> InstantSeal<M> {
/// Returns new instance of InstantSeal over the given state machine.
pub fn new(params: InstantSealParams, machine: M) -> Self {
InstantSeal {
params, machine,
params,
machine,
last_sealed_block: AtomicU64::new(0),
}
}
}
Expand All @@ -60,11 +64,19 @@ impl<M: Machine> Engine<M> for InstantSeal<M> {
fn seals_internally(&self) -> Option<bool> { Some(true) }

fn generate_seal(&self, block: &ExecutedBlock, _parent: &Header) -> Seal {
if block.transactions.is_empty() {
Seal::None
} else {
Seal::Regular(Vec::new())
if !block.transactions.is_empty() {
let block_number = block.header.number();
let last_sealed_block = self.last_sealed_block.load(Ordering::SeqCst);
// Return a regular seal if the given block is _higher_ than
// the last sealed one
if block_number > last_sealed_block {
let prev_last_sealed_block = self.last_sealed_block.compare_and_swap(last_sealed_block, block_number, Ordering::SeqCst);
if prev_last_sealed_block == last_sealed_block {
return Seal::Regular(Vec::new())
}
}
}
Seal::None
}

fn verify_local_seal(&self, _header: &Header) -> Result<(), M::Error> {
Expand Down
10 changes: 8 additions & 2 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use ethcore_miner::work_notify::NotifyWork;
use ethereum_types::{H256, U256, Address};
use io::IoChannel;
use miner::pool_client::{PoolClient, CachedNonceClient, NonceCache};
use miner;
use miner::{self, MinerService};
use parking_lot::{Mutex, RwLock};
use rayon::prelude::*;
use types::transaction::{
Expand All @@ -52,6 +52,7 @@ use client::{
BlockChain, ChainInfo, BlockProducer, SealedBlockImporter, Nonce, TransactionInfo, TransactionId
};
use client::{BlockId, ClientIoMessage};
use client::traits::EngineClient;
use engines::{EthEngine, Seal, EngineSigner};
use error::{Error, ErrorKind};
use executed::ExecutionError;
Expand Down Expand Up @@ -830,7 +831,6 @@ impl Miner {

/// Prepare pending block, check whether sealing is needed, and then update sealing.
fn prepare_and_update_sealing<C: miner::BlockChainClient>(&self, chain: &C) {
use miner::MinerService;

// Make sure to do it after transaction is imported and lock is dropped.
// We need to create pending block and enable sealing.
Expand Down Expand Up @@ -1307,13 +1307,19 @@ impl miner::MinerService for Miner {
service_transaction_checker.as_ref(),
);
queue.cull(client);
if is_internal_import {
chain.update_sealing();
}
};

if let Err(e) = channel.send(ClientIoMessage::execute(cull)) {
warn!(target: "miner", "Error queueing cull: {:?}", e);
}
} else {
self.transaction_queue.cull(client);
if is_internal_import {
self.update_sealing(chain);
}
}
}
if let Some(ref service_transaction_checker) = self.service_transaction_checker {
Expand Down
2 changes: 1 addition & 1 deletion miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ parking_lot = "0.7"
price-info = { path = "./price-info", optional = true }
rlp = { version = "0.3.0", features = ["ethereum"] }
trace-time = "0.1"
transaction-pool = "2.0"
transaction-pool = "2.0.1"

[dev-dependencies]
env_logger = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ethcore-network = { path = "../util/network" }
fake-fetch = { path = "../util/fake-fetch" }
macros = { path = "../util/macros" }
pretty_assertions = "0.1"
transaction-pool = "2.0"
transaction-pool = "2.0.1"

[features]
accounts = ["ethcore-accounts"]

0 comments on commit d9159d6

Please sign in to comment.