From 1c5aee68bfc6f5ded754a2218e2f8e2914bf2983 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Thu, 12 Apr 2018 10:11:24 +0100 Subject: [PATCH] refactor grin crate into separate modules (#955) --- .travis.yml | 2 +- Cargo.lock | 58 +++++++++---------- Cargo.toml | 4 +- config/Cargo.toml | 2 +- config/src/config.rs | 2 +- config/src/lib.rs | 2 +- config/src/types.rs | 2 +- {grin => servers}/Cargo.toml | 2 +- {grin => servers}/rustfmt.toml | 0 {grin/src => servers/src/common}/adapters.rs | 2 +- servers/src/common/mod.rs | 19 ++++++ {grin/src => servers/src/common}/stats.rs | 0 {grin/src => servers/src/common}/types.rs | 0 .../src/grin}/dandelion_monitor.rs | 0 servers/src/grin/mod.rs | 20 +++++++ {grin/src => servers/src/grin}/seed.rs | 0 {grin/src => servers/src/grin}/server.rs | 14 ++--- {grin/src => servers/src/grin}/sync.rs | 2 +- {grin => servers}/src/lib.rs | 17 ++---- {grin/src => servers/src/mining}/miner.rs | 6 +- servers/src/mining/mod.rs | 17 ++++++ {grin => servers}/tests/api.rs | 2 +- {grin => servers}/tests/dandelion.rs | 2 +- {grin => servers}/tests/framework/mod.rs | 14 ++--- {grin => servers}/tests/simulnet.rs | 24 ++++---- {grin => servers}/tests/wallet.rs | 2 +- src/bin/client.rs | 2 +- src/bin/grin.rs | 12 ++-- src/bin/tui/mining.rs | 2 +- src/bin/tui/peers.rs | 2 +- src/bin/tui/status.rs | 2 +- src/bin/tui/types.rs | 2 +- src/bin/tui/ui.rs | 2 +- src/bin/tui/version.rs | 2 +- 34 files changed, 146 insertions(+), 95 deletions(-) rename {grin => servers}/Cargo.toml (97%) rename {grin => servers}/rustfmt.toml (100%) rename {grin/src => servers/src/common}/adapters.rs (99%) create mode 100644 servers/src/common/mod.rs rename {grin/src => servers/src/common}/stats.rs (100%) rename {grin/src => servers/src/common}/types.rs (100%) rename {grin/src => servers/src/grin}/dandelion_monitor.rs (100%) create mode 100644 servers/src/grin/mod.rs rename {grin/src => servers/src/grin}/seed.rs (100%) rename {grin/src => servers/src/grin}/server.rs (98%) rename {grin/src => servers/src/grin}/sync.rs (99%) rename {grin => servers}/src/lib.rs (87%) rename {grin/src => servers/src/mining}/miner.rs (99%) create mode 100644 servers/src/mining/mod.rs rename {grin => servers}/tests/api.rs (99%) rename {grin => servers}/tests/dandelion.rs (99%) rename {grin => servers}/tests/framework/mod.rs (97%) rename {grin => servers}/tests/simulnet.rs (93%) rename {grin => servers}/tests/wallet.rs (99%) diff --git a/.travis.yml b/.travis.yml index 79c2b20d6..e4ef352ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ env: - RUST_BACKTRACE="1" - RUST_FLAGS="-C debug-assertions" matrix: - - RUST_TEST_THREADS=1 TEST_DIR=grin + - RUST_TEST_THREADS=1 TEST_DIR=servers - TEST_DIR=store - TEST_DIR=chain - TEST_DIR=pool diff --git a/Cargo.lock b/Cargo.lock index 4e1765a95..fb5d38824 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -603,10 +603,10 @@ dependencies = [ "grin_api 0.2.0", "grin_config 0.2.0", "grin_core 0.2.0", - "grin_grin 0.2.0", "grin_keychain 0.2.0", "grin_p2p 0.2.0", "grin_pow 0.2.0", + "grin_servers 0.2.0", "grin_util 0.2.0", "grin_wallet 0.2.0", "serde 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -662,9 +662,9 @@ dependencies = [ name = "grin_config" version = "0.2.0" dependencies = [ - "grin_grin 0.2.0", "grin_p2p 0.2.0", "grin_pow 0.2.0", + "grin_servers 0.2.0", "grin_util 0.2.0", "grin_wallet 0.2.0", "serde 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -691,33 +691,6 @@ dependencies = [ "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "grin_grin" -version = "0.2.0" -dependencies = [ - "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_api 0.2.0", - "grin_chain 0.2.0", - "grin_config 0.2.0", - "grin_core 0.2.0", - "grin_keychain 0.2.0", - "grin_p2p 0.2.0", - "grin_pool 0.2.0", - "grin_pow 0.2.0", - "grin_store 0.2.0", - "grin_util 0.2.0", - "grin_wallet 0.2.0", - "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "router 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "grin_keychain" version = "0.2.0" @@ -783,6 +756,33 @@ dependencies = [ "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "grin_servers" +version = "0.2.0" +dependencies = [ + "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "grin_api 0.2.0", + "grin_chain 0.2.0", + "grin_config 0.2.0", + "grin_core 0.2.0", + "grin_keychain 0.2.0", + "grin_p2p 0.2.0", + "grin_pool 0.2.0", + "grin_pow 0.2.0", + "grin_store 0.2.0", + "grin_util 0.2.0", + "grin_wallet 0.2.0", + "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "router 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "grin_store" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 776d47a52..e24d83a6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ publish = false build = "src/build/build.rs" [workspace] -members = ["api", "chain", "config", "core", "grin", "keychain", "p2p", "store", "util", "pool", "wallet"] +members = ["api", "chain", "config", "core", "keychain", "p2p", "servers", "store", "util", "pool", "wallet"] [[bin]] name = "grin" @@ -27,10 +27,10 @@ time = "0.1" grin_api = { path = "./api" } grin_config = { path = "./config" } grin_core = { path = "./core" } -grin_grin = { path = "./grin" } grin_keychain = { path = "./keychain" } grin_p2p = { path = "./p2p"} grin_pow = { path = "./pow"} +grin_servers = { path = "./servers" } grin_util = { path = "./util"} grin_wallet = { path = "./wallet" } diff --git a/config/Cargo.toml b/config/Cargo.toml index 39c19dc02..e190c6a19 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -10,7 +10,7 @@ serde = "1" serde_derive = "1" toml = "0.4" -grin_grin = { path = "../grin" } +grin_servers = { path = "../servers" } grin_p2p = { path = "../p2p" } grin_pow = { path = "../pow"} grin_util = { path = "../util" } diff --git a/config/src/config.rs b/config/src/config.rs index d6ad2ed0d..06cbed429 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -20,7 +20,7 @@ use std::path::PathBuf; use std::fs::File; use toml; -use grin::ServerConfig; +use servers::ServerConfig; use pow::types::MinerConfig; use util::LoggingConfig; use types::{ConfigError, ConfigMembers, GlobalConfig}; diff --git a/config/src/lib.rs b/config/src/lib.rs index a30cdc418..4cb3d4532 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -25,7 +25,7 @@ extern crate serde; extern crate serde_derive; extern crate toml; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_p2p as p2p; extern crate grin_pow as pow; extern crate grin_util as util; diff --git a/config/src/types.rs b/config/src/types.rs index fbc36cf28..c2dd20b57 100644 --- a/config/src/types.rs +++ b/config/src/types.rs @@ -18,7 +18,7 @@ use std::path::PathBuf; use std::io; use std::fmt; -use grin::ServerConfig; +use servers::ServerConfig; use pow::types::MinerConfig; use util::LoggingConfig; use wallet::WalletConfig; diff --git a/grin/Cargo.toml b/servers/Cargo.toml similarity index 97% rename from grin/Cargo.toml rename to servers/Cargo.toml index 8c2d2a590..7a272f529 100644 --- a/grin/Cargo.toml +++ b/servers/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "grin_grin" +name = "grin_servers" version = "0.2.0" authors = ["Grin Developers "] workspace = ".." diff --git a/grin/rustfmt.toml b/servers/rustfmt.toml similarity index 100% rename from grin/rustfmt.toml rename to servers/rustfmt.toml diff --git a/grin/src/adapters.rs b/servers/src/common/adapters.rs similarity index 99% rename from grin/src/adapters.rs rename to servers/src/common/adapters.rs index 3303012cf..1c8672ddf 100644 --- a/grin/src/adapters.rs +++ b/servers/src/common/adapters.rs @@ -31,7 +31,7 @@ use p2p; use pool; use util::OneTime; use store; -use types::{ChainValidationMode, ServerConfig}; +use common::types::{ChainValidationMode, ServerConfig}; use util::LOGGER; // All adapters use `Weak` references instead of `Arc` to avoid cycles that diff --git a/servers/src/common/mod.rs b/servers/src/common/mod.rs new file mode 100644 index 000000000..6aa35e0e2 --- /dev/null +++ b/servers/src/common/mod.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Grin Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Modules common to all Grin server types + +pub mod adapters; +pub mod stats; +pub mod types; diff --git a/grin/src/stats.rs b/servers/src/common/stats.rs similarity index 100% rename from grin/src/stats.rs rename to servers/src/common/stats.rs diff --git a/grin/src/types.rs b/servers/src/common/types.rs similarity index 100% rename from grin/src/types.rs rename to servers/src/common/types.rs diff --git a/grin/src/dandelion_monitor.rs b/servers/src/grin/dandelion_monitor.rs similarity index 100% rename from grin/src/dandelion_monitor.rs rename to servers/src/grin/dandelion_monitor.rs diff --git a/servers/src/grin/mod.rs b/servers/src/grin/mod.rs new file mode 100644 index 000000000..6d9c8c7b9 --- /dev/null +++ b/servers/src/grin/mod.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Grin Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Grin P2P / API server + +pub mod dandelion_monitor; +pub mod seed; +pub mod server; +pub mod sync; diff --git a/grin/src/seed.rs b/servers/src/grin/seed.rs similarity index 100% rename from grin/src/seed.rs rename to servers/src/grin/seed.rs diff --git a/grin/src/server.rs b/servers/src/grin/server.rs similarity index 98% rename from grin/src/server.rs rename to servers/src/grin/server.rs index 4ebab44da..1681296c2 100644 --- a/grin/src/server.rs +++ b/servers/src/grin/server.rs @@ -22,20 +22,20 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::thread; use std::time; -use adapters::*; +use common::adapters::*; use api; use chain; use core::{consensus, genesis, global}; use core::core::target::Difficulty; use core::core::hash::Hashed; -use dandelion_monitor; -use miner; +use grin::dandelion_monitor; +use mining::miner; use p2p; use pool; -use seed; -use sync; -use types::*; -use stats::*; +use grin::seed; +use grin::sync; +use common::types::*; +use common::stats::*; use pow; use util::LOGGER; diff --git a/grin/src/sync.rs b/servers/src/grin/sync.rs similarity index 99% rename from grin/src/sync.rs rename to servers/src/grin/sync.rs index 3e11280e7..0c0fede63 100644 --- a/grin/src/sync.rs +++ b/servers/src/grin/sync.rs @@ -23,7 +23,7 @@ use core::core::hash::{Hash, Hashed}; use core::core::target::Difficulty; use core::global; use p2p::{self, Peer, Peers}; -use types::Error; +use common::types::Error; use util::LOGGER; /// Starts the syncing loop, just spawns two threads that loop forever diff --git a/grin/src/lib.rs b/servers/src/lib.rs similarity index 87% rename from grin/src/lib.rs rename to servers/src/lib.rs index e035dadbd..a51eb47eb 100644 --- a/grin/src/lib.rs +++ b/servers/src/lib.rs @@ -43,15 +43,10 @@ extern crate grin_store as store; extern crate grin_util as util; extern crate grin_wallet as wallet; -mod adapters; -mod dandelion_monitor; -mod server; -mod seed; -mod sync; -pub mod types; -pub mod stats; -mod miner; +mod common; +mod grin; +mod mining; -pub use server::Server; -pub use types::{Seeding, ServerConfig}; -pub use stats::ServerStats; +pub use grin::server::Server; +pub use common::types::{Seeding, ServerConfig}; +pub use common::stats::{PeerStats, ServerStats, DiffBlock}; diff --git a/grin/src/miner.rs b/servers/src/mining/miner.rs similarity index 99% rename from grin/src/miner.rs rename to servers/src/mining/miner.rs index ddc5db637..60be7a866 100644 --- a/grin/src/miner.rs +++ b/servers/src/mining/miner.rs @@ -22,7 +22,7 @@ use std::thread; use std::time::Duration; use time; -use adapters::PoolToChainAdapter; +use common::adapters::PoolToChainAdapter; use core::consensus; use core::core; use core::core::Proof; @@ -34,8 +34,8 @@ use core::ser; use core::global; use core::ser::AsFixedBytes; use util::LOGGER; -use types::Error; -use stats::MiningStats; +use common::types::Error; +use common::stats::MiningStats; use chain; use pool; diff --git a/servers/src/mining/mod.rs b/servers/src/mining/mod.rs new file mode 100644 index 000000000..451ac09aa --- /dev/null +++ b/servers/src/mining/mod.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Grin Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Mining + Mining server + +pub mod miner; diff --git a/grin/tests/api.rs b/servers/tests/api.rs similarity index 99% rename from grin/tests/api.rs rename to servers/tests/api.rs index ce9fe8d19..2a35e2fc0 100644 --- a/grin/tests/api.rs +++ b/servers/tests/api.rs @@ -19,7 +19,7 @@ extern crate grin_api as api; extern crate grin_chain as chain; extern crate grin_config as config; extern crate grin_core as core; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_p2p as p2p; extern crate grin_pow as pow; extern crate grin_util as util; diff --git a/grin/tests/dandelion.rs b/servers/tests/dandelion.rs similarity index 99% rename from grin/tests/dandelion.rs rename to servers/tests/dandelion.rs index bf70092df..94eed8b7e 100644 --- a/grin/tests/dandelion.rs +++ b/servers/tests/dandelion.rs @@ -20,7 +20,7 @@ extern crate grin_api as api; extern crate grin_chain as chain; extern crate grin_config as config; extern crate grin_core as core; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_p2p as p2p; extern crate grin_pow as pow; extern crate grin_util as util; diff --git a/grin/tests/framework/mod.rs b/servers/tests/framework/mod.rs similarity index 97% rename from grin/tests/framework/mod.rs rename to servers/tests/framework/mod.rs index b4338f5b0..fbf41f626 100644 --- a/grin/tests/framework/mod.rs +++ b/servers/tests/framework/mod.rs @@ -15,7 +15,7 @@ extern crate grin_api as api; extern crate grin_chain as chain; extern crate grin_core as core; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_keychain as keychain; extern crate grin_p2p as p2p; extern crate grin_pow as pow; @@ -128,7 +128,7 @@ pub struct LocalServerContainer { // Structure of references to the // internal server data - pub p2p_server_stats: Option, + pub p2p_server_stats: Option, // The API server instance api_server: Option, @@ -178,14 +178,14 @@ impl LocalServerContainer { }) } - pub fn run_server(&mut self, duration_in_seconds: u64) -> grin::ServerStats { + pub fn run_server(&mut self, duration_in_seconds: u64) -> servers::ServerStats { let api_addr = format!("{}:{}", self.config.base_addr, self.config.api_server_port); - let mut seeding_type = grin::Seeding::None; + let mut seeding_type = servers::Seeding::None; let mut seeds = Vec::new(); if self.config.seed_addr.len() > 0 { - seeding_type = grin::Seeding::List; + seeding_type = servers::Seeding::List; seeds = vec![self.config.seed_addr.to_string()]; } @@ -205,7 +205,7 @@ impl LocalServerContainer { ..Default::default() }; - let s = grin::Server::new(grin::ServerConfig { + let s = servers::Server::new(servers::ServerConfig { api_http_addr: api_addr, db_root: format!("{}/.grin", self.working_dir), p2p_config: p2p::P2PConfig { @@ -498,7 +498,7 @@ impl LocalServerContainerPool { /// once they've all been run /// - pub fn run_all_servers(self) -> Vec { + pub fn run_all_servers(self) -> Vec { let run_length = self.config.run_length_in_seconds; let mut handles = vec![]; diff --git a/grin/tests/simulnet.rs b/servers/tests/simulnet.rs similarity index 93% rename from grin/tests/simulnet.rs rename to servers/tests/simulnet.rs index 132300eb1..daa10e74b 100644 --- a/grin/tests/simulnet.rs +++ b/servers/tests/simulnet.rs @@ -15,7 +15,7 @@ extern crate grin_api as api; extern crate grin_chain as chain; extern crate grin_core as core; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_p2p as p2p; extern crate grin_pow as pow; extern crate grin_util as util; @@ -186,7 +186,7 @@ fn simulate_block_propagation() { // instantiates 5 servers on different ports let mut servers = vec![]; for n in 0..5 { - let s = grin::Server::new(config(10 * n, test_name_dir, 0)).unwrap(); + let s = servers::Server::new(config(10 * n, test_name_dir, 0)).unwrap(); servers.push(s); thread::sleep(time::Duration::from_millis(100)); } @@ -226,14 +226,14 @@ fn simulate_full_sync() { let test_name_dir = "grin-sync"; framework::clean_all_output(test_name_dir); - let s1 = grin::Server::new(config(1000, "grin-sync", 1000)).unwrap(); + let s1 = servers::Server::new(config(1000, "grin-sync", 1000)).unwrap(); // mine a few blocks on server 1 s1.start_miner(miner_config()); thread::sleep(time::Duration::from_secs(8)); #[ignore(unused_mut)] // mut needed? let mut conf = config(1001, "grin-sync", 1000); - let s2 = grin::Server::new(conf).unwrap(); + let s2 = servers::Server::new(conf).unwrap(); while s2.head().height < 4 { thread::sleep(time::Duration::from_millis(100)); } @@ -253,14 +253,14 @@ fn simulate_fast_sync() { let test_name_dir = "grin-fast"; framework::clean_all_output(test_name_dir); - let s1 = grin::Server::new(config(2000, "grin-fast", 2000)).unwrap(); + let s1 = servers::Server::new(config(2000, "grin-fast", 2000)).unwrap(); // mine a few blocks on server 1 s1.start_miner(miner_config()); thread::sleep(time::Duration::from_secs(8)); let mut conf = config(2001, "grin-fast", 2000); conf.archive_mode = Some(false); - let s2 = grin::Server::new(conf).unwrap(); + let s2 = servers::Server::new(conf).unwrap(); while s2.head().height != s2.header_head().height || s2.head().height < 20 { thread::sleep(time::Duration::from_millis(1000)); } @@ -280,7 +280,7 @@ fn simulate_fast_sync_double() { framework::clean_all_output("grin-double-fast1"); framework::clean_all_output("grin-double-fast2"); - let s1 = grin::Server::new(config(3000, "grin-double-fast1", 3000)).unwrap(); + let s1 = servers::Server::new(config(3000, "grin-double-fast1", 3000)).unwrap(); // mine a few blocks on server 1 s1.start_miner(miner_config()); thread::sleep(time::Duration::from_secs(8)); @@ -288,7 +288,7 @@ fn simulate_fast_sync_double() { { let mut conf = config(3001, "grin-double-fast2", 3000); conf.archive_mode = Some(false); - let s2 = grin::Server::new(conf).unwrap(); + let s2 = servers::Server::new(conf).unwrap(); while s2.head().height != s2.header_head().height || s2.head().height < 20 { thread::sleep(time::Duration::from_millis(1000)); } @@ -301,7 +301,7 @@ fn simulate_fast_sync_double() { let mut conf = config(3001, "grin-double-fast2", 3000); conf.archive_mode = Some(false); - let s2 = grin::Server::new(conf).unwrap(); + let s2 = servers::Server::new(conf).unwrap(); while s2.head().height != s2.header_head().height || s2.head().height < 50 { thread::sleep(time::Duration::from_millis(1000)); } @@ -309,15 +309,15 @@ fn simulate_fast_sync_double() { s2.stop(); } -fn config(n: u16, test_name_dir: &str, seed_n: u16) -> grin::ServerConfig { - grin::ServerConfig { +fn config(n: u16, test_name_dir: &str, seed_n: u16) -> servers::ServerConfig { + servers::ServerConfig { api_http_addr: format!("127.0.0.1:{}", 20000 + n), db_root: format!("target/tmp/{}/grin-sync-{}", test_name_dir, n), p2p_config: p2p::P2PConfig { port: 10000 + n, ..p2p::P2PConfig::default() }, - seeding_type: grin::Seeding::List, + seeding_type: servers::Seeding::List, seeds: Some(vec![format!("127.0.0.1:{}", 10000 + seed_n)]), chain_type: core::global::ChainTypes::AutomatedTesting, archive_mode: Some(true), diff --git a/grin/tests/wallet.rs b/servers/tests/wallet.rs similarity index 99% rename from grin/tests/wallet.rs rename to servers/tests/wallet.rs index 5d2fdfd01..8a14826b4 100644 --- a/grin/tests/wallet.rs +++ b/servers/tests/wallet.rs @@ -20,7 +20,7 @@ extern crate grin_api as api; extern crate grin_chain as chain; extern crate grin_config as config; extern crate grin_core as core; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_p2p as p2p; extern crate grin_pow as pow; extern crate grin_util as util; diff --git a/src/bin/client.rs b/src/bin/client.rs index f0530b7c2..2e6187cd7 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -18,7 +18,7 @@ use std::net::SocketAddr; use api; use p2p; -use grin::ServerConfig; +use servers::ServerConfig; pub fn show_status(config: &ServerConfig) { println!(); diff --git a/src/bin/grin.rs b/src/bin/grin.rs index 0a0ab8aa6..d4aef23de 100644 --- a/src/bin/grin.rs +++ b/src/bin/grin.rs @@ -28,7 +28,7 @@ extern crate time; extern crate grin_api as api; extern crate grin_config as config; extern crate grin_core as core; -extern crate grin_grin as grin; +extern crate grin_servers as servers; extern crate grin_keychain as keychain; extern crate grin_p2p as p2p; extern crate grin_util as util; @@ -84,7 +84,7 @@ fn log_build_info() { } /// wrap below to allow UI to clean up on stop -fn start_server(config: grin::ServerConfig) { +fn start_server(config: servers::ServerConfig) { start_server_tui(config); // Just kill process for now, otherwise the process // hangs around until sigint because the API server @@ -95,12 +95,12 @@ fn start_server(config: grin::ServerConfig) { exit(0); } -fn start_server_tui(config: grin::ServerConfig) { +fn start_server_tui(config: servers::ServerConfig) { // Run the UI controller.. here for now for simplicity to access // everything it might need if config.run_tui.is_some() && config.run_tui.unwrap() { println!("Starting GRIN in UI mode..."); - grin::Server::start(config, |serv: Arc| { + servers::Server::start(config, |serv: Arc| { let _ = thread::Builder::new() .name("ui".to_string()) .spawn(move || { @@ -111,7 +111,7 @@ fn start_server_tui(config: grin::ServerConfig) { }); }).unwrap(); } else { - grin::Server::start(config, |_| {}).unwrap(); + servers::Server::start(config, |_| {}).unwrap(); } } @@ -412,7 +412,7 @@ fn server_command(server_args: Option<&ArgMatches>, mut global_config: GlobalCon } if let Some(seeds) = a.values_of("seed") { - server_config.seeding_type = grin::Seeding::List; + server_config.seeding_type = servers::Seeding::List; server_config.seeds = Some(seeds.map(|s| s.to_string()).collect()); } } diff --git a/src/bin/tui/mining.rs b/src/bin/tui/mining.rs index 37762cdc6..8249ec909 100644 --- a/src/bin/tui/mining.rs +++ b/src/bin/tui/mining.rs @@ -29,7 +29,7 @@ use tui::chrono::prelude::*; use tui::constants::*; use tui::types::*; -use grin::stats::*; +use servers::{ServerStats, DiffBlock}; use tui::pow::cuckoo_miner::CuckooMinerDeviceStats; use tui::table::{TableView, TableViewItem}; diff --git a/src/bin/tui/peers.rs b/src/bin/tui/peers.rs index 24418dbb0..2b59d5ce0 100644 --- a/src/bin/tui/peers.rs +++ b/src/bin/tui/peers.rs @@ -16,7 +16,7 @@ use std::cmp::Ordering; -use grin::stats::{PeerStats, ServerStats}; +use servers::{PeerStats, ServerStats}; use cursive::Cursive; use cursive::view::View; diff --git a/src/bin/tui/status.rs b/src/bin/tui/status.rs index c9009129e..aaca22aba 100644 --- a/src/bin/tui/status.rs +++ b/src/bin/tui/status.rs @@ -23,7 +23,7 @@ use cursive::traits::*; use tui::constants::*; use tui::types::*; -use grin::ServerStats; +use servers::ServerStats; pub struct TUIStatusView; diff --git a/src/bin/tui/types.rs b/src/bin/tui/types.rs index ca8fbaeb8..fea43c11c 100644 --- a/src/bin/tui/types.rs +++ b/src/bin/tui/types.rs @@ -16,7 +16,7 @@ use cursive::Cursive; use cursive::view::View; -use grin::stats::ServerStats; +use servers::ServerStats; /// Main message struct to communicate between the UI and /// the main process diff --git a/src/bin/tui/ui.rs b/src/bin/tui/ui.rs index 747ff1849..310748563 100644 --- a/src/bin/tui/ui.rs +++ b/src/bin/tui/ui.rs @@ -28,7 +28,7 @@ use cursive::views::{LinearLayout, Panel, StackView, TextView, ViewBox}; use cursive::direction::Orientation; use cursive::traits::*; -use grin::Server; +use servers::Server; use tui::{menu, mining, peers, status, version}; use tui::types::*; diff --git a/src/bin/tui/version.rs b/src/bin/tui/version.rs index ee730173f..ceccca1ef 100644 --- a/src/bin/tui/version.rs +++ b/src/bin/tui/version.rs @@ -23,7 +23,7 @@ use cursive::traits::*; use tui::constants::*; use tui::types::*; -use grin::ServerStats; +use servers::ServerStats; use info_strings; pub struct TUIVersionView;