mirror of
https://github.com/mimblewimble/grin.git
synced 2025-04-25 03:41:14 +03:00
Start of a binary file for the grin node
This commit is contained in:
parent
96ea9a7d9f
commit
f18aeb3024
3 changed files with 56 additions and 0 deletions
|
@ -5,3 +5,11 @@ authors = ["Ignotus Peverell <igno.peverell@protonmail.com>"]
|
|||
|
||||
[workspace]
|
||||
members = ["api", "chain", "core", "grin", "p2p", "store", "util"]
|
||||
|
||||
[dependencies]
|
||||
grin_grin = { path = "./grin" }
|
||||
|
||||
env_logger="^0.3.5"
|
||||
log = "^0.3"
|
||||
serde = "~0.9.10"
|
||||
serde_json = "~0.9.9"
|
||||
|
|
3
rustfmt.toml
Normal file
3
rustfmt.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
hard_tabs = true
|
||||
wrap_comments = true
|
||||
write_mode = "Overwrite"
|
|
@ -14,5 +14,50 @@
|
|||
|
||||
//! Main for building the binary of a Grin peer-to-peer node.
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
|
||||
extern crate grin_grin as grin;
|
||||
|
||||
const GRIN_HOME: &'static str = ".grin";
|
||||
|
||||
use std::env;
|
||||
use std::thread;
|
||||
use std::io::Read;
|
||||
use std::fs::File;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
env_logger::init().unwrap();
|
||||
|
||||
info!("Starting the Grin server...");
|
||||
grin::Server::start(read_config()).unwrap();
|
||||
|
||||
loop {
|
||||
thread::sleep(Duration::from_secs(60));
|
||||
}
|
||||
}
|
||||
|
||||
fn read_config() -> grin::ServerConfig {
|
||||
let mut config_path = env::home_dir().ok_or("Failed to detect home directory!").unwrap();
|
||||
config_path.push(GRIN_HOME);
|
||||
if !config_path.exists() {
|
||||
return default_config();
|
||||
}
|
||||
let mut config_file = File::open(config_path).unwrap();
|
||||
let mut config_content = String::new();
|
||||
config_file.read_to_string(&mut config_content).unwrap();
|
||||
serde_json::from_str(config_content.as_str()).unwrap()
|
||||
}
|
||||
|
||||
fn default_config() -> grin::ServerConfig {
|
||||
grin::ServerConfig {
|
||||
cuckoo_size: 12,
|
||||
seeding_type: grin::Seeding::WebStatic,
|
||||
enable_mining: false,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue