mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
fix: move sync state check from server into test_miner (#2958)
* fix: move sync state check from server into test_miner * fix: compile error from SyncState moving to grin_chain
This commit is contained in:
parent
441e846af6
commit
ecd16d114f
3 changed files with 14 additions and 13 deletions
|
@ -388,19 +388,12 @@ impl Server {
|
|||
self.tx_pool.clone(),
|
||||
self.verifier_cache.clone(),
|
||||
stop_state,
|
||||
sync_state,
|
||||
);
|
||||
miner.set_debug_output_id(format!("Port {}", self.config.p2p_config.port));
|
||||
let _ = thread::Builder::new()
|
||||
.name("test_miner".to_string())
|
||||
.spawn(move || {
|
||||
// TODO push this down in the run loop so miner gets paused anytime we
|
||||
// decide to sync again
|
||||
let secs_5 = time::Duration::from_secs(5);
|
||||
while sync_state.is_syncing() {
|
||||
thread::sleep(secs_5);
|
||||
}
|
||||
miner.run_loop(wallet_listener_url);
|
||||
});
|
||||
.spawn(move || miner.run_loop(wallet_listener_url));
|
||||
}
|
||||
|
||||
/// The chain head
|
||||
|
@ -421,8 +414,7 @@ impl Server {
|
|||
/// Returns a set of stats about this server. This and the ServerStats
|
||||
/// structure
|
||||
/// can be updated over time to include any information needed by tests or
|
||||
/// other
|
||||
/// consumers
|
||||
/// other consumers
|
||||
pub fn get_server_stats(&self) -> Result<ServerStats, Error> {
|
||||
let stratum_stats = self.state_info.stratum_stats.read().clone();
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ use crate::core::global;
|
|||
use crate::mining::mine_block;
|
||||
use crate::pool;
|
||||
use crate::util::StopState;
|
||||
use grin_chain::SyncState;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct Miner {
|
||||
config: StratumServerConfig,
|
||||
|
@ -37,7 +40,7 @@ pub struct Miner {
|
|||
tx_pool: Arc<RwLock<pool::TransactionPool>>,
|
||||
verifier_cache: Arc<RwLock<dyn VerifierCache>>,
|
||||
stop_state: Arc<StopState>,
|
||||
|
||||
sync_state: Arc<SyncState>,
|
||||
// Just to hold the port we're on, so this miner can be identified
|
||||
// while watching debug output
|
||||
debug_output_id: String,
|
||||
|
@ -52,6 +55,7 @@ impl Miner {
|
|||
tx_pool: Arc<RwLock<pool::TransactionPool>>,
|
||||
verifier_cache: Arc<RwLock<dyn VerifierCache>>,
|
||||
stop_state: Arc<StopState>,
|
||||
sync_state: Arc<SyncState>,
|
||||
) -> Miner {
|
||||
Miner {
|
||||
config,
|
||||
|
@ -60,6 +64,7 @@ impl Miner {
|
|||
verifier_cache,
|
||||
debug_output_id: String::from("none"),
|
||||
stop_state,
|
||||
sync_state,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,6 +145,10 @@ impl Miner {
|
|||
break;
|
||||
}
|
||||
|
||||
while self.sync_state.is_syncing() {
|
||||
thread::sleep(Duration::from_secs(5));
|
||||
}
|
||||
|
||||
trace!("in miner loop. key_id: {:?}", key_id);
|
||||
|
||||
// get the latest chain state and build a block on top of it
|
||||
|
|
|
@ -80,7 +80,7 @@ fn real_main() -> i32 {
|
|||
match args.subcommand() {
|
||||
("wallet", _) => {
|
||||
println!();
|
||||
println!("As of v1.1.0, the wallet has been split into a seperate executable.");
|
||||
println!("As of v1.1.0, the wallet has been split into a separate executable.");
|
||||
println!(
|
||||
"Please visit https://github.com/mimblewimble/grin-wallet/releases to download"
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue