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
ordian committed Sep 12, 2019
1 parent 4eeac61 commit 636ffb1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 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 @@ -37,7 +37,7 @@ serde_derive = "1.0"
serde_json = "1.0"
time-utils = { path = "../../util/time-utils" }
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;
20 changes: 16 additions & 4 deletions ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use machine::Machine;
use types::header::{Header, ExtendedHeader};
use block::ExecutedBlock;
use error::Error;
use std::sync::atomic::{AtomicU64, Ordering};


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

impl InstantSeal {
Expand All @@ -48,6 +51,7 @@ impl InstantSeal {
InstantSeal {
params,
machine,
last_sealed_block: AtomicU64::new(0),
}
}
}
Expand All @@ -62,11 +66,19 @@ impl Engine for InstantSeal {
fn sealing_state(&self) -> SealingState { SealingState::Ready }

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<(), Error> {
Expand Down
12 changes: 10 additions & 2 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use futures::sync::mpsc;
use io::IoChannel;
use miner::filter_options::{FilterOptions, FilterOperator};
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 @@ -54,6 +54,7 @@ use client::{
BlockChain, ChainInfo, BlockProducer, SealedBlockImporter, Nonce, TransactionInfo, TransactionId
};
use client::{BlockId, ClientIoMessage};
use client::traits::EngineClient;
use engines::{Engine, Seal, SealingState, EngineSigner};
use error::Error;
use executed::ExecutionError;
Expand Down Expand Up @@ -855,9 +856,9 @@ impl Miner {
false
}
}

/// 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;
match self.engine.sealing_state() {
SealingState::Ready => {
self.maybe_enable_sealing();
Expand Down Expand Up @@ -1414,15 +1415,22 @@ 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 {
match service_transaction_checker.refresh_cache(chain) {
Ok(true) => {
Expand Down
2 changes: 1 addition & 1 deletion miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
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 @@ -71,7 +71,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 636ffb1

Please sign in to comment.