mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-10 23:13:33 -07:00
parser: create config.toml if needed
This commit is contained in:
+8
-4
@@ -1,6 +1,5 @@
|
||||
use std::{path::Path, thread::sleep, time::Duration};
|
||||
|
||||
use color_eyre::eyre::eyre;
|
||||
use parser::{iter_blocks, log, BitcoinDB, BitcoinDaemon, Config};
|
||||
|
||||
fn main() -> color_eyre::Result<()> {
|
||||
@@ -9,13 +8,18 @@ fn main() -> color_eyre::Result<()> {
|
||||
let config = Config::read();
|
||||
|
||||
if config.datadir.is_none() {
|
||||
return Err(eyre!(
|
||||
"You need to set the --datadir parameter at least once to run the parser"
|
||||
));
|
||||
println!(
|
||||
"You need to set the --datadir parameter at least once to run the parser.\nRun the program with '-h' for help."
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
config.write()?;
|
||||
|
||||
if true {
|
||||
panic!();
|
||||
}
|
||||
|
||||
let daemon = BitcoinDaemon::new(&config);
|
||||
|
||||
loop {
|
||||
|
||||
@@ -27,7 +27,7 @@ impl Config {
|
||||
const PATH: &'static str = "config.toml";
|
||||
|
||||
pub fn read() -> Self {
|
||||
File::open(Self::PATH).unwrap();
|
||||
fs::write(Self::PATH, "").unwrap();
|
||||
|
||||
let string = fs::read_to_string(Self::PATH).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user