mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
global: snapshot
This commit is contained in:
@@ -11,7 +11,6 @@ use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
use crate::{default_brk_path, dot_brk_path, fix_user_path, website::Website};
|
||||
|
||||
|
||||
#[derive(Parser, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
|
||||
#[command(version, about)]
|
||||
pub struct Config {
|
||||
@@ -40,9 +39,9 @@ pub struct Config {
|
||||
#[arg(long, value_name = "BOOL")]
|
||||
exchanges: Option<bool>,
|
||||
|
||||
/// Website served by the server, default: default, saved
|
||||
/// Website served by the server: true (default), false, or PATH, saved
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[arg(short, long)]
|
||||
#[arg(short, long, value_name = "BOOL|PATH")]
|
||||
website: Option<Website>,
|
||||
|
||||
/// Bitcoin RPC ip, default: localhost, saved
|
||||
@@ -232,9 +231,7 @@ Finally, you can run the program with '-h' for help."
|
||||
pub fn bitcoindir(&self) -> PathBuf {
|
||||
self.bitcoindir
|
||||
.as_ref()
|
||||
.map_or_else(Client::default_bitcoin_path, |s| {
|
||||
fix_user_path(s.as_ref())
|
||||
})
|
||||
.map_or_else(Client::default_bitcoin_path, |s| fix_user_path(s.as_ref()))
|
||||
}
|
||||
|
||||
pub fn blocksdir(&self) -> PathBuf {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
use std::{
|
||||
fs,
|
||||
path::PathBuf,
|
||||
thread::{self, sleep},
|
||||
time::Duration,
|
||||
};
|
||||
@@ -68,14 +67,17 @@ pub fn run() -> color_eyre::Result<()> {
|
||||
let data_path = config.brkdir();
|
||||
|
||||
let website_source = match config.website() {
|
||||
Website::Enabled(false) => WebsiteSource::Disabled,
|
||||
Website::Path(p) => WebsiteSource::Filesystem(p),
|
||||
Website::Enabled(false) => {
|
||||
info!("Website: disabled");
|
||||
WebsiteSource::Disabled
|
||||
}
|
||||
Website::Path(p) => {
|
||||
info!("Website: filesystem ({})", p.display());
|
||||
WebsiteSource::Filesystem(p)
|
||||
}
|
||||
Website::Enabled(true) => {
|
||||
// Prefer local filesystem if available, otherwise use embedded
|
||||
match find_local_website_dir() {
|
||||
Some(path) => WebsiteSource::Filesystem(path),
|
||||
None => WebsiteSource::Embedded,
|
||||
}
|
||||
info!("Website: embedded");
|
||||
WebsiteSource::Embedded
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,12 +121,3 @@ pub fn run() -> color_eyre::Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Path to website directory relative to this crate (only valid at dev machine)
|
||||
const DEV_WEBSITE_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../website");
|
||||
|
||||
/// Returns local website path if it exists (dev mode)
|
||||
fn find_local_website_dir() -> Option<PathBuf> {
|
||||
let path = PathBuf::from(DEV_WEBSITE_DIR);
|
||||
path.exists().then_some(path)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ impl Default for Website {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl FromStr for Website {
|
||||
type Err = std::convert::Infallible;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user