diff --git a/.gitignore b/.gitignore index 2834b8e0f..7b02fdf25 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ TODO.md .stfolder +/charts diff --git a/CHANGELOG.md b/CHANGELOG.md index 780ed0884..297d54793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ - Realized Price 0.5th Percentile - Realized Price 0.1th Percentile - Node - - Added a `node.args` file where you can set the path to your node `datadir` and where you can add additional args (you can see the syntax in `parser/README.md`) + - Added an argument parser for improved UX with several options - Price - Improved error message when price cannot be found @@ -40,10 +40,14 @@ - + Better Lighthouse score - - Slower Typescript server - Fixed datasets with null values crashing their fetch function + - Added a 'Go to a random chart' button in several places - Chart - Fixed series color being set to default ones after hovering the legend - Fixed chart starting showing candlesticks and quickly switching to a line when it should've started directly with the line - Separated the QRCode generator library from the main chunk and made it imported on click + - Fixed timescale changing on small screen after changing charts +- Favorites + - Added a 'favorite' and 'unfavorite' button at the bottom - Settings - Removed the horizontal scroll bar which was unintended diff --git a/app/src/app/components/frames/history.tsx b/app/src/app/components/frames/history.tsx index 09ccea2cc..9db23b844 100644 --- a/app/src/app/components/frames/history.tsx +++ b/app/src/app/components/frames/history.tsx @@ -1,6 +1,7 @@ import { run } from "/src/scripts/utils/run"; -import { ButtonRandomChart } from "./button"; +import { Box } from "./box"; +import { Button, ButtonRandomChart } from "./button"; import { Header } from "./header"; import { Line } from "./line"; @@ -94,6 +95,25 @@ export function HistoryFrame({
+ + {/* + + + */} ); } diff --git a/app/src/app/components/frames/search.tsx b/app/src/app/components/frames/search.tsx index b3f67b22f..17f644bf6 100644 --- a/app/src/app/components/frames/search.tsx +++ b/app/src/app/components/frames/search.tsx @@ -186,7 +186,7 @@ export function SearchFrame({ id={INPUT_PRESET_SEARCH_ID} ref={inputRef.set} class="w-full bg-transparent p-1 caret-orange-500 placeholder:text-orange-200/50 focus:outline-none" - placeholder="Search by name or path - / to focus" + placeholder="Search by name or path" value={search()} onFocus={initHaystackIfNeeded} onInput={(event) => search.set(event.target.value)} @@ -243,7 +243,7 @@ function ListSection({ ); return ( -
+
{({ preset, path, title }) => ( { + chart.timeScale().setVisibleRange(range); + }, 50); + + onCleanup(() => { + clearTimeout(timeout); + }); + } +} + export function getInitialTimeRange(scale: ResourceScale): TimeRange { const urlParams = new URLSearchParams(window.location.search); @@ -145,4 +166,4 @@ function saveTimeRange({ localStorage.setItem(getLocalStorageKey(scale), JSON.stringify(range)); } -const debouncedSaveTimeRange = debounce(saveTimeRange, 500); +const debouncedSaveTimeRange = debounce(saveTimeRange, 250); diff --git a/app/src/scripts/presets/apply.ts b/app/src/scripts/presets/apply.ts index 3c0efd200..999700e48 100644 --- a/app/src/scripts/presets/apply.ts +++ b/app/src/scripts/presets/apply.ts @@ -16,6 +16,7 @@ import { getInitialTimeRange, initTimeScale, setActiveIds, + setInitialTimeRange, } from "../lightweightCharts/time"; import { setWhitespace } from "../lightweightCharts/whitespace"; import { colors } from "../utils/colors"; @@ -121,9 +122,7 @@ export function applySeriesList({ const range = exactRange(); - if (range) { - chart.timeScale().setVisibleRange(range); - } + setInitialTimeRange({ chart, range }); if (chartIndex === 0) { initTimeScale({ diff --git a/parser/.gitignore b/parser/.gitignore index 585470447..04a0ff623 100644 --- a/parser/.gitignore +++ b/parser/.gitignore @@ -13,4 +13,6 @@ flamegraph.svg /exports*/ /imports*/ benches -node.args + +parser.log +config.toml diff --git a/parser/Cargo.lock b/parser/Cargo.lock index dfb8c7ae9..b693bd112 100644 --- a/parser/Cargo.lock +++ b/parser/Cargo.lock @@ -256,9 +256,9 @@ checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -301,9 +301,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -311,22 +311,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", - "terminal_size", ] [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", @@ -382,12 +381,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" -[[package]] -name = "condtype" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" - [[package]] name = "core-foundation" version = "0.9.4" @@ -472,11 +465,12 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.3" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" dependencies = [ "cfg-if", + "crossbeam-utils", "hashbrown", "lock_api", "once_cell", @@ -500,31 +494,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "divan" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d567df2c9c2870a43f3f2bd65aaeb18dbce1c18f217c3e564b4fbaeb3ee56c" -dependencies = [ - "cfg-if", - "clap", - "condtype", - "divan-macros", - "libc", - "regex-lite", -] - -[[package]] -name = "divan-macros" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "either" version = "1.12.0" @@ -541,14 +510,24 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.2" +name = "env_filter" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" dependencies = [ "log", ] +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "env_filter", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -910,9 +889,9 @@ dependencies = [ [[package]] name = "inferno" -version = "0.11.19" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" +checksum = "7c77a3ae7d4761b9c64d2c030f70746ceb8cfba32dce0325a56792e0a4816c31" dependencies = [ "ahash", "clap", @@ -1113,12 +1092,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nohash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0f889fb66f7acdf83442c35775764b51fed3c606ab9cee51500dbde2cf528ca" - [[package]] name = "num-format" version = "0.4.4" @@ -1265,7 +1238,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.4", ] @@ -1280,16 +1253,14 @@ dependencies = [ "bitcoin_hashes", "byteorder", "chrono", + "clap", "color-eyre", "db-key", "derive_deref", - "divan", - "fastrand", "inferno", "itertools", "leveldb", "memory-stats", - "nohash", "ordered-float", "par-iter-sync", "rayon", @@ -1297,6 +1268,7 @@ dependencies = [ "sanakirja", "serde", "serde_json", + "toml", ] [[package]] @@ -1401,19 +1373,13 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] -[[package]] -name = "regex-lite" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" - [[package]] name = "reqwest" version = "0.12.5" @@ -1460,9 +1426,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.37" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +checksum = "1aee83dc281d5a3200d37b299acd13b81066ea126a7f16f0eae70fc9aed241d9" dependencies = [ "bytemuck", ] @@ -1657,6 +1623,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1788,16 +1763,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "terminal_size" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" -dependencies = [ - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "thiserror" version = "1.0.58" @@ -1893,6 +1858,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -2297,6 +2296,15 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.52.0" @@ -2309,18 +2317,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 65d717f6f..5f7cfc6f1 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -1,6 +1,9 @@ [package] name = "parser" +description = "A better, FOSS, Bitcoin-only, self-hostable Glassnode" +homepage = "https://satonomics.xyz" version = "0.2.1" +repository = "https://github.com/satonomics-org/satonomics" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -12,16 +15,14 @@ bitcoin = { version = "0.32.2", features = ["serde"] } bitcoin_hashes = { version = "0.14.0" } byteorder = "1.5.0" chrono = { version = "0.4.38", features = ["serde"] } +clap = { version = "4.5.9", features = ["derive"] } color-eyre = "0.6.3" db-key = "=0.0.5" derive_deref = "1.1.1" -divan = "0.1.14" -fastrand = "2.1.0" -inferno = "0.11.19" +inferno = "0.11.20" itertools = "0.13.0" leveldb = "0.8.6" memory-stats = "1.2.0" -nohash = "0.2.0" ordered-float = "4.2.1" par-iter-sync = "0.1.11" rayon = "1.10.0" @@ -29,3 +30,4 @@ reqwest = { version = "0.12.5", features = ["blocking", "json"] } sanakirja = "1.4.2" serde = { version = "1.0.204", features = ["derive"] } serde_json = "1.0.120" +toml = "0.8.14" diff --git a/parser/README.md b/parser/README.md index 789ff7e86..3862f14a6 100644 --- a/parser/README.md +++ b/parser/README.md @@ -11,11 +11,7 @@ The backbone of the project, it does most of the work by parsing and then comput ## Run ```bash -# Update the 'node.args' file with the path to your bitcoin folder and optional bitcoind arguments -# Examples: -# "$HOME/.bitcoin" -# "$HOME/.bitcoin" -rpcconnect=1.2.3.4 -./run.sh +./run.sh --datadir=$HOME/Developer/bitcoin ``` ## Limitations diff --git a/parser/node.args b/parser/node.args deleted file mode 100644 index 7f1f6d725..000000000 --- a/parser/node.args +++ /dev/null @@ -1 +0,0 @@ -"$HOME/Developer/bitcoin" diff --git a/parser/run.sh b/parser/run.sh index 021ebd8c5..b82977f49 100755 --- a/parser/run.sh +++ b/parser/run.sh @@ -18,9 +18,8 @@ if [ "$(uname)" == "Darwin" ]; then sudo mdutil -a -i off &> /dev/null fi - echo "Cleaning local TimeMachine snapshots..." - # If not enough: tmutil thinlocalsnapshots / 500000000000 4 + echo "Thinning local TimeMachine snapshots..." tmutil thinlocalsnapshots / &> /dev/null fi -eval $(echo "cargo run -r -- $(cat node.args)") +cargo run -r -- "$@" diff --git a/parser/samply.sh b/parser/samply.sh index fb6936334..d6d445732 100755 --- a/parser/samply.sh +++ b/parser/samply.sh @@ -1,5 +1,5 @@ echo "Increasing limit of opened files..." -ulimit -n $(ulimit -Hn) +ulimit -n 1000000 # Needed because the datasets tree is too big lol echo "Increasing stack size..." diff --git a/parser/src/bitcoin/daemon.rs b/parser/src/bitcoin/daemon.rs index f9355f379..e728c660e 100644 --- a/parser/src/bitcoin/daemon.rs +++ b/parser/src/bitcoin/daemon.rs @@ -3,7 +3,10 @@ use std::{process::Command, thread::sleep, time::Duration}; use color_eyre::eyre::eyre; use serde_json::Value; -use crate::utils::{log, log_output, retry}; +use crate::{ + utils::{log, log_output, retry}, + Config, +}; struct BlockchainInfo { pub headers: u64, @@ -11,15 +14,13 @@ struct BlockchainInfo { } pub struct BitcoinDaemon { - path: String, - other_args: Vec, + config: Config, } impl BitcoinDaemon { - pub fn new(bitcoin_dir_path: String, other_bitcoin_args: Vec) -> Self { + pub fn new(config: &Config) -> Self { Self { - path: bitcoin_dir_path, - other_args: other_bitcoin_args, + config: config.clone(), } } @@ -30,13 +31,16 @@ impl BitcoinDaemon { command .arg(self.datadir_arg()) - .arg("-blocksonly") .arg("-txindex=1") .arg("-daemon"); - self.other_args.iter().for_each(|arg| { - command.arg(arg); - }); + if self.config.blocksonly.unwrap() { + command.arg("-blocksonly"); + } + + if let Some(ip) = self.config.rpcconnect.as_ref() { + command.arg(format!("-rpcconnect={}", ip)); + } // bitcoind -datadir=/Users/k/Developer/bitcoin -blocksonly -txindex=1 -daemon let output = command @@ -123,6 +127,10 @@ impl BitcoinDaemon { } fn datadir_arg(&self) -> String { - format!("-datadir={}", self.path) + if self.config.datadir.is_none() { + unreachable!(); + } + + format!("-datadir={}", self.config.datadir.as_ref().unwrap()) } } diff --git a/parser/src/lib.rs b/parser/src/lib.rs index e86db4259..8b297cb25 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -14,7 +14,7 @@ pub use crate::{ datasets::OHLC, io::{Binary, Json, Serialization}, structs::{ - DateMap, HeightMap, SerializedDateMap, SerializedHeightMap, WNaiveDate, + Config, DateMap, HeightMap, SerializedDateMap, SerializedHeightMap, WNaiveDate, HEIGHT_MAP_CHUNK_SIZE, }, utils::log, diff --git a/parser/src/main.rs b/parser/src/main.rs index 114a7b3cf..63492e135 100644 --- a/parser/src/main.rs +++ b/parser/src/main.rs @@ -1,23 +1,29 @@ -use std::{env::args, path::Path}; +use std::{path::Path, thread::sleep, time::Duration}; -use itertools::Itertools; -use parser::{iter_blocks, log, BitcoinDB, BitcoinDaemon}; +use color_eyre::eyre::eyre; +use parser::{iter_blocks, log, BitcoinDB, BitcoinDaemon, Config}; fn main() -> color_eyre::Result<()> { - let mut args = args().collect_vec(); - let bitcoin_dir_path = args.get(1).unwrap().to_owned(); - args.drain(0..2); - color_eyre::install()?; - let deamon = BitcoinDaemon::new(bitcoin_dir_path.to_owned(), args); + 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" + )); + } + + config.write()?; + + let daemon = BitcoinDaemon::new(&config); loop { - deamon.stop(); + daemon.stop(); // Scoped to free bitcoin's lock let block_count = { - let bitcoin_db = BitcoinDB::new(Path::new(&bitcoin_dir_path), true)?; + let bitcoin_db = BitcoinDB::new(Path::new(&config.datadir.as_ref().unwrap()), true)?; // let block_count = 200_000; let block_count = bitcoin_db.get_block_count(); @@ -29,12 +35,16 @@ fn main() -> color_eyre::Result<()> { block_count }; - deamon.start(); + daemon.start(); - if deamon.check_if_fully_synced() { - deamon.wait_for_new_block(block_count - 1); + if daemon.check_if_fully_synced() { + daemon.wait_for_new_block(block_count - 1); } else { - deamon.wait_sync(); + daemon.wait_sync(); + } + + if let Some(delay) = config.delay { + sleep(Duration::from_secs(delay)) } } diff --git a/parser/src/structs/config.rs b/parser/src/structs/config.rs new file mode 100644 index 000000000..44e69ff15 --- /dev/null +++ b/parser/src/structs/config.rs @@ -0,0 +1,62 @@ +use std::fs::{self, File}; + +use clap::Parser; +use serde::{Deserialize, Serialize}; + +#[derive(Parser, Debug, Clone, Default, Serialize, Deserialize)] +#[command(version, about, long_about = None)] +pub struct Config { + /// bitcoind `-datadir=` argument + #[arg(long, value_name = "DIR")] + pub datadir: Option, + + /// bitcoind `-blocksonly` argument, default: true + #[arg(long)] + pub blocksonly: Option, + + /// bitcoind `-rpcconnect=` argument + #[arg(long, value_name = "IP")] + pub rpcconnect: Option, + + /// Delay between runs, default: 0 + #[arg(long, value_name = "SECONDS")] + pub delay: Option, +} + +impl Config { + const PATH: &'static str = "config.toml"; + + pub fn read() -> Self { + File::open(Self::PATH).unwrap(); + + let string = fs::read_to_string(Self::PATH).unwrap(); + + let config_args = Config::parse(); + + let mut config_saved: Config = toml::from_str(&string).unwrap_or_default(); + + if let Some(datadir) = config_args.datadir { + config_saved.datadir = Some(datadir); + } + + if let Some(blocksonly) = config_args.blocksonly { + config_saved.blocksonly = Some(blocksonly); + } else { + config_saved.blocksonly = Some(true); + } + + if let Some(rpcconnect) = config_args.rpcconnect { + config_saved.rpcconnect = Some(rpcconnect); + } + + if let Some(delay) = config_args.delay { + config_saved.delay = Some(delay); + } + + config_saved + } + + pub fn write(&self) -> std::io::Result<()> { + fs::write(Self::PATH, toml::to_string(self).unwrap()) + } +} diff --git a/parser/src/structs/mod.rs b/parser/src/structs/mod.rs index 61e7be34e..8f8d21403 100644 --- a/parser/src/structs/mod.rs +++ b/parser/src/structs/mod.rs @@ -8,6 +8,7 @@ mod any_map; mod bi_map; mod block_data; mod block_path; +mod config; mod counter; mod date_data; mod date_map; @@ -33,6 +34,7 @@ pub use any_map::*; pub use bi_map::*; pub use block_data::*; pub use block_path::*; +pub use config::*; pub use counter::*; pub use date_data::*; pub use date_map::*; diff --git a/parser/src/utils/log.rs b/parser/src/utils/log.rs index 7c657a202..7d8aacfd0 100644 --- a/parser/src/utils/log.rs +++ b/parser/src/utils/log.rs @@ -1,4 +1,4 @@ -use std::process::Output; +use std::{fs::OpenOptions, io::Write, process::Output}; use chrono::Local; use color_eyre::owo_colors::OwoColorize; @@ -10,6 +10,16 @@ pub fn log(str: &str) { str.lines() .filter(|line| !line.is_empty()) .for_each(|line| { + let mut file = OpenOptions::new() + .create(true) + .append(true) + .open("./parser.log") + .unwrap(); + + if let Err(e) = writeln!(file, "{} {}", date_time, line) { + eprintln!("Couldn't write to file: {}", e); + } + println!("{} {}", date_time.bright_black(), line); }); } diff --git a/server/.gitignore b/server/.gitignore index 05923927f..adc710f2f 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -1,2 +1,3 @@ /target .DS_Store +/parser.log diff --git a/server/Cargo.lock b/server/Cargo.lock index beae438d3..29f9df7c0 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -383,9 +383,9 @@ checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -432,9 +432,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -442,22 +442,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", - "terminal_size", ] [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", @@ -513,12 +512,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" -[[package]] -name = "condtype" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" - [[package]] name = "core-foundation" version = "0.9.4" @@ -612,11 +605,12 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.3" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" dependencies = [ "cfg-if", + "crossbeam-utils", "hashbrown", "lock_api", "once_cell", @@ -640,31 +634,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "divan" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d567df2c9c2870a43f3f2bd65aaeb18dbce1c18f217c3e564b4fbaeb3ee56c" -dependencies = [ - "cfg-if", - "clap", - "condtype", - "divan-macros", - "libc", - "regex-lite", -] - -[[package]] -name = "divan-macros" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - [[package]] name = "either" version = "1.12.0" @@ -681,14 +650,24 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.2" +name = "env_filter" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" dependencies = [ "log", ] +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "env_filter", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1067,9 +1046,9 @@ dependencies = [ [[package]] name = "inferno" -version = "0.11.19" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" +checksum = "7c77a3ae7d4761b9c64d2c030f70746ceb8cfba32dce0325a56792e0a4816c31" dependencies = [ "ahash", "clap", @@ -1285,12 +1264,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nohash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0f889fb66f7acdf83442c35775764b51fed3c606ab9cee51500dbde2cf528ca" - [[package]] name = "num-format" version = "0.4.4" @@ -1462,16 +1435,14 @@ dependencies = [ "bitcoin_hashes", "byteorder", "chrono", + "clap", "color-eyre", "db-key", "derive_deref", - "divan", - "fastrand", "inferno", "itertools", "leveldb", "memory-stats", - "nohash", "ordered-float", "par-iter-sync", "rayon", @@ -1479,6 +1450,7 @@ dependencies = [ "sanakirja", "serde", "serde_json", + "toml", ] [[package]] @@ -1613,12 +1585,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "regex-lite" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" - [[package]] name = "regex-syntax" version = "0.8.2" @@ -1671,9 +1637,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.37" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +checksum = "1aee83dc281d5a3200d37b299acd13b81066ea126a7f16f0eae70fc9aed241d9" dependencies = [ "bytemuck", ] @@ -1884,6 +1850,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2048,16 +2023,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "terminal_size" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" -dependencies = [ - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "thiserror" version = "1.0.58" @@ -2168,6 +2133,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -2592,6 +2591,15 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.52.0" @@ -2604,18 +2612,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote",