openethereum/chainspec/src/main.rs

52 lines
1.5 KiB
Rust
Raw Normal View History

// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
extern crate ethjson;
2020-08-05 06:08:03 +02:00
extern crate serde_json;
use ethjson::spec::Spec;
2020-08-05 06:08:03 +02:00
use std::{env, fs, process};
fn quit(s: &str) -> ! {
2020-08-05 06:08:03 +02:00
println!("{}", s);
process::exit(1);
}
fn main() {
2020-08-05 06:08:03 +02:00
let mut args = env::args();
if args.len() != 2 {
quit(
"You need to specify chainspec.json\n\
\n\
2020-08-05 06:08:03 +02:00
./chainspec <chainspec.json>",
);
}
2020-08-05 06:08:03 +02:00
let path = args.nth(1).expect("args.len() == 2; qed");
let file = match fs::File::open(&path) {
Ok(file) => file,
Err(_) => quit(&format!("{} could not be opened", path)),
};
2020-08-05 06:08:03 +02:00
let spec: Result<Spec, _> = serde_json::from_reader(file);
2020-08-05 06:08:03 +02:00
if let Err(err) = spec {
quit(&format!("{} {}", path, err.to_string()));
}
2020-08-05 06:08:03 +02:00
println!("{} is valid", path);
}