Skip to content

Commit

Permalink
Merge ad2145a into 399a725
Browse files Browse the repository at this point in the history
  • Loading branch information
ssyuan authored Jan 8, 2021
2 parents 399a725 + ad2145a commit 4553add
Show file tree
Hide file tree
Showing 33 changed files with 453 additions and 187 deletions.
98 changes: 95 additions & 3 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 cmd/miner_client/src/cpu_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Solver for CpuSolver {
nonce_tx: mpsc::UnboundedSender<(Vec<u8>, u32)>,
mut stop_rx: mpsc::UnboundedReceiver<bool>,
) {
let thread_num = self.config.thread_num;
let thread_num = self.config.miner_thread();
let worker_txs = (0..thread_num)
.map(|i| {
let worker_name = format!("starcoin-miner-cpu-worker-{}", i);
Expand Down
2 changes: 1 addition & 1 deletion cmd/miner_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
MinerClientConfig {
server: Some(opts.server.clone()),
plugin_path: opts.plugin_path,
thread_num: opts.thread_num,
miner_thread: Some(opts.thread_num),
enable_stderr: true,
}
};
Expand Down
4 changes: 2 additions & 2 deletions cmd/starcoin/src/dev/sign_txn_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ mod tests {
#[stest::test(timeout = 300)]
fn test_upgrade_module() {
let mut node_config = NodeConfig::random_for_test();
node_config.network.disable_seed = true;
node_config.network.disable_seed = Some(true);
let config = Arc::new(node_config);
let node_handle = run_node_by_config(config.clone()).unwrap();
let rpc_service = node_handle.rpc_service().unwrap();
Expand Down Expand Up @@ -438,7 +438,7 @@ mod tests {
#[stest::test(timeout = 300)]
fn test_only_new_module() {
let mut node_config = NodeConfig::random_for_test();
node_config.network.disable_seed = true;
node_config.network.disable_seed = Some(true);
let config = Arc::new(node_config);
let node_handle = run_node_by_config(config.clone()).unwrap();
let rpc_service = node_handle.rpc_service().unwrap();
Expand Down
11 changes: 11 additions & 0 deletions commons/system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "starcoin-system"
version = "0.9.4"
authors = ["Starcoin Core Dev <dev@starcoin.org>"]
license = "Apache-2.0"
publish = false
edition = "2018"

[dependencies]
systemstat ="0.1.6"
anyhow = "1.0.37"
14 changes: 14 additions & 0 deletions commons/system/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use systemstat::{Platform, System};

pub fn get_free_mem_size() -> Result<u64> {
let sys = System::new();
let free = match sys.memory() {
Ok(mem) => mem.free.as_u64(),
Err(_x) => 0u64,
};
Ok(free)
}
2 changes: 2 additions & 0 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ publish = false
edition = "2018"

[dependencies]
clap = "2.33.3"
dirs = "3"
anyhow = "1.0.37"
thiserror = "1.0"
Expand All @@ -27,3 +28,4 @@ starcoin-vm-types = { path = "../vm/types" }
network-p2p-types = { path = "../network-p2p/types"}
starcoin-logger = {path = "../commons/logger", package="starcoin-logger"}
diem-temppath = { git = "https://github.com/starcoinorg/diem", rev="89223522186cb4cd39e21e44fb2da745f7a45c7a" }
starcoin-system = {path = "../commons/system", package="starcoin-system"}
5 changes: 4 additions & 1 deletion config/src/account_vault_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ use crate::{BaseConfig, ConfigModule, StarcoinOpt};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use structopt::StructOpt;

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, StructOpt)]
#[serde(deny_unknown_fields)]
pub struct AccountVaultConfig {
#[structopt(long = "vault-dir", parse(from_os_str), conflicts_with("vault-dir"))]
/// Account vault dir config.
dir: PathBuf,
#[serde(skip)]
absolute_dir: Option<PathBuf>,
Expand Down
43 changes: 8 additions & 35 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,37 +198,14 @@ pub struct StarcoinOpt {
/// Rpc address, default is 127.0.0.1
pub rpc_address: Option<String>,

#[structopt(long = "miner-thread")]
/// Miner thread number, not work for dev network, default is 1
pub miner_thread: Option<u16>,

#[structopt(long = "disable-std-log")]
/// Disable std error log output.
pub disable_std_log: bool,

#[structopt(long = "disable-file-log")]
/// Disable std error log output.
pub disable_file_log: bool,

#[structopt(long = "disable-metrics")]
/// Disable metrics.
pub disable_metrics: bool,

#[structopt(long = "disable-miner-client")]
/// Don't start a miner client in node.
pub disable_miner_client: bool,

#[structopt(long = "disable-seed")]
/// Do not connect to seed node, include builtin and config seed.
pub disable_seed: bool,

#[structopt(long = "enable-mdns")]
/// Enable p2p mdns discovery, for automatically discover the peer from the local network.
pub enable_mdns: bool,

#[structopt(long = "disable-mint-empty-block")]
/// Do not mint empty block, default is true in Dev network.
pub disable_mint_empty_block: Option<bool>,
#[structopt(flatten)]
pub logger: LoggerConfig,
#[structopt(flatten)]
pub metrics: MetricsConfig,
#[structopt(flatten)]
pub miner: MinerConfig,
#[structopt(flatten)]
pub network: NetworkConfig,

#[structopt(long = "watch-timeout")]
/// Watch timeout in seconds
Expand All @@ -249,8 +226,6 @@ pub struct StarcoinOpt {
pub ipc: IpcConfiguration,
#[structopt(flatten)]
pub api_quotas: ApiQuotaConfiguration,
#[structopt(flatten)]
pub network_rpc_quotas: NetworkRpcQuotaConfiguration,
}

#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -444,9 +419,7 @@ impl NodeConfig {
}
}
};

config.after_load(opt, &base)?;
save_config(&config, &config_file_path)?;
Ok(config)
}

Expand Down
Loading

0 comments on commit 4553add

Please sign in to comment.