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

Commit

Permalink
Don't shutdown the stepper thread at all, just let it run until exit
Browse files Browse the repository at this point in the history
Also: fix a few warnings and tests
  • Loading branch information
dvdplm committed May 23, 2019
1 parent 709e8fe commit 56eb2ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
21 changes: 2 additions & 19 deletions ethcore/src/engines/clique/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::sync::{Arc, Weak, atomic::{AtomicBool, Ordering}};
use std::sync::{Arc, Weak};
use std::thread;
use std::time;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
Expand Down Expand Up @@ -166,7 +166,6 @@ pub struct Clique {
block_state_by_hash: RwLock<LruCache<H256, CliqueBlockState>>,
proposals: RwLock<HashMap<Address, VoteType>>,
signer: RwLock<Option<Box<EngineSigner>>>,
shutdown_stepping: Arc<AtomicBool>,
}

#[cfg(test)]
Expand All @@ -179,13 +178,6 @@ pub struct Clique {
pub block_state_by_hash: RwLock<LruCache<H256, CliqueBlockState>>,
pub proposals: RwLock<HashMap<Address, VoteType>>,
pub signer: RwLock<Option<Box<EngineSigner>>>,
pub shutdown_stepping: Arc<AtomicBool>,
}

impl Drop for Clique {
fn drop(&mut self) {
self.shutdown_stepping.store(true, Ordering::Release);
}
}

impl Clique {
Expand All @@ -204,24 +196,16 @@ impl Clique {
proposals: Default::default(),
signer: Default::default(),
machine,
shutdown_stepping: Arc::new(AtomicBool::new(false)),
};
let engine = Arc::new(engine);
let weak_eng = Arc::downgrade(&engine);
let shutdown = engine.shutdown_stepping.clone();

thread::Builder::new().name("StepService".into())
.spawn(move || {
thread::sleep(INITIAL_DELAY);
loop {
// Check if we are in shutdown.
if shutdown.load(Ordering::Acquire) {
trace!(target: "shutdown", "StepService: received shutdown signal!");
break;
}
trace!(target: "miner", "StepService: triggering sealing");
// Try sealing
weak_eng.upgrade().map(|x| x.step());
// Yield
thread::sleep(SEALING_FREQ);
}
})?;
Expand All @@ -243,7 +227,6 @@ impl Clique {
proposals: Default::default(),
signer: Default::default(),
machine: Spec::new_test_machine(),
step_service: None,
}
}

Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ extern crate journaldb;
extern crate keccak_hash as hash;
extern crate keccak_hasher;
extern crate kvdb;
extern crate kvdb_memorydb;
extern crate len_caching_lock;
extern crate lru_cache;
extern crate memory_cache;
Expand Down Expand Up @@ -113,6 +112,8 @@ extern crate ethcore_accounts as accounts;
extern crate ethcore_stratum;
#[cfg(any(test, feature = "tempdir"))]
extern crate tempdir;
#[cfg(test)]
extern crate kvdb_memorydb;
#[cfg(any(test, feature = "kvdb-rocksdb"))]
extern crate kvdb_rocksdb;
#[cfg(any(test, feature = "blooms-db"))]
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/snapshot/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ pub fn restore(
genesis: &[u8],
) -> Result<(), ::error::Error> {
use std::sync::atomic::AtomicBool;
use snappy;

let flag = AtomicBool::new(true);
let components = engine.snapshot_components().unwrap();
Expand Down

0 comments on commit 56eb2ac

Please sign in to comment.