parser: create config.toml if needed

This commit is contained in:
k
2024-07-15 19:07:00 +02:00
parent ad51edbe07
commit 1be22713f9
2 changed files with 9 additions and 5 deletions
+8 -4
View File
@@ -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 {
+1 -1
View File
@@ -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();