mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-01 06:19:02 -07:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18fb2e7d4d | |||
| a610fd53e2 | |||
| 16abce1f2d | |||
| f3b42f34a6 | |||
| 6483d324de | |||
| 5ab97050dd | |||
| 17eed70903 | |||
| 88067c03b7 | |||
| 7c1e5b913f | |||
| 0014235e91 | |||
| a39b7be1d1 | |||
| de98c5f706 | |||
| 10b496e845 | |||
| bbe7bf390d | |||
| 4777b3400a | |||
| acaa70e944 | |||
| 4049d694f7 | |||
| e155a3dacf |
@@ -64,7 +64,7 @@ jobs:
|
|||||||
# we specify bash to get pipefail; it guards against the `curl` command
|
# we specify bash to get pipefail; it guards against the `curl` command
|
||||||
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
||||||
shell: bash
|
shell: bash
|
||||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.29.0/cargo-dist-installer.sh | sh"
|
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.0/cargo-dist-installer.sh | sh"
|
||||||
- name: Cache dist
|
- name: Cache dist
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
# Builds
|
# Builds
|
||||||
target
|
target
|
||||||
websites/dist
|
websites/dist
|
||||||
vecid-to-indexes.js
|
bridge/
|
||||||
/ids.txt
|
/ids.txt
|
||||||
|
|
||||||
# Copies
|
# Copies
|
||||||
|
|||||||
Generated
+404
-173
File diff suppressed because it is too large
Load Diff
+20
-18
@@ -4,7 +4,7 @@ members = ["crates/*"]
|
|||||||
package.description = "The Bitcoin Research Kit is a suite of tools designed to extract, compute and display data stored on a Bitcoin Core node"
|
package.description = "The Bitcoin Research Kit is a suite of tools designed to extract, compute and display data stored on a Bitcoin Core node"
|
||||||
package.license = "MIT"
|
package.license = "MIT"
|
||||||
package.edition = "2024"
|
package.edition = "2024"
|
||||||
package.version = "0.0.98"
|
package.version = "0.0.106"
|
||||||
package.homepage = "https://bitcoinresearchkit.org"
|
package.homepage = "https://bitcoinresearchkit.org"
|
||||||
package.repository = "https://github.com/bitcoinresearchkit/brk"
|
package.repository = "https://github.com/bitcoinresearchkit/brk"
|
||||||
package.readme = "README.md"
|
package.readme = "README.md"
|
||||||
@@ -23,22 +23,24 @@ debug = true
|
|||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
allocative = { version = "0.3.4", features = ["parking_lot"] }
|
||||||
|
allocative_derive = "0.3.3"
|
||||||
axum = "0.8.4"
|
axum = "0.8.4"
|
||||||
bitcoin = { version = "0.32.7", features = ["serde"] }
|
bitcoin = { version = "0.32.7", features = ["serde"] }
|
||||||
bitcoincore-rpc = "0.19.0"
|
bitcoincore-rpc = "0.19.0"
|
||||||
brk_bundler = { version = "0.0.98", path = "crates/brk_bundler" }
|
brk_bundler = { version = "0.0.106", path = "crates/brk_bundler" }
|
||||||
brk_cli = { version = "0.0.98", path = "crates/brk_cli" }
|
brk_cli = { version = "0.0.106", path = "crates/brk_cli" }
|
||||||
brk_computer = { version = "0.0.98", path = "crates/brk_computer" }
|
brk_computer = { version = "0.0.106", path = "crates/brk_computer" }
|
||||||
brk_error = { version = "0.0.98", path = "crates/brk_error" }
|
brk_error = { version = "0.0.106", path = "crates/brk_error" }
|
||||||
brk_fetcher = { version = "0.0.98", path = "crates/brk_fetcher" }
|
brk_fetcher = { version = "0.0.106", path = "crates/brk_fetcher" }
|
||||||
brk_indexer = { version = "0.0.98", path = "crates/brk_indexer" }
|
brk_indexer = { version = "0.0.106", path = "crates/brk_indexer" }
|
||||||
brk_interface = { version = "0.0.98", path = "crates/brk_interface" }
|
brk_interface = { version = "0.0.106", path = "crates/brk_interface" }
|
||||||
brk_logger = { version = "0.0.98", path = "crates/brk_logger" }
|
brk_logger = { version = "0.0.106", path = "crates/brk_logger" }
|
||||||
brk_mcp = { version = "0.0.98", path = "crates/brk_mcp" }
|
brk_mcp = { version = "0.0.106", path = "crates/brk_mcp" }
|
||||||
brk_parser = { version = "0.0.98", path = "crates/brk_parser" }
|
brk_parser = { version = "0.0.106", path = "crates/brk_parser" }
|
||||||
brk_server = { version = "0.0.98", path = "crates/brk_server" }
|
brk_server = { version = "0.0.106", path = "crates/brk_server" }
|
||||||
brk_store = { version = "0.0.98", path = "crates/brk_store" }
|
brk_store = { version = "0.0.106", path = "crates/brk_store" }
|
||||||
brk_structs = { version = "0.0.98", path = "crates/brk_structs" }
|
brk_structs = { version = "0.0.106", path = "crates/brk_structs" }
|
||||||
byteview = "=0.6.1"
|
byteview = "=0.6.1"
|
||||||
derive_deref = "1.1.1"
|
derive_deref = "1.1.1"
|
||||||
fjall = "2.11.2"
|
fjall = "2.11.2"
|
||||||
@@ -54,9 +56,9 @@ serde_derive = "1.0.219"
|
|||||||
serde_json = { version = "1.0.143", features = ["float_roundtrip"] }
|
serde_json = { version = "1.0.143", features = ["float_roundtrip"] }
|
||||||
tokio = { version = "1.47.1", features = ["rt-multi-thread"] }
|
tokio = { version = "1.47.1", features = ["rt-multi-thread"] }
|
||||||
# vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]}
|
# vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]}
|
||||||
vecdb = { version = "0.2.9", features = ["derive"]}
|
vecdb = { version = "0.2.12", features = ["derive"]}
|
||||||
zerocopy = "0.8.26"
|
zerocopy = "0.8.27"
|
||||||
zerocopy-derive = "0.8.26"
|
zerocopy-derive = "0.8.27"
|
||||||
|
|
||||||
[workspace.metadata.release]
|
[workspace.metadata.release]
|
||||||
shared-version = true
|
shared-version = true
|
||||||
@@ -65,7 +67,7 @@ pre-release-commit-message = "release: v{{version}}"
|
|||||||
tag-message = "release: v{{version}}"
|
tag-message = "release: v{{version}}"
|
||||||
|
|
||||||
[workspace.metadata.dist]
|
[workspace.metadata.dist]
|
||||||
cargo-dist-version = "0.29.0"
|
cargo-dist-version = "0.30.0"
|
||||||
ci = "github"
|
ci = "github"
|
||||||
allow-dirty = ["ci"]
|
allow-dirty = ["ci"]
|
||||||
installers = []
|
installers = []
|
||||||
|
|||||||
@@ -64,11 +64,9 @@
|
|||||||
- miners
|
- miners
|
||||||
- maybe xpubs
|
- maybe xpubs
|
||||||
- charts
|
- charts
|
||||||
- improve some names and colors
|
- improve names and colors
|
||||||
- remove `sum` series when it's a duplicate of the `base` (in subsidy for example)
|
|
||||||
- selected unit sometimes changes when going back end forth
|
- selected unit sometimes changes when going back end forth
|
||||||
- add support for custom charts
|
- add support for custom charts
|
||||||
- separate z-score charts from "realized price" (with their own prices), have 4y, 2y and 1y
|
|
||||||
- price scale format depends on unit, hide digits for sats for example (if/when possible)
|
- price scale format depends on unit, hide digits for sats for example (if/when possible)
|
||||||
- table
|
- table
|
||||||
- pagination
|
- pagination
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ build = "build.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
notify = "8.2.0"
|
notify = "8.2.0"
|
||||||
brk_rolldown = "0.1.4"
|
brk_rolldown = "0.1.5"
|
||||||
# brk_rolldown = { path = "../../../rolldown/crates/rolldown"}
|
# brk_rolldown = { path = "../../../rolldown/crates/rolldown"}
|
||||||
sugar_path = "1.2.0"
|
sugar_path = "1.2.0"
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ pub async fn bundle(websites_path: &Path, source_folder: &str, watch: bool) -> i
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
bundler.write().await.unwrap();
|
if let Err(error) = bundler.write().await {
|
||||||
|
error!("{error:?}");
|
||||||
|
}
|
||||||
|
|
||||||
let absolute_source_index_path = source_path.join("index.html").absolutize();
|
let absolute_source_index_path = source_path.join("index.html").absolutize();
|
||||||
let absolute_source_index_path_clone = absolute_source_index_path.clone();
|
let absolute_source_index_path_clone = absolute_source_index_path.clone();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ minreq = { workspace = true }
|
|||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
toml = "0.9.5"
|
toml = "0.9.5"
|
||||||
zip = { version = "4.6.1", default-features = false, features = ["deflate"] }
|
zip = { version = "5.0.0", default-features = false, features = ["deflate"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "brk"
|
name = "brk"
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
use std::{fs, io, path::Path};
|
use std::{fs, io, path::Path};
|
||||||
|
|
||||||
|
use brk_computer::pools;
|
||||||
use brk_interface::{Index, Interface};
|
use brk_interface::{Index, Interface};
|
||||||
use brk_server::VERSION;
|
use brk_server::VERSION;
|
||||||
|
|
||||||
use crate::website::Website;
|
use crate::website::Website;
|
||||||
|
|
||||||
const SCRIPTS: &str = "scripts";
|
const BRIDGE_PATH: &str = "scripts/bridge";
|
||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
pub trait Bridge {
|
pub trait Bridge {
|
||||||
fn generate_bridge_file(&self, website: Website, websites_path: &Path) -> io::Result<()>;
|
fn generate_bridge_files(&self, website: Website, websites_path: &Path) -> io::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bridge for Interface<'static> {
|
impl Bridge for Interface<'static> {
|
||||||
fn generate_bridge_file(&self, website: Website, websites_path: &Path) -> io::Result<()> {
|
fn generate_bridge_files(&self, website: Website, websites_path: &Path) -> io::Result<()> {
|
||||||
if website.is_none() {
|
if website.is_none() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -24,88 +25,130 @@ impl Bridge for Interface<'static> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = path.join(SCRIPTS);
|
let path = path.join(BRIDGE_PATH);
|
||||||
|
|
||||||
fs::create_dir_all(&path)?;
|
fs::create_dir_all(&path)?;
|
||||||
|
|
||||||
let path = path.join(Path::new("vecid-to-indexes.js"));
|
generate_vecs_file(self, &path)?;
|
||||||
|
generate_pools_file(&path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let indexes = Index::all();
|
fn generate_pools_file(parent: &Path) -> io::Result<()> {
|
||||||
|
let path = parent.join(Path::new("pools.js"));
|
||||||
|
|
||||||
let mut contents = format!(
|
let pools = pools();
|
||||||
"//
|
|
||||||
|
let mut contents = "//
|
||||||
|
// File auto-generated, any modifications will be overwritten
|
||||||
|
//
|
||||||
|
"
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
contents += "
|
||||||
|
/** @typedef {ReturnType<typeof createPools>} Pools */
|
||||||
|
/** @typedef {keyof Pools} Pool */
|
||||||
|
|
||||||
|
export function createPools() {
|
||||||
|
return /** @type {const} */ ({
|
||||||
|
";
|
||||||
|
|
||||||
|
let mut sorted_pools: Vec<_> = pools.iter().collect();
|
||||||
|
sorted_pools.sort_by(|a, b| a.name.to_lowercase().cmp(&b.name.to_lowercase()));
|
||||||
|
|
||||||
|
contents += &sorted_pools
|
||||||
|
.iter()
|
||||||
|
.map(|pool| {
|
||||||
|
let id = pool.serialized_id();
|
||||||
|
format!(" {id}: \"{}\",", pool.name)
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
contents += "\n });\n}\n";
|
||||||
|
|
||||||
|
fs::write(path, contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generate_vecs_file(interface: &Interface<'static>, parent: &Path) -> io::Result<()> {
|
||||||
|
let path = parent.join(Path::new("vecs.js"));
|
||||||
|
|
||||||
|
let indexes = Index::all();
|
||||||
|
|
||||||
|
let mut contents = format!(
|
||||||
|
"//
|
||||||
// File auto-generated, any modifications will be overwritten
|
// File auto-generated, any modifications will be overwritten
|
||||||
//
|
//
|
||||||
|
|
||||||
export const VERSION = \"v{VERSION}\";
|
export const VERSION = \"v{VERSION}\";
|
||||||
|
|
||||||
"
|
"
|
||||||
);
|
);
|
||||||
|
|
||||||
contents += &indexes
|
contents += &indexes
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i_of_i, i)| {
|
||||||
|
// let lowered = i.to_string().to_lowercase();
|
||||||
|
format!("/** @typedef {{{i_of_i}}} {i} */",)
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
contents += &format!(
|
||||||
|
"\n\n/** @typedef {{{}}} Index */\n",
|
||||||
|
indexes
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.map(|i| i.to_string())
|
||||||
.map(|(i_of_i, i)| {
|
|
||||||
// let lowered = i.to_string().to_lowercase();
|
|
||||||
format!("/** @typedef {{{i_of_i}}} {i} */",)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join(" | ")
|
||||||
|
);
|
||||||
|
|
||||||
contents += &format!(
|
contents += "
|
||||||
"\n\n/** @typedef {{{}}} Index */\n",
|
|
||||||
indexes
|
|
||||||
.iter()
|
|
||||||
.map(|i| i.to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(" | ")
|
|
||||||
);
|
|
||||||
|
|
||||||
contents += "
|
|
||||||
/** @typedef {ReturnType<typeof createIndexes>} Indexes */
|
/** @typedef {ReturnType<typeof createIndexes>} Indexes */
|
||||||
|
|
||||||
export function createIndexes() {
|
export function createIndexes() {
|
||||||
return {
|
return {
|
||||||
";
|
";
|
||||||
|
|
||||||
contents += &indexes
|
contents += &indexes
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i_of_i, i)| {
|
.map(|(i_of_i, i)| {
|
||||||
let lowered = i.to_string().to_lowercase();
|
let lowered = i.to_string().to_lowercase();
|
||||||
format!(" {lowered}: /** @satisfies {{{i}}} */ ({i_of_i}),",)
|
format!(" {lowered}: /** @satisfies {{{i}}} */ ({i_of_i}),",)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
contents += " };\n}\n";
|
contents += " };\n}\n";
|
||||||
|
|
||||||
contents += "
|
contents += "
|
||||||
/** @typedef {ReturnType<typeof createVecIdToIndexes>} VecIdToIndexes
|
/** @typedef {ReturnType<typeof createVecIdToIndexes>} VecIdToIndexes
|
||||||
/** @typedef {keyof VecIdToIndexes} VecId */
|
/** @typedef {keyof VecIdToIndexes} VecId */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Record<any, number[]>}
|
* @returns {Record<any, number[]>}
|
||||||
*/
|
*/
|
||||||
export function createVecIdToIndexes() {
|
export function createVecIdToIndexes() {
|
||||||
return {
|
return {
|
||||||
";
|
";
|
||||||
|
|
||||||
self.id_to_index_to_vec()
|
interface
|
||||||
.iter()
|
.id_to_index_to_vec()
|
||||||
.for_each(|(id, index_to_vec)| {
|
.iter()
|
||||||
let indexes = index_to_vec
|
.for_each(|(id, index_to_vec)| {
|
||||||
.keys()
|
let indexes = index_to_vec
|
||||||
.map(|i| (*i as u8).to_string())
|
.keys()
|
||||||
// .map(|i| i.to_string())
|
.map(|i| (*i as u8).to_string())
|
||||||
.collect::<Vec<_>>()
|
// .map(|i| i.to_string())
|
||||||
.join(", ");
|
.collect::<Vec<_>>()
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
contents += &format!(" \"{id}\": [{indexes}],\n");
|
contents += &format!(" \"{id}\": [{indexes}],\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
contents += " };\n}\n";
|
contents += " };\n}\n";
|
||||||
|
|
||||||
fs::write(path, contents)
|
fs::write(path, contents)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use std::{
|
|||||||
use bitcoincore_rpc::{self, Auth, Client};
|
use bitcoincore_rpc::{self, Auth, Client};
|
||||||
use brk_fetcher::Fetcher;
|
use brk_fetcher::Fetcher;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use clap_derive::Parser;
|
|
||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ pub fn run() -> color_eyre::Result<()> {
|
|||||||
downloaded_websites_path
|
downloaded_websites_path
|
||||||
};
|
};
|
||||||
|
|
||||||
interface.generate_bridge_file(website, websites_path.as_path())?;
|
interface.generate_bridge_files(website, websites_path.as_path())?;
|
||||||
|
|
||||||
Some(bundle(&websites_path, website.to_folder_name(), true).await?)
|
Some(bundle(&websites_path, website.to_folder_name(), true).await?)
|
||||||
} else {
|
} else {
|
||||||
@@ -135,6 +135,8 @@ pub fn run() -> color_eyre::Result<()> {
|
|||||||
let starting_indexes =
|
let starting_indexes =
|
||||||
indexer.index(&parser, rpc, &exit, config.check_collisions()).unwrap();
|
indexer.index(&parser, rpc, &exit, config.check_collisions()).unwrap();
|
||||||
|
|
||||||
|
// dbg!(&starting_indexes);
|
||||||
|
|
||||||
computer.compute(&indexer, starting_indexes, &exit).unwrap();
|
computer.compute(&indexer, starting_indexes, &exit).unwrap();
|
||||||
|
|
||||||
info!("Waiting for new blocks...");
|
info!("Waiting for new blocks...");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use clap_derive::ValueEnum;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, ValueEnum)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, ValueEnum)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum Website {
|
pub enum Website {
|
||||||
None,
|
None,
|
||||||
Bitview,
|
Bitview,
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ rust-version.workspace = true
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
allocative = { workspace = true }
|
||||||
|
allocative_derive = { workspace = true }
|
||||||
bitcoin = { workspace = true }
|
bitcoin = { workspace = true }
|
||||||
bitcoincore-rpc = { workspace = true }
|
bitcoincore-rpc = { workspace = true }
|
||||||
brk_structs = { workspace = true }
|
brk_structs = { workspace = true }
|
||||||
@@ -17,14 +19,18 @@ brk_error = { workspace = true }
|
|||||||
brk_fetcher = { workspace = true }
|
brk_fetcher = { workspace = true }
|
||||||
brk_indexer = { workspace = true }
|
brk_indexer = { workspace = true }
|
||||||
brk_logger = { workspace = true }
|
brk_logger = { workspace = true }
|
||||||
|
brk_store = { workspace = true }
|
||||||
brk_parser = { workspace = true }
|
brk_parser = { workspace = true }
|
||||||
vecdb = { workspace = true }
|
vecdb = { workspace = true }
|
||||||
derive_deref = { workspace = true }
|
derive_deref = { workspace = true }
|
||||||
|
inferno = "0.12.3"
|
||||||
|
jiff = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
num_enum = "0.7.4"
|
num_enum = "0.7.4"
|
||||||
pco = "0.4.6"
|
pco = "0.4.6"
|
||||||
rayon = { workspace = true }
|
rayon = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true }
|
||||||
zerocopy = { workspace = true }
|
zerocopy = { workspace = true }
|
||||||
zerocopy-derive = { workspace = true }
|
zerocopy-derive = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ use brk_computer::{Computer, pools};
|
|||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_fetcher::Fetcher;
|
use brk_fetcher::Fetcher;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use vecdb::Exit;
|
use brk_structs::{AddressBytes, OutputIndex, OutputType};
|
||||||
|
use vecdb::{AnyIterableVec, Exit, VecIterator};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
brk_logger::init(Some(Path::new(".log")))?;
|
brk_logger::init(Some(Path::new(".log")))?;
|
||||||
@@ -27,20 +28,89 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let mut res: BTreeMap<&'static str, usize> = BTreeMap::default();
|
let mut res: BTreeMap<&'static str, usize> = BTreeMap::default();
|
||||||
|
|
||||||
let mut height_to_first_txindex_iter = indexer.vecs.height_to_first_txindex.iter();
|
let vecs = indexer.vecs;
|
||||||
// let mut i = indexer.vecs.txz
|
let stores = indexer.stores;
|
||||||
|
|
||||||
indexer
|
let mut height_to_first_txindex_iter = vecs.height_to_first_txindex.iter();
|
||||||
.stores
|
let mut txindex_to_first_outputindex_iter = vecs.txindex_to_first_outputindex.iter();
|
||||||
|
let mut txindex_to_output_count_iter = computer.indexes.txindex_to_output_count.iter();
|
||||||
|
let mut outputindex_to_outputtype_iter = vecs.outputindex_to_outputtype.iter();
|
||||||
|
let mut outputindex_to_typeindex_iter = vecs.outputindex_to_typeindex.iter();
|
||||||
|
let mut p2pk65addressindex_to_p2pk65bytes_iter =
|
||||||
|
vecs.p2pk65addressindex_to_p2pk65bytes.iter();
|
||||||
|
let mut p2pk33addressindex_to_p2pk33bytes_iter =
|
||||||
|
vecs.p2pk33addressindex_to_p2pk33bytes.iter();
|
||||||
|
let mut p2pkhaddressindex_to_p2pkhbytes_iter =
|
||||||
|
vecs.p2pkhaddressindex_to_p2pkhbytes.iter();
|
||||||
|
let mut p2shaddressindex_to_p2shbytes_iter = vecs.p2shaddressindex_to_p2shbytes.iter();
|
||||||
|
let mut p2wpkhaddressindex_to_p2wpkhbytes_iter =
|
||||||
|
vecs.p2wpkhaddressindex_to_p2wpkhbytes.iter();
|
||||||
|
let mut p2wshaddressindex_to_p2wshbytes_iter =
|
||||||
|
vecs.p2wshaddressindex_to_p2wshbytes.iter();
|
||||||
|
let mut p2traddressindex_to_p2trbytes_iter = vecs.p2traddressindex_to_p2trbytes.iter();
|
||||||
|
let mut p2aaddressindex_to_p2abytes_iter = vecs.p2aaddressindex_to_p2abytes.iter();
|
||||||
|
|
||||||
|
let unknown = pools.get_unknown();
|
||||||
|
|
||||||
|
stores
|
||||||
.height_to_coinbase_tag
|
.height_to_coinbase_tag
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|(_, coinbase_tag)| {
|
.for_each(|(height, coinbase_tag)| {
|
||||||
let pool = pools.find_from_coinbase_tag(&coinbase_tag);
|
let txindex = height_to_first_txindex_iter.unwrap_get_inner(height);
|
||||||
if let Some(pool) = pool {
|
let outputindex = txindex_to_first_outputindex_iter.unwrap_get_inner(txindex);
|
||||||
*res.entry(pool.name).or_default() += 1;
|
let outputcount = txindex_to_output_count_iter.unwrap_get_inner(txindex);
|
||||||
} else {
|
|
||||||
*res.entry(pools.get_unknown().name).or_default() += 1;
|
let pool = (*outputindex..(*outputindex + *outputcount))
|
||||||
}
|
.map(OutputIndex::from)
|
||||||
|
.find_map(|outputindex| {
|
||||||
|
let outputtype =
|
||||||
|
outputindex_to_outputtype_iter.unwrap_get_inner(outputindex);
|
||||||
|
let typeindex =
|
||||||
|
outputindex_to_typeindex_iter.unwrap_get_inner(outputindex);
|
||||||
|
|
||||||
|
let address = match outputtype {
|
||||||
|
OutputType::P2PK65 => Some(AddressBytes::from(
|
||||||
|
p2pk65addressindex_to_p2pk65bytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2PK33 => Some(AddressBytes::from(
|
||||||
|
p2pk33addressindex_to_p2pk33bytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2PKH => Some(AddressBytes::from(
|
||||||
|
p2pkhaddressindex_to_p2pkhbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2SH => Some(AddressBytes::from(
|
||||||
|
p2shaddressindex_to_p2shbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2WPKH => Some(AddressBytes::from(
|
||||||
|
p2wpkhaddressindex_to_p2wpkhbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2WSH => Some(AddressBytes::from(
|
||||||
|
p2wshaddressindex_to_p2wshbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2TR => Some(AddressBytes::from(
|
||||||
|
p2traddressindex_to_p2trbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2A => Some(AddressBytes::from(
|
||||||
|
p2aaddressindex_to_p2abytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
address
|
||||||
|
.and_then(|address| pools.find_from_address(&address.to_string()))
|
||||||
|
})
|
||||||
|
.or_else(|| pools.find_from_coinbase_tag(&coinbase_tag))
|
||||||
|
.unwrap_or(unknown);
|
||||||
|
|
||||||
|
*res.entry(pool.name).or_default() += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut v = res.into_iter().map(|(k, v)| (v, k)).collect::<Vec<_>>();
|
let mut v = res.into_iter().map(|(k, v)| (v, k)).collect::<Vec<_>>();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_structs::{
|
use brk_structs::{
|
||||||
@@ -30,7 +31,7 @@ const TARGET_BLOCKS_PER_SEMESTER: u64 = 2 * TARGET_BLOCKS_PER_QUARTER;
|
|||||||
const TARGET_BLOCKS_PER_YEAR: u64 = 2 * TARGET_BLOCKS_PER_SEMESTER;
|
const TARGET_BLOCKS_PER_YEAR: u64 = 2 * TARGET_BLOCKS_PER_SEMESTER;
|
||||||
const TARGET_BLOCKS_PER_DECADE: u64 = 10 * TARGET_BLOCKS_PER_YEAR;
|
const TARGET_BLOCKS_PER_DECADE: u64 = 10 * TARGET_BLOCKS_PER_YEAR;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct Vecs {
|
pub struct Vecs {
|
||||||
db: Database,
|
db: Database,
|
||||||
|
|
||||||
@@ -51,6 +52,9 @@ pub struct Vecs {
|
|||||||
pub halvingepoch_to_timestamp: EagerVec<HalvingEpoch, Timestamp>,
|
pub halvingepoch_to_timestamp: EagerVec<HalvingEpoch, Timestamp>,
|
||||||
pub timeindexes_to_timestamp: ComputedVecsFromDateIndex<Timestamp>,
|
pub timeindexes_to_timestamp: ComputedVecsFromDateIndex<Timestamp>,
|
||||||
pub indexes_to_block_count: ComputedVecsFromHeight<StoredU32>,
|
pub indexes_to_block_count: ComputedVecsFromHeight<StoredU32>,
|
||||||
|
pub indexes_to_1w_block_count: ComputedVecsFromDateIndex<StoredU32>,
|
||||||
|
pub indexes_to_1m_block_count: ComputedVecsFromDateIndex<StoredU32>,
|
||||||
|
pub indexes_to_1y_block_count: ComputedVecsFromDateIndex<StoredU32>,
|
||||||
pub indexes_to_block_interval: ComputedVecsFromHeight<Timestamp>,
|
pub indexes_to_block_interval: ComputedVecsFromHeight<Timestamp>,
|
||||||
pub indexes_to_block_size: ComputedVecsFromHeight<StoredU64>,
|
pub indexes_to_block_size: ComputedVecsFromHeight<StoredU64>,
|
||||||
pub indexes_to_block_vbytes: ComputedVecsFromHeight<StoredU64>,
|
pub indexes_to_block_vbytes: ComputedVecsFromHeight<StoredU64>,
|
||||||
@@ -389,6 +393,30 @@ impl Vecs {
|
|||||||
indexes,
|
indexes,
|
||||||
VecBuilderOptions::default().add_sum().add_cumulative(),
|
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||||
)?,
|
)?,
|
||||||
|
indexes_to_1w_block_count: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
&db,
|
||||||
|
"1w_block_count",
|
||||||
|
Source::Compute,
|
||||||
|
version + VERSION + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1m_block_count: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
&db,
|
||||||
|
"1m_block_count",
|
||||||
|
Source::Compute,
|
||||||
|
version + VERSION + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1y_block_count: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
&db,
|
||||||
|
"1y_block_count",
|
||||||
|
Source::Compute,
|
||||||
|
version + VERSION + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
indexes_to_block_weight: ComputedVecsFromHeight::forced_import(
|
indexes_to_block_weight: ComputedVecsFromHeight::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"block_weight",
|
"block_weight",
|
||||||
@@ -937,6 +965,54 @@ impl Vecs {
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1w_block_count.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
v.compute_sum(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_block_count.dateindex.unwrap_sum(),
|
||||||
|
7,
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1m_block_count.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
v.compute_sum(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_block_count.dateindex.unwrap_sum(),
|
||||||
|
30,
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1y_block_count.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
v.compute_sum(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_block_count.dateindex.unwrap_sum(),
|
||||||
|
365,
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
let mut height_to_timestamp_iter = indexer.vecs.height_to_timestamp.iter();
|
let mut height_to_timestamp_iter = indexer.vecs.height_to_timestamp.iter();
|
||||||
self.height_to_interval.compute_transform(
|
self.height_to_interval.compute_transform(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
@@ -1769,6 +1845,9 @@ impl Vecs {
|
|||||||
self.indexes_to_hash_rate_1y_sma.vecs(),
|
self.indexes_to_hash_rate_1y_sma.vecs(),
|
||||||
self.timeindexes_to_timestamp.vecs(),
|
self.timeindexes_to_timestamp.vecs(),
|
||||||
self.indexes_to_block_count.vecs(),
|
self.indexes_to_block_count.vecs(),
|
||||||
|
self.indexes_to_1w_block_count.vecs(),
|
||||||
|
self.indexes_to_1m_block_count.vecs(),
|
||||||
|
self.indexes_to_1y_block_count.vecs(),
|
||||||
self.indexes_to_block_interval.vecs(),
|
self.indexes_to_block_interval.vecs(),
|
||||||
self.indexes_to_block_size.vecs(),
|
self.indexes_to_block_size.vecs(),
|
||||||
self.indexes_to_block_vbytes.vecs(),
|
self.indexes_to_block_vbytes.vecs(),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_structs::{StoredI16, StoredU16, Version};
|
use brk_structs::{StoredF32, StoredI16, StoredU16, Version};
|
||||||
use vecdb::{AnyCollectableVec, AnyVec, Database, Exit};
|
use vecdb::{AnyCollectableVec, AnyVec, Database, Exit};
|
||||||
|
|
||||||
use crate::grouped::Source;
|
use crate::grouped::Source;
|
||||||
@@ -24,7 +24,9 @@ pub struct Vecs {
|
|||||||
pub constant_2: ComputedVecsFromHeight<StoredU16>,
|
pub constant_2: ComputedVecsFromHeight<StoredU16>,
|
||||||
pub constant_3: ComputedVecsFromHeight<StoredU16>,
|
pub constant_3: ComputedVecsFromHeight<StoredU16>,
|
||||||
pub constant_4: ComputedVecsFromHeight<StoredU16>,
|
pub constant_4: ComputedVecsFromHeight<StoredU16>,
|
||||||
|
pub constant_38_2: ComputedVecsFromHeight<StoredF32>,
|
||||||
pub constant_50: ComputedVecsFromHeight<StoredU16>,
|
pub constant_50: ComputedVecsFromHeight<StoredU16>,
|
||||||
|
pub constant_61_8: ComputedVecsFromHeight<StoredF32>,
|
||||||
pub constant_100: ComputedVecsFromHeight<StoredU16>,
|
pub constant_100: ComputedVecsFromHeight<StoredU16>,
|
||||||
pub constant_600: ComputedVecsFromHeight<StoredU16>,
|
pub constant_600: ComputedVecsFromHeight<StoredU16>,
|
||||||
pub constant_minus_1: ComputedVecsFromHeight<StoredI16>,
|
pub constant_minus_1: ComputedVecsFromHeight<StoredI16>,
|
||||||
@@ -78,6 +80,14 @@ impl Vecs {
|
|||||||
indexes,
|
indexes,
|
||||||
VecBuilderOptions::default().add_last(),
|
VecBuilderOptions::default().add_last(),
|
||||||
)?,
|
)?,
|
||||||
|
constant_38_2: ComputedVecsFromHeight::forced_import(
|
||||||
|
&db,
|
||||||
|
"constant_38_2",
|
||||||
|
Source::Compute,
|
||||||
|
version + VERSION + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
constant_50: ComputedVecsFromHeight::forced_import(
|
constant_50: ComputedVecsFromHeight::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"constant_50",
|
"constant_50",
|
||||||
@@ -86,6 +96,14 @@ impl Vecs {
|
|||||||
indexes,
|
indexes,
|
||||||
VecBuilderOptions::default().add_last(),
|
VecBuilderOptions::default().add_last(),
|
||||||
)?,
|
)?,
|
||||||
|
constant_61_8: ComputedVecsFromHeight::forced_import(
|
||||||
|
&db,
|
||||||
|
"constant_61_8",
|
||||||
|
Source::Compute,
|
||||||
|
version + VERSION + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
constant_100: ComputedVecsFromHeight::forced_import(
|
constant_100: ComputedVecsFromHeight::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"constant_100",
|
"constant_100",
|
||||||
@@ -223,6 +241,30 @@ impl Vecs {
|
|||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
[
|
||||||
|
(&mut self.constant_38_2, 38.2),
|
||||||
|
(&mut self.constant_61_8, 61.8),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.try_for_each(|(vec, value)| {
|
||||||
|
vec.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, indexes, starting_indexes, exit| {
|
||||||
|
vec.compute_to(
|
||||||
|
starting_indexes.height,
|
||||||
|
indexes.height_to_date.len(),
|
||||||
|
indexes.height_to_date.version(),
|
||||||
|
|i| (i, StoredF32::from(value)),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +275,9 @@ impl Vecs {
|
|||||||
self.constant_2.vecs(),
|
self.constant_2.vecs(),
|
||||||
self.constant_3.vecs(),
|
self.constant_3.vecs(),
|
||||||
self.constant_4.vecs(),
|
self.constant_4.vecs(),
|
||||||
|
self.constant_38_2.vecs(),
|
||||||
self.constant_50.vecs(),
|
self.constant_50.vecs(),
|
||||||
|
self.constant_61_8.vecs(),
|
||||||
self.constant_100.vecs(),
|
self.constant_100.vecs(),
|
||||||
self.constant_600.vecs(),
|
self.constant_600.vecs(),
|
||||||
self.constant_minus_1.vecs(),
|
self.constant_minus_1.vecs(),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_error::{Error, Result};
|
use brk_error::{Error, Result};
|
||||||
use brk_structs::{CheckedSub, StoredU64, Version};
|
use brk_structs::{CheckedSub, StoredU64, Version};
|
||||||
use vecdb::{
|
use vecdb::{
|
||||||
@@ -9,7 +10,7 @@ use crate::utils::get_percentile;
|
|||||||
|
|
||||||
use super::ComputedType;
|
use super::ComputedType;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, Allocative)]
|
||||||
pub struct EagerVecBuilder<I, T>
|
pub struct EagerVecBuilder<I, T>
|
||||||
where
|
where
|
||||||
I: StoredIndex,
|
I: StoredIndex,
|
||||||
@@ -19,11 +20,11 @@ where
|
|||||||
pub average: Option<Box<EagerVec<I, T>>>,
|
pub average: Option<Box<EagerVec<I, T>>>,
|
||||||
pub sum: Option<Box<EagerVec<I, T>>>,
|
pub sum: Option<Box<EagerVec<I, T>>>,
|
||||||
pub max: Option<Box<EagerVec<I, T>>>,
|
pub max: Option<Box<EagerVec<I, T>>>,
|
||||||
pub p90: Option<Box<EagerVec<I, T>>>,
|
pub pct90: Option<Box<EagerVec<I, T>>>,
|
||||||
pub p75: Option<Box<EagerVec<I, T>>>,
|
pub pct75: Option<Box<EagerVec<I, T>>>,
|
||||||
pub median: Option<Box<EagerVec<I, T>>>,
|
pub median: Option<Box<EagerVec<I, T>>>,
|
||||||
pub p25: Option<Box<EagerVec<I, T>>>,
|
pub pct25: Option<Box<EagerVec<I, T>>>,
|
||||||
pub p10: Option<Box<EagerVec<I, T>>>,
|
pub pct10: Option<Box<EagerVec<I, T>>>,
|
||||||
pub min: Option<Box<EagerVec<I, T>>>,
|
pub min: Option<Box<EagerVec<I, T>>>,
|
||||||
pub last: Option<Box<EagerVec<I, T>>>,
|
pub last: Option<Box<EagerVec<I, T>>>,
|
||||||
pub cumulative: Option<Box<EagerVec<I, T>>>,
|
pub cumulative: Option<Box<EagerVec<I, T>>>,
|
||||||
@@ -151,44 +152,44 @@ where
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
p90: options.p90.then(|| {
|
pct90: options.pct90.then(|| {
|
||||||
Box::new(
|
Box::new(
|
||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&maybe_suffix("p90"),
|
&maybe_suffix("pct90"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
p75: options.p75.then(|| {
|
pct75: options.pct75.then(|| {
|
||||||
Box::new(
|
Box::new(
|
||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&maybe_suffix("p75"),
|
&maybe_suffix("pct75"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
p25: options.p25.then(|| {
|
pct25: options.pct25.then(|| {
|
||||||
Box::new(
|
Box::new(
|
||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&maybe_suffix("p25"),
|
&maybe_suffix("pct25"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
p10: options.p10.then(|| {
|
pct10: options.pct10.then(|| {
|
||||||
Box::new(
|
Box::new(
|
||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&maybe_suffix("p10"),
|
&maybe_suffix("pct10"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
@@ -292,11 +293,11 @@ where
|
|||||||
let needs_average_sum_or_cumulative =
|
let needs_average_sum_or_cumulative =
|
||||||
needs_sum_or_cumulative || self.average.is_some();
|
needs_sum_or_cumulative || self.average.is_some();
|
||||||
let needs_sorted = self.max.is_some()
|
let needs_sorted = self.max.is_some()
|
||||||
|| self.p90.is_some()
|
|| self.pct90.is_some()
|
||||||
|| self.p75.is_some()
|
|| self.pct75.is_some()
|
||||||
|| self.median.is_some()
|
|| self.median.is_some()
|
||||||
|| self.p25.is_some()
|
|| self.pct25.is_some()
|
||||||
|| self.p10.is_some()
|
|| self.pct10.is_some()
|
||||||
|| self.min.is_some();
|
|| self.min.is_some();
|
||||||
let needs_values = needs_sorted || needs_average_sum_or_cumulative;
|
let needs_values = needs_sorted || needs_average_sum_or_cumulative;
|
||||||
|
|
||||||
@@ -333,24 +334,24 @@ where
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(p90) = self.p90.as_mut() {
|
if let Some(pct90) = self.pct90.as_mut() {
|
||||||
p90.forced_push_at(index, get_percentile(&values, 0.90), exit)?;
|
pct90.forced_push_at(index, get_percentile(&values, 0.90), exit)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(p75) = self.p75.as_mut() {
|
if let Some(pct75) = self.pct75.as_mut() {
|
||||||
p75.forced_push_at(index, get_percentile(&values, 0.75), exit)?;
|
pct75.forced_push_at(index, get_percentile(&values, 0.75), exit)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(median) = self.median.as_mut() {
|
if let Some(median) = self.median.as_mut() {
|
||||||
median.forced_push_at(index, get_percentile(&values, 0.50), exit)?;
|
median.forced_push_at(index, get_percentile(&values, 0.50), exit)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(p25) = self.p25.as_mut() {
|
if let Some(pct25) = self.pct25.as_mut() {
|
||||||
p25.forced_push_at(index, get_percentile(&values, 0.25), exit)?;
|
pct25.forced_push_at(index, get_percentile(&values, 0.25), exit)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(p10) = self.p10.as_mut() {
|
if let Some(pct10) = self.pct10.as_mut() {
|
||||||
p10.forced_push_at(index, get_percentile(&values, 0.10), exit)?;
|
pct10.forced_push_at(index, get_percentile(&values, 0.10), exit)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(min) = self.min.as_mut() {
|
if let Some(min) = self.min.as_mut() {
|
||||||
@@ -401,11 +402,11 @@ where
|
|||||||
where
|
where
|
||||||
I2: StoredIndex + StoredRaw + CheckedSub<I2>,
|
I2: StoredIndex + StoredRaw + CheckedSub<I2>,
|
||||||
{
|
{
|
||||||
if self.p90.is_some()
|
if self.pct90.is_some()
|
||||||
|| self.p75.is_some()
|
|| self.pct75.is_some()
|
||||||
|| self.median.is_some()
|
|| self.median.is_some()
|
||||||
|| self.p25.is_some()
|
|| self.pct25.is_some()
|
||||||
|| self.p10.is_some()
|
|| self.pct10.is_some()
|
||||||
{
|
{
|
||||||
panic!("unsupported");
|
panic!("unsupported");
|
||||||
}
|
}
|
||||||
@@ -558,24 +559,24 @@ where
|
|||||||
self.max.as_ref().unwrap()
|
self.max.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn unwrap_p90(&self) -> &EagerVec<I, T> {
|
pub fn unwrap_pct90(&self) -> &EagerVec<I, T> {
|
||||||
self.p90.as_ref().unwrap()
|
self.pct90.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn unwrap_p75(&self) -> &EagerVec<I, T> {
|
pub fn unwrap_pct75(&self) -> &EagerVec<I, T> {
|
||||||
self.p75.as_ref().unwrap()
|
self.pct75.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn unwrap_median(&self) -> &EagerVec<I, T> {
|
pub fn unwrap_median(&self) -> &EagerVec<I, T> {
|
||||||
self.median.as_ref().unwrap()
|
self.median.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn unwrap_p25(&self) -> &EagerVec<I, T> {
|
pub fn unwrap_pct25(&self) -> &EagerVec<I, T> {
|
||||||
self.p25.as_ref().unwrap()
|
self.pct25.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn unwrap_p10(&self) -> &EagerVec<I, T> {
|
pub fn unwrap_pct10(&self) -> &EagerVec<I, T> {
|
||||||
self.p10.as_ref().unwrap()
|
self.pct10.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
pub fn unwrap_min(&self) -> &EagerVec<I, T> {
|
pub fn unwrap_min(&self) -> &EagerVec<I, T> {
|
||||||
self.min.as_ref().unwrap()
|
self.min.as_ref().unwrap()
|
||||||
@@ -615,17 +616,17 @@ where
|
|||||||
if let Some(cumulative) = self.cumulative.as_ref() {
|
if let Some(cumulative) = self.cumulative.as_ref() {
|
||||||
v.push(cumulative.as_ref());
|
v.push(cumulative.as_ref());
|
||||||
}
|
}
|
||||||
if let Some(p90) = self.p90.as_ref() {
|
if let Some(pct90) = self.pct90.as_ref() {
|
||||||
v.push(p90.as_ref());
|
v.push(pct90.as_ref());
|
||||||
}
|
}
|
||||||
if let Some(p75) = self.p75.as_ref() {
|
if let Some(pct75) = self.pct75.as_ref() {
|
||||||
v.push(p75.as_ref());
|
v.push(pct75.as_ref());
|
||||||
}
|
}
|
||||||
if let Some(p25) = self.p25.as_ref() {
|
if let Some(pct25) = self.pct25.as_ref() {
|
||||||
v.push(p25.as_ref());
|
v.push(pct25.as_ref());
|
||||||
}
|
}
|
||||||
if let Some(p10) = self.p10.as_ref() {
|
if let Some(pct10) = self.pct10.as_ref() {
|
||||||
v.push(p10.as_ref());
|
v.push(pct10.as_ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
v
|
v
|
||||||
@@ -656,17 +657,17 @@ where
|
|||||||
if let Some(cumulative) = self.cumulative.as_mut() {
|
if let Some(cumulative) = self.cumulative.as_mut() {
|
||||||
cumulative.safe_flush(exit)?;
|
cumulative.safe_flush(exit)?;
|
||||||
}
|
}
|
||||||
if let Some(p90) = self.p90.as_mut() {
|
if let Some(pct90) = self.pct90.as_mut() {
|
||||||
p90.safe_flush(exit)?;
|
pct90.safe_flush(exit)?;
|
||||||
}
|
}
|
||||||
if let Some(p75) = self.p75.as_mut() {
|
if let Some(pct75) = self.pct75.as_mut() {
|
||||||
p75.safe_flush(exit)?;
|
pct75.safe_flush(exit)?;
|
||||||
}
|
}
|
||||||
if let Some(p25) = self.p25.as_mut() {
|
if let Some(pct25) = self.pct25.as_mut() {
|
||||||
p25.safe_flush(exit)?;
|
pct25.safe_flush(exit)?;
|
||||||
}
|
}
|
||||||
if let Some(p10) = self.p10.as_mut() {
|
if let Some(pct10) = self.pct10.as_mut() {
|
||||||
p10.safe_flush(exit)?;
|
pct10.safe_flush(exit)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -697,17 +698,17 @@ where
|
|||||||
if let Some(cumulative) = self.cumulative.as_mut() {
|
if let Some(cumulative) = self.cumulative.as_mut() {
|
||||||
cumulative.validate_computed_version_or_reset(Version::ZERO + version)?;
|
cumulative.validate_computed_version_or_reset(Version::ZERO + version)?;
|
||||||
}
|
}
|
||||||
if let Some(p90) = self.p90.as_mut() {
|
if let Some(pct90) = self.pct90.as_mut() {
|
||||||
p90.validate_computed_version_or_reset(Version::ZERO + version)?;
|
pct90.validate_computed_version_or_reset(Version::ZERO + version)?;
|
||||||
}
|
}
|
||||||
if let Some(p75) = self.p75.as_mut() {
|
if let Some(pct75) = self.pct75.as_mut() {
|
||||||
p75.validate_computed_version_or_reset(Version::ZERO + version)?;
|
pct75.validate_computed_version_or_reset(Version::ZERO + version)?;
|
||||||
}
|
}
|
||||||
if let Some(p25) = self.p25.as_mut() {
|
if let Some(pct25) = self.pct25.as_mut() {
|
||||||
p25.validate_computed_version_or_reset(Version::ZERO + version)?;
|
pct25.validate_computed_version_or_reset(Version::ZERO + version)?;
|
||||||
}
|
}
|
||||||
if let Some(p10) = self.p10.as_mut() {
|
if let Some(pct10) = self.pct10.as_mut() {
|
||||||
p10.validate_computed_version_or_reset(Version::ZERO + version)?;
|
pct10.validate_computed_version_or_reset(Version::ZERO + version)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -719,11 +720,11 @@ pub struct VecBuilderOptions {
|
|||||||
average: bool,
|
average: bool,
|
||||||
sum: bool,
|
sum: bool,
|
||||||
max: bool,
|
max: bool,
|
||||||
p90: bool,
|
pct90: bool,
|
||||||
p75: bool,
|
pct75: bool,
|
||||||
median: bool,
|
median: bool,
|
||||||
p25: bool,
|
pct25: bool,
|
||||||
p10: bool,
|
pct10: bool,
|
||||||
min: bool,
|
min: bool,
|
||||||
first: bool,
|
first: bool,
|
||||||
last: bool,
|
last: bool,
|
||||||
@@ -743,24 +744,24 @@ impl VecBuilderOptions {
|
|||||||
self.max
|
self.max
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn p90(&self) -> bool {
|
pub fn pct90(&self) -> bool {
|
||||||
self.p90
|
self.pct90
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn p75(&self) -> bool {
|
pub fn pct75(&self) -> bool {
|
||||||
self.p75
|
self.pct75
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn median(&self) -> bool {
|
pub fn median(&self) -> bool {
|
||||||
self.median
|
self.median
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn p25(&self) -> bool {
|
pub fn pct25(&self) -> bool {
|
||||||
self.p25
|
self.pct25
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn p10(&self) -> bool {
|
pub fn pct10(&self) -> bool {
|
||||||
self.p10
|
self.pct10
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn min(&self) -> bool {
|
pub fn min(&self) -> bool {
|
||||||
@@ -816,26 +817,26 @@ impl VecBuilderOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn add_p90(mut self) -> Self {
|
pub fn add_pct90(mut self) -> Self {
|
||||||
self.p90 = true;
|
self.pct90 = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn add_p75(mut self) -> Self {
|
pub fn add_pct75(mut self) -> Self {
|
||||||
self.p75 = true;
|
self.pct75 = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn add_p25(mut self) -> Self {
|
pub fn add_pct25(mut self) -> Self {
|
||||||
self.p25 = true;
|
self.pct25 = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn add_p10(mut self) -> Self {
|
pub fn add_pct10(mut self) -> Self {
|
||||||
self.p10 = true;
|
self.pct10 = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -875,26 +876,26 @@ impl VecBuilderOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn rm_p90(mut self) -> Self {
|
pub fn rm_pct90(mut self) -> Self {
|
||||||
self.p90 = false;
|
self.pct90 = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn rm_p75(mut self) -> Self {
|
pub fn rm_pct75(mut self) -> Self {
|
||||||
self.p75 = false;
|
self.pct75 = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn rm_p25(mut self) -> Self {
|
pub fn rm_pct25(mut self) -> Self {
|
||||||
self.p25 = false;
|
self.pct25 = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn rm_p10(mut self) -> Self {
|
pub fn rm_pct10(mut self) -> Self {
|
||||||
self.p10 = false;
|
self.pct10 = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,20 +912,20 @@ impl VecBuilderOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_percentiles(mut self) -> Self {
|
pub fn add_percentiles(mut self) -> Self {
|
||||||
self.p90 = true;
|
self.pct90 = true;
|
||||||
self.p75 = true;
|
self.pct75 = true;
|
||||||
self.median = true;
|
self.median = true;
|
||||||
self.p25 = true;
|
self.pct25 = true;
|
||||||
self.p10 = true;
|
self.pct10 = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_percentiles(mut self) -> Self {
|
pub fn remove_percentiles(mut self) -> Self {
|
||||||
self.p90 = false;
|
self.pct90 = false;
|
||||||
self.p75 = false;
|
self.pct75 = false;
|
||||||
self.median = false;
|
self.median = false;
|
||||||
self.p25 = false;
|
self.pct25 = false;
|
||||||
self.p10 = false;
|
self.pct10 = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,11 +934,11 @@ impl VecBuilderOptions {
|
|||||||
self.average,
|
self.average,
|
||||||
self.sum,
|
self.sum,
|
||||||
self.max,
|
self.max,
|
||||||
self.p90,
|
self.pct90,
|
||||||
self.p75,
|
self.pct75,
|
||||||
self.median,
|
self.median,
|
||||||
self.p25,
|
self.pct25,
|
||||||
self.p10,
|
self.pct10,
|
||||||
self.min,
|
self.min,
|
||||||
self.first,
|
self.first,
|
||||||
self.last,
|
self.last,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_structs::Version;
|
use brk_structs::Version;
|
||||||
use vecdb::{
|
use vecdb::{
|
||||||
AnyBoxedIterableVec, AnyCloneableIterableVec, AnyCollectableVec, FromCoarserIndex,
|
AnyBoxedIterableVec, AnyCloneableIterableVec, AnyCollectableVec, FromCoarserIndex,
|
||||||
@@ -9,7 +10,7 @@ use crate::grouped::{EagerVecBuilder, VecBuilderOptions};
|
|||||||
use super::ComputedType;
|
use super::ComputedType;
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct LazyVecBuilder<I, T, S1I, S2T>
|
pub struct LazyVecBuilder<I, T, S1I, S2T>
|
||||||
where
|
where
|
||||||
I: StoredIndex,
|
I: StoredIndex,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
|
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -10,7 +11,7 @@ use crate::{Indexes, grouped::LazyVecBuilder, indexes};
|
|||||||
|
|
||||||
use super::{ComputedType, EagerVecBuilder, Source, VecBuilderOptions};
|
use super::{ComputedType, EagerVecBuilder, Source, VecBuilderOptions};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct ComputedVecsFromDateIndex<T>
|
pub struct ComputedVecsFromDateIndex<T>
|
||||||
where
|
where
|
||||||
T: ComputedType + PartialOrd,
|
T: ComputedType + PartialOrd,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
|
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -15,7 +16,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{ComputedType, EagerVecBuilder, VecBuilderOptions};
|
use super::{ComputedType, EagerVecBuilder, VecBuilderOptions};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct ComputedVecsFromHeight<T>
|
pub struct ComputedVecsFromHeight<T>
|
||||||
where
|
where
|
||||||
T: ComputedType + PartialOrd,
|
T: ComputedType + PartialOrd,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_structs::{
|
use brk_structs::{
|
||||||
@@ -17,7 +18,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{ComputedType, EagerVecBuilder, VecBuilderOptions};
|
use super::{ComputedType, EagerVecBuilder, VecBuilderOptions};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct ComputedVecsFromTxindex<T>
|
pub struct ComputedVecsFromTxindex<T>
|
||||||
where
|
where
|
||||||
T: ComputedType + PartialOrd,
|
T: ComputedType + PartialOrd,
|
||||||
@@ -319,24 +320,24 @@ impl ComputedVecsFromTxindex<Bitcoin> {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_90p) = self.height.p90.as_mut() {
|
if let Some(pct90) = self.height.pct90.as_mut() {
|
||||||
_90p.forced_push_at(
|
pct90.forced_push_at(
|
||||||
height,
|
height,
|
||||||
Bitcoin::from(
|
Bitcoin::from(
|
||||||
sats.height
|
sats.height
|
||||||
.unwrap_p90()
|
.unwrap_pct90()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
),
|
),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_75p) = self.height.p75.as_mut() {
|
if let Some(pct75) = self.height.pct75.as_mut() {
|
||||||
_75p.forced_push_at(
|
pct75.forced_push_at(
|
||||||
height,
|
height,
|
||||||
Bitcoin::from(
|
Bitcoin::from(
|
||||||
sats.height
|
sats.height
|
||||||
.unwrap_p75()
|
.unwrap_pct75()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
),
|
),
|
||||||
@@ -355,24 +356,24 @@ impl ComputedVecsFromTxindex<Bitcoin> {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_25p) = self.height.p25.as_mut() {
|
if let Some(pct25) = self.height.pct25.as_mut() {
|
||||||
_25p.forced_push_at(
|
pct25.forced_push_at(
|
||||||
height,
|
height,
|
||||||
Bitcoin::from(
|
Bitcoin::from(
|
||||||
sats.height
|
sats.height
|
||||||
.unwrap_p25()
|
.unwrap_pct25()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
),
|
),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_10p) = self.height.p10.as_mut() {
|
if let Some(pct10) = self.height.pct10.as_mut() {
|
||||||
_10p.forced_push_at(
|
pct10.forced_push_at(
|
||||||
height,
|
height,
|
||||||
Bitcoin::from(
|
Bitcoin::from(
|
||||||
sats.height
|
sats.height
|
||||||
.unwrap_p10()
|
.unwrap_pct10()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
),
|
),
|
||||||
@@ -502,25 +503,25 @@ impl ComputedVecsFromTxindex<Dollars> {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_90p) = self.height.p90.as_mut() {
|
if let Some(pct90) = self.height.pct90.as_mut() {
|
||||||
_90p.forced_push_at(
|
pct90.forced_push_at(
|
||||||
height,
|
height,
|
||||||
price
|
price
|
||||||
* bitcoin
|
* bitcoin
|
||||||
.height
|
.height
|
||||||
.unwrap_p90()
|
.unwrap_pct90()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_75p) = self.height.p75.as_mut() {
|
if let Some(pct75) = self.height.pct75.as_mut() {
|
||||||
_75p.forced_push_at(
|
pct75.forced_push_at(
|
||||||
height,
|
height,
|
||||||
price
|
price
|
||||||
* bitcoin
|
* bitcoin
|
||||||
.height
|
.height
|
||||||
.unwrap_p75()
|
.unwrap_pct75()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
exit,
|
exit,
|
||||||
@@ -538,25 +539,25 @@ impl ComputedVecsFromTxindex<Dollars> {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_25p) = self.height.p25.as_mut() {
|
if let Some(pct25) = self.height.pct25.as_mut() {
|
||||||
_25p.forced_push_at(
|
pct25.forced_push_at(
|
||||||
height,
|
height,
|
||||||
price
|
price
|
||||||
* bitcoin
|
* bitcoin
|
||||||
.height
|
.height
|
||||||
.unwrap_p25()
|
.unwrap_pct25()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(_10p) = self.height.p10.as_mut() {
|
if let Some(pct10) = self.height.pct10.as_mut() {
|
||||||
_10p.forced_push_at(
|
pct10.forced_push_at(
|
||||||
height,
|
height,
|
||||||
price
|
price
|
||||||
* bitcoin
|
* bitcoin
|
||||||
.height
|
.height
|
||||||
.unwrap_p10()
|
.unwrap_pct10()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unwrap_get_inner(height),
|
.unwrap_get_inner(height),
|
||||||
exit,
|
exit,
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ use vecdb::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Indexes,
|
Indexes,
|
||||||
grouped::{ComputedStandardDeviationVecsFromDateIndex, source::Source},
|
grouped::{
|
||||||
|
ComputedStandardDeviationVecsFromDateIndex, StandardDeviationVecsOptions, source::Source,
|
||||||
|
},
|
||||||
indexes, price,
|
indexes, price,
|
||||||
utils::get_percentile,
|
utils::get_percentile,
|
||||||
};
|
};
|
||||||
@@ -105,6 +107,7 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
Source::Compute,
|
Source::Compute,
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
indexes,
|
indexes,
|
||||||
|
StandardDeviationVecsOptions::default().add_all(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}),
|
}),
|
||||||
@@ -116,6 +119,7 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
Source::Compute,
|
Source::Compute,
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
indexes,
|
indexes,
|
||||||
|
StandardDeviationVecsOptions::default().add_all(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}),
|
}),
|
||||||
@@ -127,6 +131,7 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
Source::Compute,
|
Source::Compute,
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
indexes,
|
indexes,
|
||||||
|
StandardDeviationVecsOptions::default().add_all(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}),
|
}),
|
||||||
@@ -138,6 +143,7 @@ impl ComputedRatioVecsFromDateIndex {
|
|||||||
Source::Compute,
|
Source::Compute,
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ZERO,
|
||||||
indexes,
|
indexes,
|
||||||
|
StandardDeviationVecsOptions::default().add_all(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}),
|
}),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_structs::{Bitcoin, Dollars, Height, Sats, Version};
|
use brk_structs::{Bitcoin, Dollars, Height, Sats, Version};
|
||||||
@@ -12,7 +13,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{ComputedVecsFromHeight, VecBuilderOptions};
|
use super::{ComputedVecsFromHeight, VecBuilderOptions};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct ComputedValueVecsFromHeight {
|
pub struct ComputedValueVecsFromHeight {
|
||||||
pub sats: ComputedVecsFromHeight<Sats>,
|
pub sats: ComputedVecsFromHeight<Sats>,
|
||||||
pub bitcoin: ComputedVecsFromHeight<Bitcoin>,
|
pub bitcoin: ComputedVecsFromHeight<Bitcoin>,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_structs::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
|
use brk_structs::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
|
||||||
@@ -10,7 +11,7 @@ use crate::{Indexes, grouped::Source, indexes, price};
|
|||||||
|
|
||||||
use super::{ComputedVecsFromTxindex, VecBuilderOptions};
|
use super::{ComputedVecsFromTxindex, VecBuilderOptions};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Allocative)]
|
||||||
pub struct ComputedValueVecsFromTxindex {
|
pub struct ComputedValueVecsFromTxindex {
|
||||||
pub sats: ComputedVecsFromTxindex<Sats>,
|
pub sats: ComputedVecsFromTxindex<Sats>,
|
||||||
pub bitcoin_txindex: LazyVecFrom1<TxIndex, Bitcoin, TxIndex, Sats>,
|
pub bitcoin_txindex: LazyVecFrom1<TxIndex, Bitcoin, TxIndex, Sats>,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
|
|
||||||
use std::{path::Path, thread};
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
use brk_fetcher::Fetcher;
|
use brk_fetcher::Fetcher;
|
||||||
@@ -34,6 +34,7 @@ pub struct Computer {
|
|||||||
pub indexes: indexes::Vecs,
|
pub indexes: indexes::Vecs,
|
||||||
pub constants: constants::Vecs,
|
pub constants: constants::Vecs,
|
||||||
pub market: market::Vecs,
|
pub market: market::Vecs,
|
||||||
|
pub pools: pools::Vecs,
|
||||||
pub price: Option<price::Vecs>,
|
pub price: Option<price::Vecs>,
|
||||||
pub chain: chain::Vecs,
|
pub chain: chain::Vecs,
|
||||||
pub stateful: stateful::Vecs,
|
pub stateful: stateful::Vecs,
|
||||||
@@ -41,7 +42,7 @@ pub struct Computer {
|
|||||||
pub cointime: cointime::Vecs,
|
pub cointime: cointime::Vecs,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: Version = Version::TWO;
|
const VERSION: Version = Version::new(4);
|
||||||
|
|
||||||
impl Computer {
|
impl Computer {
|
||||||
/// Do NOT import multiple times or things will break !!!
|
/// Do NOT import multiple times or things will break !!!
|
||||||
@@ -86,6 +87,12 @@ impl Computer {
|
|||||||
&indexes,
|
&indexes,
|
||||||
price.as_ref(),
|
price.as_ref(),
|
||||||
)?,
|
)?,
|
||||||
|
pools: pools::Vecs::forced_import(
|
||||||
|
&computed_path,
|
||||||
|
VERSION + Version::ZERO,
|
||||||
|
&indexes,
|
||||||
|
price.as_ref(),
|
||||||
|
)?,
|
||||||
cointime: cointime::Vecs::forced_import(
|
cointime: cointime::Vecs::forced_import(
|
||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION + Version::ZERO,
|
VERSION + Version::ZERO,
|
||||||
@@ -125,8 +132,8 @@ impl Computer {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread::scope(|scope| -> Result<()> {
|
std::thread::scope(|scope| -> Result<()> {
|
||||||
let chain = scope.spawn(|| {
|
let chain = scope.spawn(|| -> Result<()> {
|
||||||
info!("Computing chain...");
|
info!("Computing chain...");
|
||||||
self.chain.compute(
|
self.chain.compute(
|
||||||
indexer,
|
indexer,
|
||||||
@@ -134,23 +141,31 @@ impl Computer {
|
|||||||
&starting_indexes,
|
&starting_indexes,
|
||||||
self.price.as_ref(),
|
self.price.as_ref(),
|
||||||
exit,
|
exit,
|
||||||
)
|
)?;
|
||||||
});
|
|
||||||
|
|
||||||
let market = scope.spawn(|| -> Result<()> {
|
|
||||||
if let Some(price) = self.price.as_ref() {
|
|
||||||
info!("Computing market...");
|
|
||||||
self.market
|
|
||||||
.compute(indexer, &self.indexes, price, &starting_indexes, exit)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(price) = self.price.as_ref() {
|
||||||
|
info!("Computing market...");
|
||||||
|
self.market
|
||||||
|
.compute(indexer, &self.indexes, price, &starting_indexes, exit)?;
|
||||||
|
}
|
||||||
|
|
||||||
chain.join().unwrap()?;
|
chain.join().unwrap()?;
|
||||||
market.join().unwrap()?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
self.pools.compute(
|
||||||
|
indexer,
|
||||||
|
&self.indexes,
|
||||||
|
&starting_indexes,
|
||||||
|
&self.chain,
|
||||||
|
self.price.as_ref(),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// return Ok(());
|
||||||
|
|
||||||
info!("Computing stateful...");
|
info!("Computing stateful...");
|
||||||
self.stateful.compute(
|
self.stateful.compute(
|
||||||
indexer,
|
indexer,
|
||||||
@@ -183,6 +198,7 @@ impl Computer {
|
|||||||
self.chain.vecs(),
|
self.chain.vecs(),
|
||||||
self.stateful.vecs(),
|
self.stateful.vecs(),
|
||||||
self.cointime.vecs(),
|
self.cointime.vecs(),
|
||||||
|
self.pools.vecs(),
|
||||||
self.fetched.as_ref().map_or(vec![], |v| v.vecs()),
|
self.fetched.as_ref().map_or(vec![], |v| v.vecs()),
|
||||||
self.price.as_ref().map_or(vec![], |v| v.vecs()),
|
self.price.as_ref().map_or(vec![], |v| v.vecs()),
|
||||||
]
|
]
|
||||||
@@ -195,3 +211,36 @@ impl Computer {
|
|||||||
Box::leak(Box::new(self.clone()))
|
Box::leak(Box::new(self.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub fn generate_allocation_files(monitored: &pools::Vecs) -> Result<()> {
|
||||||
|
// info!("Generating Allocative files...");
|
||||||
|
|
||||||
|
// let mut flamegraph = allocative::FlameGraphBuilder::default();
|
||||||
|
// flamegraph.visit_root(monitored);
|
||||||
|
// let output = flamegraph.finish();
|
||||||
|
|
||||||
|
// let folder = format!(
|
||||||
|
// "at-{}",
|
||||||
|
// jiff::Timestamp::now().strftime("%Y-%m-%d_%Hh%Mm%Ss"),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// let path = std::path::PathBuf::from(&format!("./target/flamegraph/{folder}"));
|
||||||
|
// std::fs::create_dir_all(&path)?;
|
||||||
|
|
||||||
|
// // fs::write(path.join("flamegraph.src"), &output.flamegraph())?;
|
||||||
|
|
||||||
|
// let mut fg_svg = Vec::new();
|
||||||
|
// inferno::flamegraph::from_reader(
|
||||||
|
// &mut inferno::flamegraph::Options::default(),
|
||||||
|
// output.flamegraph().write().as_bytes(),
|
||||||
|
// &mut fg_svg,
|
||||||
|
// )?;
|
||||||
|
|
||||||
|
// std::fs::write(path.join("flamegraph.svg"), &fg_svg)?;
|
||||||
|
|
||||||
|
// std::fs::write(path.join("warnings.txt"), output.warnings())?;
|
||||||
|
|
||||||
|
// info!("Successfully generated Allocative files");
|
||||||
|
|
||||||
|
// Ok(())
|
||||||
|
// }
|
||||||
|
|||||||
+590
-155
File diff suppressed because it is too large
Load Diff
@@ -1,101 +1,123 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use num_enum::{FromPrimitive, IntoPrimitive};
|
use num_enum::{FromPrimitive, IntoPrimitive};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
// Created from the list in `pools.rs`
|
||||||
|
// Can be used as index for said list
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FromPrimitive, IntoPrimitive)]
|
#[derive(
|
||||||
#[repr(u16)]
|
Debug,
|
||||||
|
Copy,
|
||||||
|
Clone,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
FromPrimitive,
|
||||||
|
IntoPrimitive,
|
||||||
|
FromBytes,
|
||||||
|
IntoBytes,
|
||||||
|
Immutable,
|
||||||
|
KnownLayout,
|
||||||
|
Allocative,
|
||||||
|
)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
#[repr(u8)]
|
||||||
pub enum PoolId {
|
pub enum PoolId {
|
||||||
#[default]
|
#[default]
|
||||||
Unknown,
|
Unknown,
|
||||||
BlockFills,
|
BlockFills,
|
||||||
Ultimuspool,
|
UltimusPool,
|
||||||
TerraPool,
|
TerraPool,
|
||||||
Luxor,
|
Luxor,
|
||||||
OneTHash,
|
OneThash,
|
||||||
BTCCom,
|
BtcCom,
|
||||||
Bitfarms,
|
Bitfarms,
|
||||||
HuobiPool,
|
HuobiPool,
|
||||||
WayiCn,
|
WayiCn,
|
||||||
CanoePool,
|
CanoePool,
|
||||||
BTCTop,
|
BtcTop,
|
||||||
BitcoinCom,
|
BitcoinCom,
|
||||||
OneSevenFiveBtc,
|
Pool175btc,
|
||||||
GBMiners,
|
GbMiners,
|
||||||
AXbt,
|
AXbt,
|
||||||
ASICMiner,
|
AsicMiner,
|
||||||
BitMinter,
|
BitMinter,
|
||||||
BitcoinRussia,
|
BitcoinRussia,
|
||||||
BTCServ,
|
BtcServ,
|
||||||
SimplecoinUs,
|
SimplecoinUs,
|
||||||
BTCGuild,
|
BtcGuild,
|
||||||
Eligius,
|
Eligius,
|
||||||
OzCoin,
|
OzCoin,
|
||||||
EclipseMC,
|
EclipseMc,
|
||||||
MaxBTC,
|
MaxBtc,
|
||||||
TripleMining,
|
TripleMining,
|
||||||
CoinLab,
|
CoinLab,
|
||||||
FiftyBTC,
|
Pool50btc,
|
||||||
GHashIO,
|
GhashIo,
|
||||||
STMiningCorp,
|
StMiningCorp,
|
||||||
Bitparking,
|
Bitparking,
|
||||||
MMPool,
|
Mmpool,
|
||||||
Polmine,
|
Polmine,
|
||||||
KnCMiner,
|
KncMiner,
|
||||||
Bitalo,
|
Bitalo,
|
||||||
F2Pool,
|
F2Pool,
|
||||||
HHTT,
|
Hhtt,
|
||||||
MegaBigPower,
|
MegaBigPower,
|
||||||
MtRed,
|
MtRed,
|
||||||
NMCbit,
|
NmcBit,
|
||||||
YourbtcNet,
|
YourbtcNet,
|
||||||
GiveMeCoins,
|
GiveMeCoins,
|
||||||
BraiinsPool,
|
BraiinsPool,
|
||||||
AntPool,
|
AntPool,
|
||||||
MultiCoinCo,
|
MultiCoinCo,
|
||||||
BCPoolIo,
|
BcpoolIo,
|
||||||
Cointerra,
|
Cointerra,
|
||||||
KanoPool,
|
KanoPool,
|
||||||
SoloCK,
|
SoloCk,
|
||||||
CKPool,
|
CkPool,
|
||||||
NiceHash,
|
NiceHash,
|
||||||
BitClub,
|
BitClub,
|
||||||
BitcoinAffiliateNetwork,
|
BitcoinAffiliateNetwork,
|
||||||
BTCC,
|
Btcc,
|
||||||
BWPool,
|
BwPool,
|
||||||
EXXAndBW,
|
ExxBw,
|
||||||
Bitsolo,
|
Bitsolo,
|
||||||
BitFury,
|
BitFury,
|
||||||
TwentyOneInc,
|
TwentyOneInc,
|
||||||
DigitalBTC,
|
DigitalBtc,
|
||||||
EightBaochi,
|
EightBaochi,
|
||||||
MyBTCcoinPool,
|
MyBtcCoinPool,
|
||||||
TBDice,
|
TbDice,
|
||||||
HASHPOOL,
|
HashPool,
|
||||||
Nexious,
|
Nexious,
|
||||||
BravoMining,
|
BravoMining,
|
||||||
HotPool,
|
HotPool,
|
||||||
OKExPool,
|
OkExPool,
|
||||||
BCMonster,
|
BcMonster,
|
||||||
OneHash,
|
OneHash,
|
||||||
Bixin,
|
Bixin,
|
||||||
TATMASPool,
|
TatmasPool,
|
||||||
ViaBTC,
|
ViaBtc,
|
||||||
ConnectBTC,
|
ConnectBtc,
|
||||||
BATPOOL,
|
BatPool,
|
||||||
Waterhole,
|
Waterhole,
|
||||||
DCExploration,
|
DcExploration,
|
||||||
DCEX,
|
Dcex,
|
||||||
BTPOOL,
|
BtPool,
|
||||||
FiftyEightCoin,
|
FiftyEightCoin,
|
||||||
BitcoinIndiaLowercase,
|
BitcoinIndia,
|
||||||
ShawnP0wers,
|
ShawnP0wers,
|
||||||
PHashIO,
|
PHashIo,
|
||||||
RigPool,
|
RigPool,
|
||||||
HAOZHUZHU,
|
HaoZhuZhu,
|
||||||
SevenPool,
|
SevenPool,
|
||||||
MiningKings,
|
MiningKings,
|
||||||
HashBX,
|
HashBx,
|
||||||
DPOOL,
|
DPool,
|
||||||
Rawpool,
|
Rawpool,
|
||||||
Haominer,
|
Haominer,
|
||||||
Helix,
|
Helix,
|
||||||
@@ -114,62 +136,152 @@ pub enum PoolId {
|
|||||||
BinancePool,
|
BinancePool,
|
||||||
Minerium,
|
Minerium,
|
||||||
LubianCom,
|
LubianCom,
|
||||||
OKKONG,
|
Okkong,
|
||||||
AAOPool,
|
AaoPool,
|
||||||
EMCDPool,
|
EmcdPool,
|
||||||
FoundryUSA,
|
FoundryUsa,
|
||||||
SBICrypto,
|
SbiCrypto,
|
||||||
ArkPool,
|
ArkPool,
|
||||||
PureBTCCom,
|
PureBtcCom,
|
||||||
MARAPool,
|
MaraPool,
|
||||||
KuCoinPool,
|
KuCoinPool,
|
||||||
EntrustCharityPool,
|
EntrustCharityPool,
|
||||||
OKMINER,
|
OkMiner,
|
||||||
Titan,
|
Titan,
|
||||||
PEGAPool,
|
PegaPool,
|
||||||
BTCNuggets,
|
BtcNuggets,
|
||||||
CloudHashing,
|
CloudHashing,
|
||||||
DigitalXMintsy,
|
DigitalXMintsy,
|
||||||
Telco214,
|
Telco214,
|
||||||
BTCPoolParty,
|
BtcPoolParty,
|
||||||
Multipool,
|
Multipool,
|
||||||
TransactionCoinMining,
|
TransactionCoinMining,
|
||||||
BTCDig,
|
BtcDig,
|
||||||
TrickysBTCPool,
|
TrickysBtcPool,
|
||||||
BTCMP,
|
BtcMp,
|
||||||
Eobot,
|
Eobot,
|
||||||
UNOMP,
|
Unomp,
|
||||||
Patels,
|
Patels,
|
||||||
GoGreenLight,
|
GoGreenLight,
|
||||||
BitcoinIndiaCamel, // duplicate-ish entry preserved with slight name change
|
EkanemBtc,
|
||||||
EkanemBTC,
|
Canoe,
|
||||||
CanoeUppercase,
|
Tiger,
|
||||||
TigerLowercase,
|
OneM1x,
|
||||||
OneM1X,
|
|
||||||
Zulupool,
|
Zulupool,
|
||||||
SECPOOL,
|
SecPool,
|
||||||
OCEAN,
|
Ocean,
|
||||||
WhitePool,
|
WhitePool,
|
||||||
Wiz,
|
|
||||||
Mononaut,
|
|
||||||
Rijndael,
|
|
||||||
Wk057,
|
Wk057,
|
||||||
FutureBitApolloSolo,
|
FutureBitApolloSolo,
|
||||||
Emzy,
|
|
||||||
Knorrium,
|
|
||||||
CarbonNegative,
|
CarbonNegative,
|
||||||
PortlandHODL,
|
PortlandHodl,
|
||||||
Phoenix,
|
Phoenix,
|
||||||
Neopool,
|
Neopool,
|
||||||
MaxiPool,
|
MaxiPool,
|
||||||
DrDetroit,
|
|
||||||
BitFuFuPool,
|
BitFuFuPool,
|
||||||
LuckyPool,
|
LuckyPool,
|
||||||
MiningDutch,
|
MiningDutch,
|
||||||
PublicPool,
|
PublicPool,
|
||||||
MiningSquared,
|
MiningSquared,
|
||||||
InnopolisTech,
|
InnopolisTech,
|
||||||
Nymkappa,
|
BtcLab,
|
||||||
BTCLab,
|
|
||||||
Parasite,
|
Parasite,
|
||||||
|
Dummy158,
|
||||||
|
Dummy159,
|
||||||
|
Dummy160,
|
||||||
|
Dummy161,
|
||||||
|
Dummy162,
|
||||||
|
Dummy163,
|
||||||
|
Dummy164,
|
||||||
|
Dummy165,
|
||||||
|
Dummy166,
|
||||||
|
Dummy167,
|
||||||
|
Dummy168,
|
||||||
|
Dummy169,
|
||||||
|
Dummy170,
|
||||||
|
Dummy171,
|
||||||
|
Dummy172,
|
||||||
|
Dummy173,
|
||||||
|
Dummy174,
|
||||||
|
Dummy175,
|
||||||
|
Dummy176,
|
||||||
|
Dummy177,
|
||||||
|
Dummy178,
|
||||||
|
Dummy179,
|
||||||
|
Dummy180,
|
||||||
|
Dummy181,
|
||||||
|
Dummy182,
|
||||||
|
Dummy183,
|
||||||
|
Dummy184,
|
||||||
|
Dummy185,
|
||||||
|
Dummy186,
|
||||||
|
Dummy187,
|
||||||
|
Dummy188,
|
||||||
|
Dummy189,
|
||||||
|
Dummy190,
|
||||||
|
Dummy191,
|
||||||
|
Dummy192,
|
||||||
|
Dummy193,
|
||||||
|
Dummy194,
|
||||||
|
Dummy195,
|
||||||
|
Dummy196,
|
||||||
|
Dummy197,
|
||||||
|
Dummy198,
|
||||||
|
Dummy199,
|
||||||
|
Dummy200,
|
||||||
|
Dummy201,
|
||||||
|
Dummy202,
|
||||||
|
Dummy203,
|
||||||
|
Dummy204,
|
||||||
|
Dummy205,
|
||||||
|
Dummy206,
|
||||||
|
Dummy207,
|
||||||
|
Dummy208,
|
||||||
|
Dummy209,
|
||||||
|
Dummy210,
|
||||||
|
Dummy211,
|
||||||
|
Dummy212,
|
||||||
|
Dummy213,
|
||||||
|
Dummy214,
|
||||||
|
Dummy215,
|
||||||
|
Dummy216,
|
||||||
|
Dummy217,
|
||||||
|
Dummy218,
|
||||||
|
Dummy219,
|
||||||
|
Dummy220,
|
||||||
|
Dummy221,
|
||||||
|
Dummy222,
|
||||||
|
Dummy223,
|
||||||
|
Dummy224,
|
||||||
|
Dummy225,
|
||||||
|
Dummy226,
|
||||||
|
Dummy227,
|
||||||
|
Dummy228,
|
||||||
|
Dummy229,
|
||||||
|
Dummy230,
|
||||||
|
Dummy231,
|
||||||
|
Dummy232,
|
||||||
|
Dummy233,
|
||||||
|
Dummy234,
|
||||||
|
Dummy235,
|
||||||
|
Dummy236,
|
||||||
|
Dummy237,
|
||||||
|
Dummy238,
|
||||||
|
Dummy239,
|
||||||
|
Dummy240,
|
||||||
|
Dummy241,
|
||||||
|
Dummy242,
|
||||||
|
Dummy243,
|
||||||
|
Dummy244,
|
||||||
|
Dummy245,
|
||||||
|
Dummy246,
|
||||||
|
Dummy247,
|
||||||
|
Dummy248,
|
||||||
|
Dummy249,
|
||||||
|
Dummy250,
|
||||||
|
Dummy251,
|
||||||
|
Dummy252,
|
||||||
|
Dummy253,
|
||||||
|
Dummy254,
|
||||||
|
Dummy255,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,240 @@
|
|||||||
|
use std::{collections::BTreeMap, path::Path};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
|
use brk_error::Result;
|
||||||
|
use brk_indexer::Indexer;
|
||||||
|
use brk_store::AnyStore;
|
||||||
|
use brk_structs::{AddressBytes, Height, OutputIndex, OutputType};
|
||||||
|
use rayon::prelude::*;
|
||||||
|
use vecdb::{
|
||||||
|
AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec,
|
||||||
|
PAGE_SIZE, RawVec, StoredIndex, VecIterator, Version,
|
||||||
|
};
|
||||||
|
|
||||||
mod id;
|
mod id;
|
||||||
mod pool;
|
mod pool;
|
||||||
|
#[allow(clippy::module_inception)]
|
||||||
mod pools;
|
mod pools;
|
||||||
|
mod vecs;
|
||||||
|
|
||||||
pub use id::*;
|
pub use id::*;
|
||||||
pub use pool::*;
|
pub use pool::*;
|
||||||
pub use pools::*;
|
pub use pools::*;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
chain,
|
||||||
|
indexes::{self, Indexes},
|
||||||
|
price,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Allocative)]
|
||||||
|
pub struct Vecs {
|
||||||
|
db: Database,
|
||||||
|
pools: &'static Pools,
|
||||||
|
height_to_pool: RawVec<Height, PoolId>,
|
||||||
|
|
||||||
|
vecs: BTreeMap<PoolId, vecs::Vecs>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Vecs {
|
||||||
|
pub fn forced_import(
|
||||||
|
parent_path: &Path,
|
||||||
|
parent_version: Version,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
price: Option<&price::Vecs>,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let db = Database::open(&parent_path.join("pools"))?;
|
||||||
|
db.set_min_len(PAGE_SIZE * 1_000_000)?;
|
||||||
|
let pools = pools();
|
||||||
|
|
||||||
|
let version = parent_version + Version::new(3) + Version::new(pools.len() as u64);
|
||||||
|
|
||||||
|
let this = Self {
|
||||||
|
height_to_pool: RawVec::forced_import(&db, "pool", version + Version::ZERO)?,
|
||||||
|
vecs: pools
|
||||||
|
.iter()
|
||||||
|
.map(|pool| {
|
||||||
|
vecs::Vecs::forced_import(
|
||||||
|
&db,
|
||||||
|
pool.id,
|
||||||
|
pools,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
price,
|
||||||
|
)
|
||||||
|
.map(|vecs| (pool.id, vecs))
|
||||||
|
})
|
||||||
|
.collect::<Result<BTreeMap<_, _>>>()?,
|
||||||
|
pools,
|
||||||
|
db,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.db.retain_regions(
|
||||||
|
this.vecs()
|
||||||
|
.into_iter()
|
||||||
|
.flat_map(|v| v.region_names())
|
||||||
|
.collect(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn compute(
|
||||||
|
&mut self,
|
||||||
|
indexer: &Indexer,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
starting_indexes: &Indexes,
|
||||||
|
chain: &chain::Vecs,
|
||||||
|
price: Option<&price::Vecs>,
|
||||||
|
exit: &Exit,
|
||||||
|
) -> Result<()> {
|
||||||
|
self.compute_(indexer, indexes, starting_indexes, chain, price, exit)?;
|
||||||
|
self.db.flush_then_punch()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn compute_(
|
||||||
|
&mut self,
|
||||||
|
indexer: &Indexer,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
starting_indexes: &Indexes,
|
||||||
|
chain: &chain::Vecs,
|
||||||
|
price: Option<&price::Vecs>,
|
||||||
|
exit: &Exit,
|
||||||
|
) -> Result<()> {
|
||||||
|
self.compute_height_to_pool(indexer, indexes, starting_indexes, exit)?;
|
||||||
|
|
||||||
|
self.vecs.par_iter_mut().try_for_each(|(_, vecs)| {
|
||||||
|
vecs.compute(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
&self.height_to_pool,
|
||||||
|
chain,
|
||||||
|
price,
|
||||||
|
exit,
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn compute_height_to_pool(
|
||||||
|
&mut self,
|
||||||
|
indexer: &Indexer,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
starting_indexes: &Indexes,
|
||||||
|
exit: &Exit,
|
||||||
|
) -> Result<()> {
|
||||||
|
self.height_to_pool.validate_computed_version_or_reset(
|
||||||
|
self.height_to_pool.version() + indexer.stores.height_to_coinbase_tag.version(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let mut height_to_first_txindex_iter = indexer.vecs.height_to_first_txindex.iter();
|
||||||
|
let mut txindex_to_first_outputindex_iter =
|
||||||
|
indexer.vecs.txindex_to_first_outputindex.iter();
|
||||||
|
let mut txindex_to_output_count_iter = indexes.txindex_to_output_count.iter();
|
||||||
|
let mut outputindex_to_outputtype_iter = indexer.vecs.outputindex_to_outputtype.iter();
|
||||||
|
let mut outputindex_to_typeindex_iter = indexer.vecs.outputindex_to_typeindex.iter();
|
||||||
|
let mut p2pk65addressindex_to_p2pk65bytes_iter =
|
||||||
|
indexer.vecs.p2pk65addressindex_to_p2pk65bytes.iter();
|
||||||
|
let mut p2pk33addressindex_to_p2pk33bytes_iter =
|
||||||
|
indexer.vecs.p2pk33addressindex_to_p2pk33bytes.iter();
|
||||||
|
let mut p2pkhaddressindex_to_p2pkhbytes_iter =
|
||||||
|
indexer.vecs.p2pkhaddressindex_to_p2pkhbytes.iter();
|
||||||
|
let mut p2shaddressindex_to_p2shbytes_iter =
|
||||||
|
indexer.vecs.p2shaddressindex_to_p2shbytes.iter();
|
||||||
|
let mut p2wpkhaddressindex_to_p2wpkhbytes_iter =
|
||||||
|
indexer.vecs.p2wpkhaddressindex_to_p2wpkhbytes.iter();
|
||||||
|
let mut p2wshaddressindex_to_p2wshbytes_iter =
|
||||||
|
indexer.vecs.p2wshaddressindex_to_p2wshbytes.iter();
|
||||||
|
let mut p2traddressindex_to_p2trbytes_iter =
|
||||||
|
indexer.vecs.p2traddressindex_to_p2trbytes.iter();
|
||||||
|
let mut p2aaddressindex_to_p2abytes_iter = indexer.vecs.p2aaddressindex_to_p2abytes.iter();
|
||||||
|
|
||||||
|
let unknown = self.pools.get_unknown();
|
||||||
|
|
||||||
|
let min = starting_indexes
|
||||||
|
.height
|
||||||
|
.unwrap_to_usize()
|
||||||
|
.min(self.height_to_pool.len());
|
||||||
|
|
||||||
|
indexer
|
||||||
|
.stores
|
||||||
|
.height_to_coinbase_tag
|
||||||
|
.iter()
|
||||||
|
.skip(min)
|
||||||
|
.try_for_each(|(height, coinbase_tag)| -> Result<()> {
|
||||||
|
let txindex = height_to_first_txindex_iter.unwrap_get_inner(height);
|
||||||
|
let outputindex = txindex_to_first_outputindex_iter.unwrap_get_inner(txindex);
|
||||||
|
let outputcount = txindex_to_output_count_iter.unwrap_get_inner(txindex);
|
||||||
|
|
||||||
|
let pool = (*outputindex..(*outputindex + *outputcount))
|
||||||
|
.map(OutputIndex::from)
|
||||||
|
.find_map(|outputindex| {
|
||||||
|
let outputtype =
|
||||||
|
outputindex_to_outputtype_iter.unwrap_get_inner(outputindex);
|
||||||
|
let typeindex = outputindex_to_typeindex_iter.unwrap_get_inner(outputindex);
|
||||||
|
|
||||||
|
let address = match outputtype {
|
||||||
|
OutputType::P2PK65 => Some(AddressBytes::from(
|
||||||
|
p2pk65addressindex_to_p2pk65bytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2PK33 => Some(AddressBytes::from(
|
||||||
|
p2pk33addressindex_to_p2pk33bytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2PKH => Some(AddressBytes::from(
|
||||||
|
p2pkhaddressindex_to_p2pkhbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2SH => Some(AddressBytes::from(
|
||||||
|
p2shaddressindex_to_p2shbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2WPKH => Some(AddressBytes::from(
|
||||||
|
p2wpkhaddressindex_to_p2wpkhbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2WSH => Some(AddressBytes::from(
|
||||||
|
p2wshaddressindex_to_p2wshbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2TR => Some(AddressBytes::from(
|
||||||
|
p2traddressindex_to_p2trbytes_iter
|
||||||
|
.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
OutputType::P2A => Some(AddressBytes::from(
|
||||||
|
p2aaddressindex_to_p2abytes_iter.unwrap_get_inner(typeindex.into()),
|
||||||
|
)),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
address
|
||||||
|
.and_then(|address| self.pools.find_from_address(&address.to_string()))
|
||||||
|
})
|
||||||
|
.or_else(|| self.pools.find_from_coinbase_tag(&coinbase_tag))
|
||||||
|
.unwrap_or(unknown);
|
||||||
|
|
||||||
|
self.height_to_pool.push_if_needed(height, pool.id)?;
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
|
||||||
|
self.height_to_pool.safe_flush(exit)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
|
||||||
|
[
|
||||||
|
self.vecs
|
||||||
|
.iter()
|
||||||
|
.flat_map(|(_, vecs)| vecs.vecs())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
vec![&self.height_to_pool],
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,44 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use allocative::Allocative;
|
||||||
|
|
||||||
use crate::pools::PoolId;
|
use crate::pools::PoolId;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Allocative)]
|
||||||
pub struct Pool {
|
pub struct Pool {
|
||||||
pub id: PoolId,
|
pub id: PoolId,
|
||||||
|
pub name: &'static str,
|
||||||
|
pub addresses: Box<[&'static str]>,
|
||||||
|
pub tags: Box<[&'static str]>,
|
||||||
|
pub tags_lowercase: Box<[String]>,
|
||||||
|
pub link: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pool {
|
||||||
|
pub fn serialized_id(&self) -> String {
|
||||||
|
let value = serde_json::to_value(self.id).unwrap();
|
||||||
|
value.as_str().unwrap().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<(usize, JSONPool)> for Pool {
|
||||||
|
fn from((index, pool): (usize, JSONPool)) -> Self {
|
||||||
|
Self {
|
||||||
|
id: (index as u8).into(),
|
||||||
|
name: pool.name,
|
||||||
|
addresses: pool.addresses,
|
||||||
|
tags_lowercase: pool
|
||||||
|
.tags
|
||||||
|
.iter()
|
||||||
|
.map(|t| t.to_lowercase())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.into_boxed_slice(),
|
||||||
|
tags: pool.tags,
|
||||||
|
link: pool.link,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct JSONPool {
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
pub addresses: Box<[&'static str]>,
|
pub addresses: Box<[&'static str]>,
|
||||||
pub tags: Box<[&'static str]>,
|
pub tags: Box<[&'static str]>,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,467 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
|
use brk_error::Result;
|
||||||
|
use brk_indexer::Indexer;
|
||||||
|
use brk_structs::{Height, Sats, StoredF32, StoredU16, StoredU32};
|
||||||
|
use vecdb::{AnyCollectableVec, AnyIterableVec, Database, Exit, StoredIndex, VecIterator, Version};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
PoolId, Pools, chain,
|
||||||
|
grouped::{
|
||||||
|
ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, ComputedVecsFromHeight, Source,
|
||||||
|
VecBuilderOptions,
|
||||||
|
},
|
||||||
|
indexes::{self, Indexes},
|
||||||
|
price,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Allocative)]
|
||||||
|
pub struct Vecs {
|
||||||
|
id: PoolId,
|
||||||
|
|
||||||
|
indexes_to_blocks_mined: ComputedVecsFromHeight<StoredU32>,
|
||||||
|
indexes_to_1w_blocks_mined: ComputedVecsFromDateIndex<StoredU32>,
|
||||||
|
indexes_to_1m_blocks_mined: ComputedVecsFromDateIndex<StoredU32>,
|
||||||
|
indexes_to_1y_blocks_mined: ComputedVecsFromDateIndex<StoredU32>,
|
||||||
|
indexes_to_subsidy: ComputedValueVecsFromHeight,
|
||||||
|
indexes_to_fee: ComputedValueVecsFromHeight,
|
||||||
|
indexes_to_coinbase: ComputedValueVecsFromHeight,
|
||||||
|
indexes_to_dominance: ComputedVecsFromDateIndex<StoredF32>,
|
||||||
|
indexes_to_1d_dominance: ComputedVecsFromDateIndex<StoredF32>,
|
||||||
|
indexes_to_1w_dominance: ComputedVecsFromDateIndex<StoredF32>,
|
||||||
|
indexes_to_1m_dominance: ComputedVecsFromDateIndex<StoredF32>,
|
||||||
|
indexes_to_1y_dominance: ComputedVecsFromDateIndex<StoredF32>,
|
||||||
|
indexes_to_days_since_block: ComputedVecsFromDateIndex<StoredU16>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Vecs {
|
||||||
|
pub fn forced_import(
|
||||||
|
db: &Database,
|
||||||
|
id: PoolId,
|
||||||
|
pools: &Pools,
|
||||||
|
parent_version: Version,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
price: Option<&price::Vecs>,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let pool = pools.get(id);
|
||||||
|
let name = pool.serialized_id();
|
||||||
|
let suffix = |s: &str| format!("{name}_{s}");
|
||||||
|
let compute_dollars = price.is_some();
|
||||||
|
let version = parent_version + Version::ZERO;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
id,
|
||||||
|
indexes_to_blocks_mined: ComputedVecsFromHeight::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("blocks_mined"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1w_blocks_mined: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1w_blocks_mined"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1m_blocks_mined: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1m_blocks_mined"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1y_blocks_mined: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1y_blocks_mined"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_subsidy: ComputedValueVecsFromHeight::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("subsidy"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||||
|
compute_dollars,
|
||||||
|
indexes,
|
||||||
|
)?,
|
||||||
|
indexes_to_fee: ComputedValueVecsFromHeight::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("fee"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||||
|
compute_dollars,
|
||||||
|
indexes,
|
||||||
|
)?,
|
||||||
|
indexes_to_coinbase: ComputedValueVecsFromHeight::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("coinbase"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
VecBuilderOptions::default().add_sum().add_cumulative(),
|
||||||
|
compute_dollars,
|
||||||
|
indexes,
|
||||||
|
)?,
|
||||||
|
indexes_to_dominance: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("dominance"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1d_dominance: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1d_dominance"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1w_dominance: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1w_dominance"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1m_dominance: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1m_dominance"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_1y_dominance: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("1y_dominance"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
indexes_to_days_since_block: ComputedVecsFromDateIndex::forced_import(
|
||||||
|
db,
|
||||||
|
&suffix("days_since_block"),
|
||||||
|
Source::Compute,
|
||||||
|
version + Version::ZERO,
|
||||||
|
indexes,
|
||||||
|
VecBuilderOptions::default().add_last(),
|
||||||
|
)?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn compute(
|
||||||
|
&mut self,
|
||||||
|
indexer: &Indexer,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
starting_indexes: &Indexes,
|
||||||
|
height_to_pool: &impl AnyIterableVec<Height, PoolId>,
|
||||||
|
chain: &chain::Vecs,
|
||||||
|
price: Option<&price::Vecs>,
|
||||||
|
exit: &Exit,
|
||||||
|
) -> Result<()> {
|
||||||
|
self.indexes_to_blocks_mined.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_transform(
|
||||||
|
starting_indexes.height,
|
||||||
|
height_to_pool,
|
||||||
|
|(h, id, ..)| {
|
||||||
|
(
|
||||||
|
h,
|
||||||
|
if id == self.id {
|
||||||
|
StoredU32::ONE
|
||||||
|
} else {
|
||||||
|
StoredU32::ZERO
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1w_blocks_mined.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
v.compute_sum(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_sum(),
|
||||||
|
7,
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1m_blocks_mined.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
v.compute_sum(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_sum(),
|
||||||
|
30,
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1y_blocks_mined.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
v.compute_sum(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_sum(),
|
||||||
|
365,
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let height_to_blocks_mined = self.indexes_to_blocks_mined.height.as_ref().unwrap();
|
||||||
|
|
||||||
|
self.indexes_to_subsidy.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
price,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_transform2(
|
||||||
|
starting_indexes.height,
|
||||||
|
height_to_blocks_mined,
|
||||||
|
chain.indexes_to_subsidy.sats.height.as_ref().unwrap(),
|
||||||
|
|(h, mined, sats, ..)| {
|
||||||
|
(
|
||||||
|
h,
|
||||||
|
if mined == StoredU32::ONE {
|
||||||
|
sats
|
||||||
|
} else {
|
||||||
|
Sats::ZERO
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_fee.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
price,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_transform2(
|
||||||
|
starting_indexes.height,
|
||||||
|
height_to_blocks_mined,
|
||||||
|
chain.indexes_to_fee.sats.height.unwrap_sum(),
|
||||||
|
|(h, mined, sats, ..)| {
|
||||||
|
(
|
||||||
|
h,
|
||||||
|
if mined == StoredU32::ONE {
|
||||||
|
sats
|
||||||
|
} else {
|
||||||
|
Sats::ZERO
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_coinbase.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
price,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_transform2(
|
||||||
|
starting_indexes.height,
|
||||||
|
height_to_blocks_mined,
|
||||||
|
chain.indexes_to_coinbase.sats.height.as_ref().unwrap(),
|
||||||
|
|(h, mined, sats, ..)| {
|
||||||
|
(
|
||||||
|
h,
|
||||||
|
if mined == StoredU32::ONE {
|
||||||
|
sats
|
||||||
|
} else {
|
||||||
|
Sats::ZERO
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_dominance.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_percentage(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_cumulative(),
|
||||||
|
chain.indexes_to_block_count.dateindex.unwrap_cumulative(),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1d_dominance.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_percentage(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_sum(),
|
||||||
|
chain.indexes_to_block_count.dateindex.unwrap_sum(),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1w_dominance.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_percentage(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_1w_blocks_mined.dateindex.as_ref().unwrap(),
|
||||||
|
chain.indexes_to_1w_block_count.dateindex.as_ref().unwrap(),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1m_dominance.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_percentage(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_1m_blocks_mined.dateindex.as_ref().unwrap(),
|
||||||
|
chain.indexes_to_1m_block_count.dateindex.as_ref().unwrap(),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_1y_dominance.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|vec, _, _, starting_indexes, exit| {
|
||||||
|
vec.compute_percentage(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_1y_blocks_mined.dateindex.as_ref().unwrap(),
|
||||||
|
chain.indexes_to_1y_block_count.dateindex.as_ref().unwrap(),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.indexes_to_days_since_block.compute_all(
|
||||||
|
indexer,
|
||||||
|
indexes,
|
||||||
|
starting_indexes,
|
||||||
|
exit,
|
||||||
|
|v, _, _, starting_indexes, exit| {
|
||||||
|
let mut prev = None;
|
||||||
|
v.compute_transform2(
|
||||||
|
starting_indexes.dateindex,
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_sum(),
|
||||||
|
self.indexes_to_blocks_mined.dateindex.unwrap_cumulative(),
|
||||||
|
|(i, sum, cumulative, slf)| {
|
||||||
|
if prev.is_none() {
|
||||||
|
let i = i.unwrap_to_usize();
|
||||||
|
prev.replace(if i > 0 {
|
||||||
|
slf.into_iter().unwrap_get_inner_(i - 1)
|
||||||
|
} else {
|
||||||
|
StoredU16::ZERO
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let days = if !cumulative.is_zero() && sum.is_zero() {
|
||||||
|
prev.unwrap() + StoredU16::ONE
|
||||||
|
} else {
|
||||||
|
StoredU16::ZERO
|
||||||
|
};
|
||||||
|
prev.replace(days);
|
||||||
|
(i, days)
|
||||||
|
},
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> {
|
||||||
|
[
|
||||||
|
self.indexes_to_blocks_mined.vecs(),
|
||||||
|
self.indexes_to_1w_blocks_mined.vecs(),
|
||||||
|
self.indexes_to_1m_blocks_mined.vecs(),
|
||||||
|
self.indexes_to_1y_blocks_mined.vecs(),
|
||||||
|
self.indexes_to_subsidy.vecs(),
|
||||||
|
self.indexes_to_fee.vecs(),
|
||||||
|
self.indexes_to_coinbase.vecs(),
|
||||||
|
self.indexes_to_dominance.vecs(),
|
||||||
|
self.indexes_to_1d_dominance.vecs(),
|
||||||
|
self.indexes_to_1w_dominance.vecs(),
|
||||||
|
self.indexes_to_1m_dominance.vecs(),
|
||||||
|
self.indexes_to_1y_dominance.vecs(),
|
||||||
|
self.indexes_to_days_since_block.vecs(),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,12 +50,12 @@ pub struct Vecs {
|
|||||||
|
|
||||||
pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight<StoredF64>,
|
pub indexes_to_coinblocks_destroyed: ComputedVecsFromHeight<StoredF64>,
|
||||||
pub indexes_to_coindays_destroyed: ComputedVecsFromHeight<StoredF64>,
|
pub indexes_to_coindays_destroyed: ComputedVecsFromHeight<StoredF64>,
|
||||||
pub dateindex_to_sopr: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_sopr: Option<EagerVec<DateIndex, StoredF64>>,
|
||||||
pub dateindex_to_sopr_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_sopr_7d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||||
pub dateindex_to_sopr_30d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_sopr_30d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||||
pub dateindex_to_adjusted_sopr: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_adjusted_sopr: Option<EagerVec<DateIndex, StoredF64>>,
|
||||||
pub dateindex_to_adjusted_sopr_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_adjusted_sopr_7d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||||
pub dateindex_to_adjusted_sopr_30d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_adjusted_sopr_30d_ema: Option<EagerVec<DateIndex, StoredF64>>,
|
||||||
pub indexes_to_realized_cap_30d_delta: Option<ComputedVecsFromDateIndex<Dollars>>,
|
pub indexes_to_realized_cap_30d_delta: Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||||
pub dateindex_to_sell_side_risk_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_sell_side_risk_ratio: Option<EagerVec<DateIndex, StoredF32>>,
|
||||||
pub dateindex_to_sell_side_risk_ratio_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
pub dateindex_to_sell_side_risk_ratio_7d_ema: Option<EagerVec<DateIndex, StoredF32>>,
|
||||||
@@ -720,7 +720,7 @@ impl Vecs {
|
|||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&suffix("sopr"),
|
&suffix("sopr"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ONE,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -729,7 +729,7 @@ impl Vecs {
|
|||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&suffix("sopr_7d_ema"),
|
&suffix("sopr_7d_ema"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ONE,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -738,7 +738,7 @@ impl Vecs {
|
|||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&suffix("sopr_30d_ema"),
|
&suffix("sopr_30d_ema"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ONE,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -747,7 +747,7 @@ impl Vecs {
|
|||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&suffix("adjusted_sopr"),
|
&suffix("adjusted_sopr"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ONE,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -756,7 +756,7 @@ impl Vecs {
|
|||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&suffix("adjusted_sopr_7d_ema"),
|
&suffix("adjusted_sopr_7d_ema"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ONE,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -765,7 +765,7 @@ impl Vecs {
|
|||||||
EagerVec::forced_import(
|
EagerVec::forced_import(
|
||||||
db,
|
db,
|
||||||
&suffix("adjusted_sopr_30d_ema"),
|
&suffix("adjusted_sopr_30d_ema"),
|
||||||
version + VERSION + Version::ZERO,
|
version + VERSION + Version::ONE,
|
||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ pub use indexes::*;
|
|||||||
pub use stores::*;
|
pub use stores::*;
|
||||||
pub use vecs::*;
|
pub use vecs::*;
|
||||||
|
|
||||||
|
// One version for all data sources
|
||||||
|
// Increment on change OR addition
|
||||||
|
const VERSION: Version = Version::new(21);
|
||||||
|
|
||||||
const SNAPSHOT_BLOCK_RANGE: usize = 1_000;
|
const SNAPSHOT_BLOCK_RANGE: usize = 1_000;
|
||||||
const COLLISIONS_CHECKED_UP_TO: Height = Height::new(909_150);
|
const COLLISIONS_CHECKED_UP_TO: Height = Height::new(909_150);
|
||||||
const VERSION: Version = Version::ONE;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Indexer {
|
pub struct Indexer {
|
||||||
@@ -39,10 +42,10 @@ impl Indexer {
|
|||||||
|
|
||||||
let path = outputs_dir.join("indexed");
|
let path = outputs_dir.join("indexed");
|
||||||
|
|
||||||
let vecs = Vecs::forced_import(&path, VERSION + Version::ZERO)?;
|
let vecs = Vecs::forced_import(&path, VERSION)?;
|
||||||
info!("Imported vecs");
|
info!("Imported vecs");
|
||||||
|
|
||||||
let stores = Stores::forced_import(&path, VERSION + Version::ZERO)?;
|
let stores = Stores::forced_import(&path, VERSION)?;
|
||||||
info!("Imported stores");
|
info!("Imported stores");
|
||||||
|
|
||||||
Ok(Self { vecs, stores })
|
Ok(Self { vecs, stores })
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ pub struct Stores {
|
|||||||
ByAddressType<Store<TypeIndexWithOutputindex, Unit>>,
|
ByAddressType<Store<TypeIndexWithOutputindex, Unit>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
|
||||||
|
|
||||||
impl Stores {
|
impl Stores {
|
||||||
pub fn forced_import(parent: &Path, version: Version) -> Result<Self> {
|
pub fn forced_import(parent: &Path, version: Version) -> Result<Self> {
|
||||||
let path = parent.join("stores");
|
let path = parent.join("stores");
|
||||||
@@ -49,34 +47,21 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"addressbyteshash_to_typeindex",
|
"addressbyteshash_to_typeindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let blockhashprefix_to_height = scope.spawn(|| {
|
let blockhashprefix_to_height = scope.spawn(|| {
|
||||||
Store::import(
|
Store::import(&keyspace, &path, "blockhashprefix_to_height", version, None)
|
||||||
&keyspace,
|
|
||||||
&path,
|
|
||||||
"blockhashprefix_to_height",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
let txidprefix_to_txindex = scope.spawn(|| {
|
|
||||||
Store::import(
|
|
||||||
&keyspace,
|
|
||||||
&path,
|
|
||||||
"txidprefix_to_txindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
let txidprefix_to_txindex = scope
|
||||||
|
.spawn(|| Store::import(&keyspace, &path, "txidprefix_to_txindex", version, None));
|
||||||
let p2aaddressindex_with_outputindex = scope.spawn(|| {
|
let p2aaddressindex_with_outputindex = scope.spawn(|| {
|
||||||
Store::import(
|
Store::import(
|
||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2aaddressindex_with_outputindex",
|
"p2aaddressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -85,7 +70,7 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2pk33addressindex_with_outputindex",
|
"p2pk33addressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -94,7 +79,7 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2pk65addressindex_with_outputindex",
|
"p2pk65addressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -103,7 +88,7 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2pkhaddressindex_with_outputindex",
|
"p2pkhaddressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -112,7 +97,7 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2shaddressindex_with_outputindex",
|
"p2shaddressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -121,7 +106,7 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2traddressindex_with_outputindex",
|
"p2traddressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -130,7 +115,7 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2wpkhaddressindex_with_outputindex",
|
"p2wpkhaddressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -139,18 +124,13 @@ impl Stores {
|
|||||||
&keyspace,
|
&keyspace,
|
||||||
&path,
|
&path,
|
||||||
"p2wshaddressindex_with_outputindex",
|
"p2wshaddressindex_with_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
Some(false),
|
Some(false),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let height_to_coinbase_tag = Store::import(
|
let height_to_coinbase_tag =
|
||||||
&keyspace,
|
Store::import(&keyspace, &path, "height_to_coinbase_tag", version, None)?;
|
||||||
&path,
|
|
||||||
"height_to_coinbase_tag",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
keyspace: keyspace.clone(),
|
keyspace: keyspace.clone(),
|
||||||
|
|||||||
+44
-150
@@ -17,8 +17,6 @@ use vecdb::{
|
|||||||
|
|
||||||
use crate::Indexes;
|
use crate::Indexes;
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Vecs {
|
pub struct Vecs {
|
||||||
db: Database,
|
db: Database,
|
||||||
@@ -78,222 +76,118 @@ impl Vecs {
|
|||||||
db.set_min_len(PAGE_SIZE * 50_000_000)?;
|
db.set_min_len(PAGE_SIZE * 50_000_000)?;
|
||||||
|
|
||||||
let this = Self {
|
let this = Self {
|
||||||
emptyoutputindex_to_txindex: CompressedVec::forced_import(
|
emptyoutputindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
|
||||||
&db,
|
height_to_blockhash: RawVec::forced_import(&db, "blockhash", version)?,
|
||||||
"txindex",
|
height_to_difficulty: CompressedVec::forced_import(&db, "difficulty", version)?,
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
height_to_blockhash: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"blockhash",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
height_to_difficulty: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"difficulty",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
height_to_first_emptyoutputindex: CompressedVec::forced_import(
|
height_to_first_emptyoutputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_emptyoutputindex",
|
"first_emptyoutputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_inputindex: CompressedVec::forced_import(
|
height_to_first_inputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_inputindex",
|
"first_inputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_opreturnindex: CompressedVec::forced_import(
|
height_to_first_opreturnindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_opreturnindex",
|
"first_opreturnindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_outputindex: CompressedVec::forced_import(
|
height_to_first_outputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_outputindex",
|
"first_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2aaddressindex: CompressedVec::forced_import(
|
height_to_first_p2aaddressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2aaddressindex",
|
"first_p2aaddressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2msoutputindex: CompressedVec::forced_import(
|
height_to_first_p2msoutputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2msoutputindex",
|
"first_p2msoutputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2pk33addressindex: CompressedVec::forced_import(
|
height_to_first_p2pk33addressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2pk33addressindex",
|
"first_p2pk33addressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2pk65addressindex: CompressedVec::forced_import(
|
height_to_first_p2pk65addressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2pk65addressindex",
|
"first_p2pk65addressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2pkhaddressindex: CompressedVec::forced_import(
|
height_to_first_p2pkhaddressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2pkhaddressindex",
|
"first_p2pkhaddressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2shaddressindex: CompressedVec::forced_import(
|
height_to_first_p2shaddressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2shaddressindex",
|
"first_p2shaddressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2traddressindex: CompressedVec::forced_import(
|
height_to_first_p2traddressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2traddressindex",
|
"first_p2traddressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2wpkhaddressindex: CompressedVec::forced_import(
|
height_to_first_p2wpkhaddressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2wpkhaddressindex",
|
"first_p2wpkhaddressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_p2wshaddressindex: CompressedVec::forced_import(
|
height_to_first_p2wshaddressindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_p2wshaddressindex",
|
"first_p2wshaddressindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
|
||||||
height_to_first_txindex: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"first_txindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
)?,
|
||||||
|
height_to_first_txindex: CompressedVec::forced_import(&db, "first_txindex", version)?,
|
||||||
height_to_first_unknownoutputindex: CompressedVec::forced_import(
|
height_to_first_unknownoutputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_unknownoutputindex",
|
"first_unknownoutputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
|
||||||
height_to_timestamp: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"timestamp",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
height_to_total_size: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"total_size",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
height_to_weight: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"weight",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
inputindex_to_outputindex: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"outputindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
opreturnindex_to_txindex: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"txindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
outputindex_to_outputtype: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"outputtype",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
outputindex_to_typeindex: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"typeindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
outputindex_to_value: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"value",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2aaddressindex_to_p2abytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2abytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2msoutputindex_to_txindex: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"txindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2pk33addressindex_to_p2pk33bytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2pk33bytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2pk65addressindex_to_p2pk65bytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2pk65bytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2pkhaddressindex_to_p2pkhbytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2pkhbytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2shaddressindex_to_p2shbytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2shbytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2traddressindex_to_p2trbytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2trbytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2wpkhaddressindex_to_p2wpkhbytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2wpkhbytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
p2wshaddressindex_to_p2wshbytes: RawVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"p2wshbytes",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
txindex_to_base_size: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"base_size",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
)?,
|
||||||
|
height_to_timestamp: CompressedVec::forced_import(&db, "timestamp", version)?,
|
||||||
|
height_to_total_size: CompressedVec::forced_import(&db, "total_size", version)?,
|
||||||
|
height_to_weight: CompressedVec::forced_import(&db, "weight", version)?,
|
||||||
|
inputindex_to_outputindex: RawVec::forced_import(&db, "outputindex", version)?,
|
||||||
|
opreturnindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
|
||||||
|
outputindex_to_outputtype: RawVec::forced_import(&db, "outputtype", version)?,
|
||||||
|
outputindex_to_typeindex: RawVec::forced_import(&db, "typeindex", version)?,
|
||||||
|
outputindex_to_value: RawVec::forced_import(&db, "value", version)?,
|
||||||
|
p2aaddressindex_to_p2abytes: RawVec::forced_import(&db, "p2abytes", version)?,
|
||||||
|
p2msoutputindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
|
||||||
|
p2pk33addressindex_to_p2pk33bytes: RawVec::forced_import(&db, "p2pk33bytes", version)?,
|
||||||
|
p2pk65addressindex_to_p2pk65bytes: RawVec::forced_import(&db, "p2pk65bytes", version)?,
|
||||||
|
p2pkhaddressindex_to_p2pkhbytes: RawVec::forced_import(&db, "p2pkhbytes", version)?,
|
||||||
|
p2shaddressindex_to_p2shbytes: RawVec::forced_import(&db, "p2shbytes", version)?,
|
||||||
|
p2traddressindex_to_p2trbytes: RawVec::forced_import(&db, "p2trbytes", version)?,
|
||||||
|
p2wpkhaddressindex_to_p2wpkhbytes: RawVec::forced_import(&db, "p2wpkhbytes", version)?,
|
||||||
|
p2wshaddressindex_to_p2wshbytes: RawVec::forced_import(&db, "p2wshbytes", version)?,
|
||||||
|
txindex_to_base_size: CompressedVec::forced_import(&db, "base_size", version)?,
|
||||||
txindex_to_first_inputindex: CompressedVec::forced_import(
|
txindex_to_first_inputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_inputindex",
|
"first_inputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_first_outputindex: CompressedVec::forced_import(
|
txindex_to_first_outputindex: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"first_outputindex",
|
"first_outputindex",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_is_explicitly_rbf: CompressedVec::forced_import(
|
txindex_to_is_explicitly_rbf: CompressedVec::forced_import(
|
||||||
&db,
|
&db,
|
||||||
"is_explicitly_rbf",
|
"is_explicitly_rbf",
|
||||||
version + VERSION + Version::ZERO,
|
version,
|
||||||
)?,
|
|
||||||
txindex_to_rawlocktime: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"rawlocktime",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
txindex_to_total_size: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"total_size",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
txindex_to_txid: RawVec::forced_import(&db, "txid", version + VERSION + Version::ZERO)?,
|
|
||||||
txindex_to_txversion: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"txversion",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
|
||||||
unknownoutputindex_to_txindex: CompressedVec::forced_import(
|
|
||||||
&db,
|
|
||||||
"txindex",
|
|
||||||
version + VERSION + Version::ZERO,
|
|
||||||
)?,
|
)?,
|
||||||
|
txindex_to_rawlocktime: CompressedVec::forced_import(&db, "rawlocktime", version)?,
|
||||||
|
txindex_to_total_size: CompressedVec::forced_import(&db, "total_size", version)?,
|
||||||
|
txindex_to_txid: RawVec::forced_import(&db, "txid", version)?,
|
||||||
|
txindex_to_txversion: CompressedVec::forced_import(&db, "txversion", version)?,
|
||||||
|
unknownoutputindex_to_txindex: CompressedVec::forced_import(&db, "txindex", version)?,
|
||||||
|
|
||||||
db,
|
db,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use serde::Deserialize;
|
|||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, JsonSchema)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum Format {
|
pub enum Format {
|
||||||
#[serde(alias = "json")]
|
#[serde(alias = "json")]
|
||||||
JSON,
|
JSON,
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use serde::Deserialize;
|
|||||||
#[derive(Debug, Deref, JsonSchema)]
|
#[derive(Debug, Deref, JsonSchema)]
|
||||||
pub struct MaybeIds(Vec<String>);
|
pub struct MaybeIds(Vec<String>);
|
||||||
|
|
||||||
const MAX_STRING_SIZE: usize = 10_000;
|
const MAX_VECS: usize = 32;
|
||||||
const MAX_VECS: usize = 64;
|
const MAX_STRING_SIZE: usize = 64 * MAX_VECS;
|
||||||
|
|
||||||
impl From<String> for MaybeIds {
|
impl From<String> for MaybeIds {
|
||||||
fn from(value: String) -> Self {
|
fn from(value: String) -> Self {
|
||||||
@@ -29,7 +29,7 @@ impl<'de> Deserialize<'de> for MaybeIds {
|
|||||||
{
|
{
|
||||||
match serde_json::Value::deserialize(deserializer)? {
|
match serde_json::Value::deserialize(deserializer)? {
|
||||||
serde_json::Value::String(str) => {
|
serde_json::Value::String(str) => {
|
||||||
if str.len() > MAX_STRING_SIZE {
|
if str.len() <= MAX_STRING_SIZE {
|
||||||
Ok(MaybeIds(sanitize_ids(
|
Ok(MaybeIds(sanitize_ids(
|
||||||
str.split(",").map(|s| s.to_string()),
|
str.split(",").map(|s| s.to_string()),
|
||||||
)))
|
)))
|
||||||
@@ -38,7 +38,7 @@ impl<'de> Deserialize<'de> for MaybeIds {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
serde_json::Value::Array(vec) => {
|
serde_json::Value::Array(vec) => {
|
||||||
if vec.len() > MAX_VECS {
|
if vec.len() <= MAX_VECS {
|
||||||
Ok(MaybeIds(sanitize_ids(
|
Ok(MaybeIds(sanitize_ids(
|
||||||
vec.into_iter().map(|s| s.as_str().unwrap().to_string()),
|
vec.into_iter().map(|s| s.as_str().unwrap().to_string()),
|
||||||
)))
|
)))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use schemars::JsonSchema;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, JsonSchema)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, JsonSchema)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum Index {
|
pub enum Index {
|
||||||
#[schemars(description = "Date/day index")]
|
#[schemars(description = "Date/day index")]
|
||||||
DateIndex,
|
DateIndex,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use tabled::Tabled as TabledTabled;
|
|||||||
use crate::Format;
|
use crate::Format;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged, rename_all = "lowercase")]
|
||||||
pub enum Output {
|
pub enum Output {
|
||||||
Json(Value),
|
Json(Value),
|
||||||
CSV(String),
|
CSV(String),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use bitcoincore_rpc::{Auth, Client, Result};
|
use bitcoincore_rpc::{Auth, Client, Result};
|
||||||
use brk_parser::Parser;
|
use brk_parser::{BlockExtended, Parser};
|
||||||
use brk_structs::Height;
|
use brk_structs::Height;
|
||||||
|
|
||||||
#[allow(clippy::needless_doctest_main)]
|
#[allow(clippy::needless_doctest_main)]
|
||||||
@@ -21,55 +21,26 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let parser = Parser::new(bitcoin_dir.join("blocks"), Some(brk_dir), rpc);
|
let parser = Parser::new(bitcoin_dir.join("blocks"), Some(brk_dir), rpc);
|
||||||
|
|
||||||
let start = None;
|
// let start = None;
|
||||||
let end = None;
|
// let end = None;
|
||||||
parser
|
// parser
|
||||||
.parse(start, end)
|
// .parse(start, end)
|
||||||
.iter()
|
// .iter()
|
||||||
.for_each(|(height, _block, hash)| {
|
// .for_each(|(height, _block, hash)| {
|
||||||
println!("{height}: {}", hash);
|
// println!("{height}: {}", hash);
|
||||||
});
|
// });
|
||||||
|
|
||||||
let block_0 = parser.get(Height::new(0));
|
let block_0 = parser.get(Height::new(0));
|
||||||
|
dbg!("{}", block_0.coinbase_tag());
|
||||||
println!(
|
|
||||||
"{}",
|
|
||||||
block_0
|
|
||||||
.txdata
|
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.output
|
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.script_pubkey
|
|
||||||
);
|
|
||||||
|
|
||||||
let block_158251 = parser.get(Height::new(158251));
|
let block_158251 = parser.get(Height::new(158251));
|
||||||
println!(
|
dbg!("{}", block_158251.coinbase_tag());
|
||||||
"{}",
|
|
||||||
block_158251
|
let block_173195 = parser.get(Height::new(173195));
|
||||||
.txdata
|
dbg!("{}", block_173195.coinbase_tag());
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.output
|
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.script_pubkey
|
|
||||||
);
|
|
||||||
|
|
||||||
let block_840_000 = parser.get(Height::new(840_004));
|
let block_840_000 = parser.get(Height::new(840_004));
|
||||||
|
dbg!("{}", block_840_000.coinbase_tag());
|
||||||
println!(
|
|
||||||
"{}",
|
|
||||||
block_840_000
|
|
||||||
.txdata
|
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.output
|
|
||||||
.first()
|
|
||||||
.unwrap()
|
|
||||||
.value
|
|
||||||
);
|
|
||||||
|
|
||||||
dbg!(i.elapsed());
|
dbg!(i.elapsed());
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use bitcoin::Block;
|
use bitcoin::Block;
|
||||||
|
|
||||||
pub trait BlockExtended {
|
pub trait BlockExtended {
|
||||||
fn coinbase_tag(&self) -> String;
|
fn coinbase_tag(&self) -> Cow<'_, str>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockExtended for Block {
|
impl BlockExtended for Block {
|
||||||
fn coinbase_tag(&self) -> String {
|
fn coinbase_tag(&self) -> Cow<'_, str> {
|
||||||
let Some(input) = self.txdata.first().and_then(|tx| tx.input.first()) else {
|
String::from_utf8_lossy(
|
||||||
return String::new();
|
self.txdata
|
||||||
};
|
.first()
|
||||||
let bytes = input.script_sig.as_bytes();
|
.and_then(|tx| tx.input.first())
|
||||||
String::from_utf8_lossy(bytes)
|
.unwrap()
|
||||||
.chars()
|
.script_sig
|
||||||
.filter(|&c| c != '\u{FFFD}' && (c >= ' ' || c == '\n' || c == '\r' || c == '\t'))
|
.as_bytes(),
|
||||||
.take(1_024)
|
)
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ rust-version.workspace = true
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
allocative = { workspace = true }
|
||||||
|
allocative_derive = { workspace = true }
|
||||||
bitcoin = { workspace = true }
|
bitcoin = { workspace = true }
|
||||||
bitcoincore-rpc = { workspace = true }
|
bitcoincore-rpc = { workspace = true }
|
||||||
brk_error = {workspace = true}
|
brk_error = {workspace = true}
|
||||||
|
|||||||
@@ -25,6 +25,25 @@ pub enum AddressBytes {
|
|||||||
P2A(P2ABytes),
|
P2A(P2ABytes),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for AddressBytes {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}",
|
||||||
|
match self {
|
||||||
|
AddressBytes::P2PK65(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2PK33(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2PKH(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2SH(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2WPKH(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2WSH(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2TR(bytes) => bytes.to_string(),
|
||||||
|
AddressBytes::P2A(bytes) => bytes.to_string(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AddressBytes {
|
impl AddressBytes {
|
||||||
pub fn as_slice(&self) -> &[u8] {
|
pub fn as_slice(&self) -> &[u8] {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ impl Serialize for AnyAddressIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum AnyAddressDataIndexEnum {
|
pub enum AnyAddressDataIndexEnum {
|
||||||
Loaded(LoadedAddressIndex),
|
Loaded(LoadedAddressIndex),
|
||||||
Empty(EmptyAddressIndex),
|
Empty(EmptyAddressIndex),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div, Mul},
|
ops::{Add, AddAssign, Div, Mul},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, StoredCompressed};
|
use vecdb::{CheckedSub, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -20,6 +21,7 @@ use super::{Sats, StoredF64};
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct Bitcoin(f64);
|
pub struct Bitcoin(f64);
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ use std::{
|
|||||||
ops::{Add, Rem},
|
ops::{Add, Rem},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use brk_error::Error;
|
use brk_error::Error;
|
||||||
use vecdb::{CheckedSub, FromCoarserIndex, Printable, StoredCompressed};
|
|
||||||
use jiff::Span;
|
use jiff::Span;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use vecdb::{CheckedSub, FromCoarserIndex, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
use crate::{DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, WeekIndex, YearIndex};
|
use crate::{DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, WeekIndex, YearIndex};
|
||||||
@@ -28,6 +29,7 @@ use super::Date;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct DateIndex(u16);
|
pub struct DateIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
use super::{Date, DateIndex, YearIndex};
|
use super::{Date, DateIndex, YearIndex};
|
||||||
@@ -25,6 +26,7 @@ use super::{Date, DateIndex, YearIndex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct DecadeIndex(u16);
|
pub struct DecadeIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -25,6 +26,7 @@ use super::Height;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct DifficultyEpoch(u16);
|
pub struct DifficultyEpoch(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div, Mul},
|
ops::{Add, AddAssign, Div, Mul},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, StoredCompressed};
|
use vecdb::{CheckedSub, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::{Low, Open};
|
||||||
|
|
||||||
use super::{Bitcoin, Cents, Close, High, Sats, StoredF32, StoredF64};
|
use super::{Bitcoin, Cents, Close, High, Sats, StoredF32, StoredF64};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@@ -24,6 +27,7 @@ use super::{Bitcoin, Cents, Close, High, Sats, StoredF32, StoredF64};
|
|||||||
Serialize,
|
Serialize,
|
||||||
Deserialize,
|
Deserialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct Dollars(f64);
|
pub struct Dollars(f64);
|
||||||
|
|
||||||
@@ -78,8 +82,8 @@ impl From<Dollars> for f64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Close<Dollars>> for Dollars {
|
impl From<Open<Dollars>> for Dollars {
|
||||||
fn from(value: Close<Dollars>) -> Self {
|
fn from(value: Open<Dollars>) -> Self {
|
||||||
Self(value.0)
|
Self(value.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,6 +94,18 @@ impl From<High<Dollars>> for Dollars {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Low<Dollars>> for Dollars {
|
||||||
|
fn from(value: Low<Dollars>) -> Self {
|
||||||
|
Self(value.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Close<Dollars>> for Dollars {
|
||||||
|
fn from(value: Close<Dollars>) -> Self {
|
||||||
|
Self(value.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<usize> for Dollars {
|
impl From<usize> for Dollars {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as f64)
|
Self(value as f64)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::StoredCompressed;
|
use vecdb::StoredCompressed;
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -10,7 +11,16 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
use super::{Sats, StoredU64};
|
use super::{Sats, StoredU64};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, Clone, Copy, Serialize, FromBytes, Immutable, IntoBytes, KnownLayout, StoredCompressed,
|
Debug,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Serialize,
|
||||||
|
FromBytes,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct FeeRate(f64);
|
pub struct FeeRate(f64);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -25,6 +26,7 @@ use super::Height;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct HalvingEpoch(u16);
|
pub struct HalvingEpoch(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Rem},
|
ops::{Add, AddAssign, Rem},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use bitcoincore_rpc::{Client, RpcApi};
|
use bitcoincore_rpc::{Client, RpcApi};
|
||||||
use byteview::ByteView;
|
use byteview::ByteView;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
@@ -32,6 +33,7 @@ use super::StoredU64;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct Height(u32);
|
pub struct Height(u32);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign};
|
use std::ops::{Add, AddAssign};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
@@ -24,6 +25,7 @@ use super::Vin;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct InputIndex(u64);
|
pub struct InputIndex(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
use super::{Date, DateIndex, YearIndex};
|
use super::{Date, DateIndex, YearIndex};
|
||||||
@@ -25,6 +26,7 @@ use super::{Date, DateIndex, YearIndex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct MonthIndex(u16);
|
pub struct MonthIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use serde::{Serialize, Serializer, ser::SerializeTuple};
|
use serde::{Serialize, Serializer, ser::SerializeTuple};
|
||||||
use vecdb::StoredCompressed;
|
use vecdb::StoredCompressed;
|
||||||
@@ -473,6 +474,7 @@ where
|
|||||||
DerefMut,
|
DerefMut,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Close<T>(T);
|
pub struct Close<T>(T);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign};
|
use std::ops::{Add, AddAssign};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
@@ -26,6 +27,7 @@ use super::Vout;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct OutputIndex(u64);
|
pub struct OutputIndex(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum OutputType {
|
pub enum OutputType {
|
||||||
P2PK65,
|
P2PK65,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -25,6 +26,7 @@ use super::MonthIndex;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct QuarterIndex(u16);
|
pub struct QuarterIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div, Mul, SubAssign},
|
ops::{Add, AddAssign, Div, Mul, SubAssign},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use bitcoin::Amount;
|
use bitcoin::Amount;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -30,6 +31,7 @@ use super::{Bitcoin, Cents, Dollars, Height};
|
|||||||
Serialize,
|
Serialize,
|
||||||
Deserialize,
|
Deserialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct Sats(u64);
|
pub struct Sats(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -25,6 +26,7 @@ use super::MonthIndex;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct SemesterIndex(u16);
|
pub struct SemesterIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{Printable, StoredCompressed};
|
use vecdb::{Printable, StoredCompressed};
|
||||||
@@ -19,6 +20,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct StoredBool(u16);
|
pub struct StoredBool(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div, Mul, Sub},
|
ops::{Add, AddAssign, Div, Mul, Sub},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::{Close, StoredU32};
|
||||||
|
|
||||||
use super::{Dollars, StoredF64};
|
use super::{Dollars, StoredF64};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@@ -25,6 +28,7 @@ use super::{Dollars, StoredF64};
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct StoredF32(f32);
|
pub struct StoredF32(f32);
|
||||||
|
|
||||||
@@ -65,12 +69,24 @@ impl From<usize> for StoredF32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<StoredU32> for StoredF32 {
|
||||||
|
fn from(value: StoredU32) -> Self {
|
||||||
|
Self(f32::from(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CheckedSub<StoredF32> for StoredF32 {
|
impl CheckedSub<StoredF32> for StoredF32 {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
Some(Self(self.0 - rhs.0))
|
Some(Self(self.0 - rhs.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CheckedSub<usize> for StoredF32 {
|
||||||
|
fn checked_sub(self, rhs: usize) -> Option<Self> {
|
||||||
|
Some(Self(self.0 - rhs as f32))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Div<usize> for StoredF32 {
|
impl Div<usize> for StoredF32 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn div(self, rhs: usize) -> Self::Output {
|
fn div(self, rhs: usize) -> Self::Output {
|
||||||
@@ -78,6 +94,13 @@ impl Div<usize> for StoredF32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Div<StoredU32> for StoredF32 {
|
||||||
|
type Output = Self;
|
||||||
|
fn div(self, rhs: StoredU32) -> Self::Output {
|
||||||
|
Self(self.0 / f32::from(rhs))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Add for StoredF32 {
|
impl Add for StoredF32 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Self) -> Self::Output {
|
fn add(self, rhs: Self) -> Self::Output {
|
||||||
@@ -103,6 +126,12 @@ impl From<Dollars> for StoredF32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Close<Dollars>> for StoredF32 {
|
||||||
|
fn from(value: Close<Dollars>) -> Self {
|
||||||
|
Self::from(*value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Div<Dollars> for StoredF32 {
|
impl Div<Dollars> for StoredF32 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn div(self, rhs: Dollars) -> Self::Output {
|
fn div(self, rhs: Dollars) -> Self::Output {
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
f64,
|
f64,
|
||||||
|
iter::Sum,
|
||||||
ops::{Add, AddAssign, Div, Mul},
|
ops::{Add, AddAssign, Div, Mul},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
@@ -23,6 +25,7 @@ use crate::{Bitcoin, Dollars};
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct StoredF64(f64);
|
pub struct StoredF64(f64);
|
||||||
|
|
||||||
@@ -75,6 +78,13 @@ impl Div<StoredF64> for StoredF64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Div<Dollars> for StoredF64 {
|
||||||
|
type Output = Self;
|
||||||
|
fn div(self, rhs: Dollars) -> Self::Output {
|
||||||
|
Self::from(self.0 / *rhs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Add for StoredF64 {
|
impl Add for StoredF64 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Self) -> Self::Output {
|
fn add(self, rhs: Self) -> Self::Output {
|
||||||
@@ -159,3 +169,9 @@ impl Printable for StoredF64 {
|
|||||||
&["f64"]
|
&["f64"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sum for StoredF64 {
|
||||||
|
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
|
||||||
|
Self(iter.map(|v| v.0).sum::<f64>())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use byteview::ByteView;
|
use byteview::ByteView;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@@ -26,6 +28,12 @@ impl From<String> for StoredString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Cow<'_, str>> for StoredString {
|
||||||
|
fn from(value: Cow<'_, str>) -> Self {
|
||||||
|
Self(value.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<ByteView> for StoredString {
|
impl From<ByteView> for StoredString {
|
||||||
fn from(value: ByteView) -> Self {
|
fn from(value: ByteView) -> Self {
|
||||||
let bytes = &*value;
|
let bytes = &*value;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign, Div};
|
use std::ops::{Add, AddAssign, Div};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
@@ -27,11 +28,13 @@ use super::{
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct StoredU16(u16);
|
pub struct StoredU16(u16);
|
||||||
|
|
||||||
impl StoredU16 {
|
impl StoredU16 {
|
||||||
pub const ZERO: Self = Self(0);
|
pub const ZERO: Self = Self(0);
|
||||||
|
pub const ONE: Self = Self(1);
|
||||||
|
|
||||||
pub fn new(v: u16) -> Self {
|
pub fn new(v: u16) -> Self {
|
||||||
Self(v)
|
Self(v)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign, Div};
|
use std::ops::{Add, AddAssign, Div, Mul};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
@@ -27,15 +28,21 @@ use super::{
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct StoredU32(u32);
|
pub struct StoredU32(u32);
|
||||||
|
|
||||||
impl StoredU32 {
|
impl StoredU32 {
|
||||||
pub const ZERO: Self = Self(0);
|
pub const ZERO: Self = Self(0);
|
||||||
|
pub const ONE: Self = Self(1);
|
||||||
|
|
||||||
pub fn new(counter: u32) -> Self {
|
pub fn new(counter: u32) -> Self {
|
||||||
Self(counter)
|
Self(counter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_zero(&self) -> bool {
|
||||||
|
self.0 == 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u32> for StoredU32 {
|
impl From<u32> for StoredU32 {
|
||||||
@@ -44,6 +51,12 @@ impl From<u32> for StoredU32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<StoredU32> for f32 {
|
||||||
|
fn from(value: StoredU32) -> Self {
|
||||||
|
value.0 as f32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<usize> for StoredU32 {
|
impl From<usize> for StoredU32 {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
if value > u32::MAX as usize {
|
if value > u32::MAX as usize {
|
||||||
@@ -59,6 +72,15 @@ impl CheckedSub<StoredU32> for StoredU32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CheckedSub<usize> for StoredU32 {
|
||||||
|
fn checked_sub(self, rhs: usize) -> Option<Self> {
|
||||||
|
if rhs > u32::MAX as usize {
|
||||||
|
panic!()
|
||||||
|
}
|
||||||
|
self.0.checked_sub(rhs as u32).map(Self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Div<usize> for StoredU32 {
|
impl Div<usize> for StoredU32 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn div(self, rhs: usize) -> Self::Output {
|
fn div(self, rhs: usize) -> Self::Output {
|
||||||
@@ -79,6 +101,17 @@ impl AddAssign for StoredU32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Mul<usize> for StoredU32 {
|
||||||
|
type Output = Self;
|
||||||
|
fn mul(self, rhs: usize) -> Self::Output {
|
||||||
|
let res = self.0 as usize * rhs;
|
||||||
|
if res > u32::MAX as usize {
|
||||||
|
panic!()
|
||||||
|
}
|
||||||
|
Self::from(res)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<f64> for StoredU32 {
|
impl From<f64> for StoredU32 {
|
||||||
fn from(value: f64) -> Self {
|
fn from(value: f64) -> Self {
|
||||||
if value < 0.0 || value > u32::MAX as f64 {
|
if value < 0.0 || value > u32::MAX as f64 {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign, Div};
|
use std::ops::{Add, AddAssign, Div};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
@@ -28,6 +29,7 @@ use super::{
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct StoredU64(u64);
|
pub struct StoredU64(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign, Div};
|
use std::ops::{Add, AddAssign, Div};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use jiff::{civil::date, tz::TimeZone};
|
use jiff::{civil::date, tz::TimeZone};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@@ -23,6 +24,7 @@ use super::Date;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct Timestamp(u32);
|
pub struct Timestamp(u32);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign};
|
use std::ops::{Add, AddAssign};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use byteview::ByteView;
|
use byteview::ByteView;
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@@ -27,6 +28,7 @@ use super::StoredU32;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct TxIndex(u32);
|
pub struct TxIndex(u32);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -25,6 +26,7 @@ use super::{Date, DateIndex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct WeekIndex(u16);
|
pub struct WeekIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::ops::{Add, AddAssign, Div};
|
use std::ops::{Add, AddAssign, Div};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use vecdb::StoredCompressed;
|
use vecdb::StoredCompressed;
|
||||||
@@ -20,6 +21,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
FromBytes,
|
FromBytes,
|
||||||
Serialize,
|
Serialize,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct Weight(u64);
|
pub struct Weight(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use std::{
|
|||||||
ops::{Add, AddAssign, Div},
|
ops::{Add, AddAssign, Div},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use allocative::Allocative;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
@@ -25,6 +26,7 @@ use super::{Date, DateIndex, MonthIndex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
StoredCompressed,
|
StoredCompressed,
|
||||||
|
Allocative,
|
||||||
)]
|
)]
|
||||||
pub struct YearIndex(u16);
|
pub struct YearIndex(u16);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "1.89.0"
|
||||||
@@ -1266,7 +1266,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
text-transform: lowercase;
|
text-transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ export function init({
|
|||||||
case null:
|
case null:
|
||||||
case CANDLE: {
|
case CANDLE: {
|
||||||
series = chart.addCandlestickSeries({
|
series = chart.addCandlestickSeries({
|
||||||
vecId: "ohlc_in_sats",
|
vecId: "price_ohlc_in_sats",
|
||||||
name: "Price",
|
name: "Price",
|
||||||
unit: topUnit,
|
unit: topUnit,
|
||||||
inverse: true,
|
inverse: true,
|
||||||
@@ -378,7 +378,7 @@ export function init({
|
|||||||
}
|
}
|
||||||
case LINE: {
|
case LINE: {
|
||||||
series = chart.addLineSeries({
|
series = chart.addLineSeries({
|
||||||
vecId: "close_in_sats",
|
vecId: "price_close_in_sats",
|
||||||
name: "Price",
|
name: "Price",
|
||||||
unit: topUnit,
|
unit: topUnit,
|
||||||
color: colors.default,
|
color: colors.default,
|
||||||
|
|||||||
+555
-535
File diff suppressed because it is too large
Load Diff
+381
-116
@@ -124,9 +124,10 @@
|
|||||||
* @param {Env} args.env
|
* @param {Env} args.env
|
||||||
* @param {Colors} args.colors
|
* @param {Colors} args.colors
|
||||||
* @param {VecIdToIndexes} args.vecIdToIndexes
|
* @param {VecIdToIndexes} args.vecIdToIndexes
|
||||||
|
* @param {Pools} args.pools
|
||||||
* @returns {PartialOptionsTree}
|
* @returns {PartialOptionsTree}
|
||||||
*/
|
*/
|
||||||
function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
function createPartialOptions({ env, colors, vecIdToIndexes, pools }) {
|
||||||
/**
|
/**
|
||||||
* @template {string} S
|
* @template {string} S
|
||||||
* @typedef {Extract<VecId, `${S}${string}`>} StartsWith
|
* @typedef {Extract<VecId, `${S}${string}`>} StartsWith
|
||||||
@@ -162,18 +163,18 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
* @typedef {"_median"} MedianSuffix
|
* @typedef {"_median"} MedianSuffix
|
||||||
* @typedef {EndsWith<MedianSuffix>} VecIdMedian
|
* @typedef {EndsWith<MedianSuffix>} VecIdMedian
|
||||||
* @typedef {WithoutSuffix<VecIdMedian, MedianSuffix>} VecIdMedianBase
|
* @typedef {WithoutSuffix<VecIdMedian, MedianSuffix>} VecIdMedianBase
|
||||||
* @typedef {"_p90"} _p90Suffix
|
* @typedef {"_pct90"} _pct90Suffix
|
||||||
* @typedef {EndsWith<_p90Suffix>} VecIdp90
|
* @typedef {EndsWith<_pct90Suffix>} VecIdpct90
|
||||||
* @typedef {WithoutSuffix<VecIdp90, _p90Suffix>} VecIdp90Base
|
* @typedef {WithoutSuffix<VecIdpct90, _pct90Suffix>} VecIdpct90Base
|
||||||
* @typedef {"_p75"} _p75Suffix
|
* @typedef {"_pct75"} _pct75Suffix
|
||||||
* @typedef {EndsWith<_p75Suffix>} VecIdp75
|
* @typedef {EndsWith<_pct75Suffix>} VecIdpct75
|
||||||
* @typedef {WithoutSuffix<VecIdp75, _p75Suffix>} VecIdp75Base
|
* @typedef {WithoutSuffix<VecIdpct75, _pct75Suffix>} VecIdpct75Base
|
||||||
* @typedef {"_p25"} _p25Suffix
|
* @typedef {"_pct25"} _pct25Suffix
|
||||||
* @typedef {EndsWith<_p25Suffix>} VecIdp25
|
* @typedef {EndsWith<_pct25Suffix>} VecIdpct25
|
||||||
* @typedef {WithoutSuffix<VecIdp25, _p25Suffix>} VecIdp25Base
|
* @typedef {WithoutSuffix<VecIdpct25, _pct25Suffix>} VecIdpct25Base
|
||||||
* @typedef {"_p10"} _p10Suffix
|
* @typedef {"_pct10"} _pct10Suffix
|
||||||
* @typedef {EndsWith<_p10Suffix>} VecIdp10
|
* @typedef {EndsWith<_pct10Suffix>} VecIdpct10
|
||||||
* @typedef {WithoutSuffix<VecIdp10, _p10Suffix>} VecIdp10Base
|
* @typedef {WithoutSuffix<VecIdpct10, _pct10Suffix>} VecIdpct10Base
|
||||||
* @typedef {"_max"} MaxSuffix
|
* @typedef {"_max"} MaxSuffix
|
||||||
* @typedef {EndsWith<MaxSuffix>} VecIdMax
|
* @typedef {EndsWith<MaxSuffix>} VecIdMax
|
||||||
* @typedef {WithoutSuffix<VecIdMax, MaxSuffix>} VecIdMaxBase
|
* @typedef {WithoutSuffix<VecIdMax, MaxSuffix>} VecIdMaxBase
|
||||||
@@ -1093,7 +1094,10 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
lineStyle,
|
lineStyle,
|
||||||
}) {
|
}) {
|
||||||
return /** @satisfies {FetchedLineSeriesBlueprint} */ ({
|
return /** @satisfies {FetchedLineSeriesBlueprint} */ ({
|
||||||
key: `constant_${number >= 0 ? number : `minus_${Math.abs(number)}`}`,
|
key: `constant_${number >= 0 ? number : `minus_${Math.abs(number)}`}`.replace(
|
||||||
|
".",
|
||||||
|
"_",
|
||||||
|
),
|
||||||
title: name ?? `${number}`,
|
title: name ?? `${number}`,
|
||||||
unit,
|
unit,
|
||||||
defaultActive,
|
defaultActive,
|
||||||
@@ -1228,7 +1232,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} args
|
* @param {Object} args
|
||||||
* @param {VecIdMinBase & VecIdMaxBase & VecIdp90Base & VecIdp75Base & VecIdMedianBase & VecIdp25Base & VecIdp10Base} args.concat
|
* @param {VecIdMinBase & VecIdMaxBase & VecIdpct90Base & VecIdpct75Base & VecIdMedianBase & VecIdpct25Base & VecIdpct10Base} args.concat
|
||||||
* @param {string} [args.title]
|
* @param {string} [args.title]
|
||||||
*/
|
*/
|
||||||
function createMinMaxPercentilesSeries({ concat, title = "" }) {
|
function createMinMaxPercentilesSeries({ concat, title = "" }) {
|
||||||
@@ -1252,26 +1256,26 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
defaultActive: false,
|
defaultActive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: `${concat}_p75`,
|
key: `${concat}_pct75`,
|
||||||
title: `p75 ${title}`,
|
title: `pct75 ${title}`,
|
||||||
color: colors.red,
|
color: colors.red,
|
||||||
defaultActive: false,
|
defaultActive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: `${concat}_p25`,
|
key: `${concat}_pct25`,
|
||||||
title: `p25 ${title}`,
|
title: `pct25 ${title}`,
|
||||||
color: colors.yellow,
|
color: colors.yellow,
|
||||||
defaultActive: false,
|
defaultActive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: `${concat}_p90`,
|
key: `${concat}_pct90`,
|
||||||
title: `p90 ${title}`,
|
title: `pct90 ${title}`,
|
||||||
color: colors.rose,
|
color: colors.rose,
|
||||||
defaultActive: false,
|
defaultActive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: `${concat}_p10`,
|
key: `${concat}_pct10`,
|
||||||
title: `p10 ${title}`,
|
title: `pct10 ${title}`,
|
||||||
color: colors.lime,
|
color: colors.lime,
|
||||||
defaultActive: false,
|
defaultActive: false,
|
||||||
},
|
},
|
||||||
@@ -1279,7 +1283,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecIdp90Base & VecIdp75Base & VecIdMedianBase & VecIdp25Base & VecIdp10Base} key
|
* @param {VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecIdpct90Base & VecIdpct75Base & VecIdMedianBase & VecIdpct25Base & VecIdpct10Base} key
|
||||||
*/
|
*/
|
||||||
function createSumCumulativeMinMaxPercentilesSeries(key) {
|
function createSumCumulativeMinMaxPercentilesSeries(key) {
|
||||||
return [
|
return [
|
||||||
@@ -1289,7 +1293,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecIdp90Base & VecIdp75Base & VecIdMedianBase & VecIdp25Base & VecIdp10Base} key
|
* @param {VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecIdpct90Base & VecIdpct75Base & VecIdMedianBase & VecIdpct25Base & VecIdpct10Base} key
|
||||||
*/
|
*/
|
||||||
function createAverageSumCumulativeMinMaxPercentilesSeries(key) {
|
function createAverageSumCumulativeMinMaxPercentilesSeries(key) {
|
||||||
return [
|
return [
|
||||||
@@ -1300,7 +1304,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} args
|
* @param {Object} args
|
||||||
* @param {VecId & VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecIdp90Base & VecIdp75Base & VecIdMedianBase & VecIdp25Base & VecIdp10Base} args.key
|
* @param {VecId & VecIdAverageBase & CumulativeVecIdBase & VecIdMinBase & VecIdMaxBase & VecIdpct90Base & VecIdpct75Base & VecIdMedianBase & VecIdpct25Base & VecIdpct10Base} args.key
|
||||||
* @param {string} args.name
|
* @param {string} args.name
|
||||||
*/
|
*/
|
||||||
function createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
function createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
||||||
@@ -3148,6 +3152,93 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
{
|
{
|
||||||
name: "Indicators",
|
name: "Indicators",
|
||||||
tree: [
|
tree: [
|
||||||
|
{
|
||||||
|
name: "Volatility",
|
||||||
|
title: "Bitcoin Price Volatility Index",
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: "price_1w_volatility",
|
||||||
|
name: "1w",
|
||||||
|
color: colors.red,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: "price_1m_volatility",
|
||||||
|
name: "1m",
|
||||||
|
color: colors.orange,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: "price_1y_volatility",
|
||||||
|
name: "1y",
|
||||||
|
color: colors.lime,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MinMax",
|
||||||
|
tree: [
|
||||||
|
{
|
||||||
|
key: "1w",
|
||||||
|
title: "1 Week",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "2w",
|
||||||
|
title: "2 Week",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "1m",
|
||||||
|
title: "1 Month",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "1y",
|
||||||
|
title: "1 Year",
|
||||||
|
},
|
||||||
|
].map(({ key, title }) => ({
|
||||||
|
name: key,
|
||||||
|
title: `Bitcoin Price ${title} MinMax Bands`,
|
||||||
|
top: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: `price_${key}_min`,
|
||||||
|
name: "min",
|
||||||
|
color: colors.red,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `price_${key}_max`,
|
||||||
|
name: "max",
|
||||||
|
color: colors.green,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "True range",
|
||||||
|
title: "Bitcoin Price True Range",
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: "price_true_range",
|
||||||
|
name: "value",
|
||||||
|
color: colors.yellow,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Choppiness",
|
||||||
|
title: "Bitcoin Price Choppiness Index",
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: "price_2w_choppiness_index",
|
||||||
|
name: "2w",
|
||||||
|
color: colors.red,
|
||||||
|
}),
|
||||||
|
createPriceLine({
|
||||||
|
unit: "Index",
|
||||||
|
number: 61.8,
|
||||||
|
}),
|
||||||
|
createPriceLine({
|
||||||
|
unit: "Index",
|
||||||
|
number: 38.2,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Mayer multiple",
|
name: "Mayer multiple",
|
||||||
title: "Mayer multiple",
|
title: "Mayer multiple",
|
||||||
@@ -3343,6 +3434,24 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
lineStyle: 4,
|
lineStyle: 4,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: "1w_block_count",
|
||||||
|
name: "1w sum",
|
||||||
|
color: colors.red,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: "1m_block_count",
|
||||||
|
name: "1m sum",
|
||||||
|
color: colors.pink,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: "1y_block_count",
|
||||||
|
name: "1y sum",
|
||||||
|
color: colors.purple,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3521,87 +3630,116 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Coinbase",
|
name: "Rewards",
|
||||||
title: "Coinbase",
|
tree: [
|
||||||
bottom: [
|
{
|
||||||
...createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
|
||||||
key: "coinbase",
|
|
||||||
name: "Coinbase",
|
name: "Coinbase",
|
||||||
}),
|
title: "Coinbase",
|
||||||
...createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
bottom: [
|
||||||
key: "coinbase_in_btc",
|
...createBaseAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
name: "Coinbase",
|
{
|
||||||
}),
|
key: "coinbase",
|
||||||
...createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
name: "Coinbase",
|
||||||
key: "coinbase_in_usd",
|
},
|
||||||
name: "Coinbase",
|
),
|
||||||
}),
|
...createBaseAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
],
|
{
|
||||||
},
|
key: "coinbase_in_btc",
|
||||||
{
|
name: "Coinbase",
|
||||||
name: "Subsidy",
|
},
|
||||||
title: "Subsidy",
|
),
|
||||||
bottom: [
|
...createBaseAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
...createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
{
|
||||||
key: "subsidy",
|
key: "coinbase_in_usd",
|
||||||
|
name: "Coinbase",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
name: "Subsidy",
|
name: "Subsidy",
|
||||||
}),
|
title: "Subsidy",
|
||||||
createBaseSeries({
|
bottom: [
|
||||||
key: "subsidy_usd_1y_sma",
|
...createBaseAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
name: "1y sma",
|
{
|
||||||
}),
|
key: "subsidy",
|
||||||
...createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
name: "Subsidy",
|
||||||
key: "subsidy_in_btc",
|
},
|
||||||
name: "Subsidy",
|
),
|
||||||
}),
|
createBaseSeries({
|
||||||
...createBaseAverageSumCumulativeMinMaxPercentilesSeries({
|
key: "subsidy_usd_1y_sma",
|
||||||
key: "subsidy_in_usd",
|
name: "1y sma",
|
||||||
name: "Subsidy",
|
}),
|
||||||
}),
|
...createBaseAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
],
|
{
|
||||||
},
|
key: "subsidy_in_btc",
|
||||||
{
|
name: "Subsidy",
|
||||||
name: "Fee",
|
},
|
||||||
title: "Transaction Fee",
|
),
|
||||||
bottom: [
|
...createBaseAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
...createAverageSumCumulativeMinMaxPercentilesSeries("fee"),
|
{
|
||||||
...createAverageSumCumulativeMinMaxPercentilesSeries(
|
key: "subsidy_in_usd",
|
||||||
"fee_in_btc",
|
name: "Subsidy",
|
||||||
),
|
},
|
||||||
...createAverageSumCumulativeMinMaxPercentilesSeries(
|
),
|
||||||
"fee_in_usd",
|
],
|
||||||
),
|
},
|
||||||
],
|
{
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Dominance",
|
|
||||||
title: "Reward Dominance",
|
|
||||||
bottom: [
|
|
||||||
createBaseSeries({
|
|
||||||
key: "fee_dominance",
|
|
||||||
name: "Fee",
|
name: "Fee",
|
||||||
color: colors.amber,
|
title: "Transaction Fee",
|
||||||
}),
|
bottom: [
|
||||||
createBaseSeries({
|
...createAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
key: "subsidy_dominance",
|
"fee",
|
||||||
name: "Subsidy",
|
),
|
||||||
color: colors.red,
|
...createAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
}),
|
"fee_in_btc",
|
||||||
],
|
),
|
||||||
},
|
...createAverageSumCumulativeMinMaxPercentilesSeries(
|
||||||
{
|
"fee_in_usd",
|
||||||
name: "Unclaimed Rewards",
|
),
|
||||||
title: "Unclaimed Rewards",
|
],
|
||||||
bottom: [
|
},
|
||||||
...createSumCumulativeSeries({
|
{
|
||||||
concat: "unclaimed_rewards",
|
name: "Dominance",
|
||||||
}),
|
title: "Reward Dominance",
|
||||||
...createSumCumulativeSeries({
|
bottom: [
|
||||||
concat: "unclaimed_rewards_in_btc",
|
createBaseSeries({
|
||||||
}),
|
key: "fee_dominance",
|
||||||
...createSumCumulativeSeries({
|
name: "Fee",
|
||||||
concat: "unclaimed_rewards_in_usd",
|
color: colors.amber,
|
||||||
}),
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: "subsidy_dominance",
|
||||||
|
name: "Subsidy",
|
||||||
|
color: colors.red,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Unclaimed",
|
||||||
|
title: "Unclaimed Rewards",
|
||||||
|
bottom: [
|
||||||
|
...createSumCumulativeSeries({
|
||||||
|
concat: "unclaimed_rewards",
|
||||||
|
}),
|
||||||
|
...createSumCumulativeSeries({
|
||||||
|
concat: "unclaimed_rewards_in_btc",
|
||||||
|
}),
|
||||||
|
...createSumCumulativeSeries({
|
||||||
|
concat: "unclaimed_rewards_in_usd",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Puell multiple",
|
||||||
|
title: "Puell multiple",
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: "puell_multiple",
|
||||||
|
name: "Multiple",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3614,16 +3752,6 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Puell multiple",
|
|
||||||
title: "Puell multiple",
|
|
||||||
bottom: [
|
|
||||||
createBaseSeries({
|
|
||||||
key: "puell_multiple",
|
|
||||||
name: "Multiple",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Difficulty",
|
name: "Difficulty",
|
||||||
title: "Difficulty",
|
title: "Difficulty",
|
||||||
@@ -3695,6 +3823,136 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Pools",
|
||||||
|
tree: Object.entries(pools).map(([_key, name]) => {
|
||||||
|
const key = /** @type {Pool} */ (_key);
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
tree: [
|
||||||
|
{
|
||||||
|
name: "Dominance",
|
||||||
|
title: `Mining Dominance of ${name}`,
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1d_dominance`,
|
||||||
|
name: "1d",
|
||||||
|
color: colors.rose,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1w_dominance`,
|
||||||
|
name: "1w",
|
||||||
|
color: colors.red,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1m_dominance`,
|
||||||
|
name: "1m",
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1y_dominance`,
|
||||||
|
name: "1y",
|
||||||
|
color: colors.lime,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_dominance`,
|
||||||
|
name: "all time",
|
||||||
|
color: colors.teal,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Blocks mined",
|
||||||
|
title: `Blocks mined by ${name}`,
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_blocks_mined`,
|
||||||
|
name: "Sum",
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_blocks_mined_cumulative`,
|
||||||
|
name: "Cumulative",
|
||||||
|
color: colors.blue,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1w_blocks_mined`,
|
||||||
|
name: "1w Sum",
|
||||||
|
color: colors.red,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1m_blocks_mined`,
|
||||||
|
name: "1m Sum",
|
||||||
|
color: colors.pink,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_1y_blocks_mined`,
|
||||||
|
name: "1y Sum",
|
||||||
|
color: colors.purple,
|
||||||
|
defaultActive: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Rewards",
|
||||||
|
title: `Rewards collected by ${name}`,
|
||||||
|
bottom: [
|
||||||
|
{
|
||||||
|
keyAddon: "coinbase",
|
||||||
|
cumulativeColor: colors.red,
|
||||||
|
sumColor: colors.orange,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
keyAddon: "subsidy",
|
||||||
|
cumulativeColor: colors.emerald,
|
||||||
|
sumColor: colors.lime,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
keyAddon: "fee",
|
||||||
|
cumulativeColor: colors.indigo,
|
||||||
|
sumColor: colors.cyan,
|
||||||
|
},
|
||||||
|
].flatMap(
|
||||||
|
({ keyAddon, sumColor, cumulativeColor }) => [
|
||||||
|
...createSumCumulativeSeries({
|
||||||
|
concat: `${key}_${keyAddon}`,
|
||||||
|
common: keyAddon,
|
||||||
|
sumColor,
|
||||||
|
cumulativeColor,
|
||||||
|
}),
|
||||||
|
...createSumCumulativeSeries({
|
||||||
|
concat: `${key}_${keyAddon}_in_btc`,
|
||||||
|
common: keyAddon,
|
||||||
|
sumColor,
|
||||||
|
cumulativeColor,
|
||||||
|
}),
|
||||||
|
...createSumCumulativeSeries({
|
||||||
|
concat: `${key}_${keyAddon}_in_usd`,
|
||||||
|
common: keyAddon,
|
||||||
|
sumColor,
|
||||||
|
cumulativeColor,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Days since block",
|
||||||
|
title: `Days since ${name} mined a block`,
|
||||||
|
bottom: [
|
||||||
|
createBaseSeries({
|
||||||
|
key: `${key}_days_since_block`,
|
||||||
|
name: "Since block",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -4184,6 +4442,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
|||||||
* @param {Env} args.env
|
* @param {Env} args.env
|
||||||
* @param {Utilities} args.utils
|
* @param {Utilities} args.utils
|
||||||
* @param {VecIdToIndexes} args.vecIdToIndexes
|
* @param {VecIdToIndexes} args.vecIdToIndexes
|
||||||
|
* @param {Pools} args.pools
|
||||||
* @param {Signal<string | null>} args.qrcode
|
* @param {Signal<string | null>} args.qrcode
|
||||||
*/
|
*/
|
||||||
export function initOptions({
|
export function initOptions({
|
||||||
@@ -4193,8 +4452,9 @@ export function initOptions({
|
|||||||
utils,
|
utils,
|
||||||
qrcode,
|
qrcode,
|
||||||
vecIdToIndexes,
|
vecIdToIndexes,
|
||||||
|
pools,
|
||||||
}) {
|
}) {
|
||||||
const LS_SELECTED_KEY = `selected_id`;
|
const LS_SELECTED_KEY = `selected_path`;
|
||||||
|
|
||||||
const urlPath_ = window.document.location.pathname
|
const urlPath_ = window.document.location.pathname
|
||||||
.split("/")
|
.split("/")
|
||||||
@@ -4208,7 +4468,12 @@ export function initOptions({
|
|||||||
/** @type {Signal<Option>} */
|
/** @type {Signal<Option>} */
|
||||||
const selected = signals.createSignal(/** @type {any} */ (undefined));
|
const selected = signals.createSignal(/** @type {any} */ (undefined));
|
||||||
|
|
||||||
const partialOptions = createPartialOptions({ env, colors, vecIdToIndexes });
|
const partialOptions = createPartialOptions({
|
||||||
|
env,
|
||||||
|
colors,
|
||||||
|
vecIdToIndexes,
|
||||||
|
pools,
|
||||||
|
});
|
||||||
|
|
||||||
/** @type {Option[]} */
|
/** @type {Option[]} */
|
||||||
const list = [];
|
const list = [];
|
||||||
|
|||||||
@@ -515,12 +515,17 @@ function createIndexToVecIds(vecIdToIndexes) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} args
|
* @param {Object} args
|
||||||
* @param {number | OHLCTuple} args.value
|
* @param {number | string | Object | Array<any>} args.value
|
||||||
* @param {Unit} args.unit
|
* @param {Unit} args.unit
|
||||||
*/
|
*/
|
||||||
function serializeValue({ value, unit }) {
|
function serializeValue({ value, unit }) {
|
||||||
if (typeof value !== "number") {
|
const t = typeof value;
|
||||||
return JSON.stringify(value);
|
if (value === null) {
|
||||||
|
return "null";
|
||||||
|
} else if (typeof value === "string") {
|
||||||
|
return value;
|
||||||
|
} else if (t !== "number") {
|
||||||
|
return JSON.stringify(value).replaceAll('"', "").slice(1, -1);
|
||||||
} else if (value !== 18446744073709552000) {
|
} else if (value !== 18446744073709552000) {
|
||||||
if (unit === "USD" || unit === "Difficulty" || unit === "sat/vB") {
|
if (unit === "USD" || unit === "Difficulty" || unit === "sat/vB") {
|
||||||
return value.toLocaleString("en-us", {
|
return value.toLocaleString("en-us", {
|
||||||
|
|||||||
Reference in New Issue
Block a user