mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-14 20:58:36 -07:00
global: renames + refactor + p2a support
This commit is contained in:
77
Cargo.lock
generated
77
Cargo.lock
generated
@@ -34,6 +34,19 @@ dependencies = [
|
|||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ahash"
|
||||||
|
version = "0.8.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"getrandom 0.2.16",
|
||||||
|
"once_cell",
|
||||||
|
"version_check",
|
||||||
|
"zerocopy 0.7.35",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "1.1.3"
|
version = "1.1.3"
|
||||||
@@ -440,7 +453,7 @@ dependencies = [
|
|||||||
"rlimit",
|
"rlimit",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -481,7 +494,7 @@ dependencies = [
|
|||||||
"fjall",
|
"fjall",
|
||||||
"log",
|
"log",
|
||||||
"rayon",
|
"rayon",
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -506,7 +519,7 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -561,7 +574,7 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
"zstd",
|
"zstd",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -649,9 +662,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.19"
|
version = "1.2.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
|
checksum = "04da6a0d40b948dfc4fa8f5bbf402b0fc1a64a28dbf7d12ffd683550f2c1b63a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -2134,12 +2147,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "papergrid"
|
name = "papergrid"
|
||||||
version = "0.14.0"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b915f831b85d984193fdc3d3611505871dc139b2534530fa01c1a6a6707b6723"
|
checksum = "30268a8d20c2c0d126b2b6610ab405f16517f6ba9f244d8c59ac2c512a8a1ce7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ahash",
|
||||||
"bytecount",
|
"bytecount",
|
||||||
"fnv",
|
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2299,7 +2312,7 @@ version = "0.2.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2820,19 +2833,20 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tabled"
|
name = "tabled"
|
||||||
version = "0.18.0"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "121d8171ee5687a4978d1b244f7d99c43e7385a272185a2f1e1fa4dc0979d444"
|
checksum = "228d124371171cd39f0f454b58f73ddebeeef3cef3207a82ffea1c29465aea43"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"papergrid",
|
"papergrid",
|
||||||
"tabled_derive",
|
"tabled_derive",
|
||||||
|
"testing_table",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tabled_derive"
|
name = "tabled_derive"
|
||||||
version = "0.10.0"
|
version = "0.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52d9946811baad81710ec921809e2af67ad77719418673b2a3794932d57b7538"
|
checksum = "0ea5d1b13ca6cff1f9231ffd62f15eefd72543dab5e468735f1a456728a02846"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro-error2",
|
"proc-macro-error2",
|
||||||
@@ -2854,6 +2868,15 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "testing_table"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0f8daae29995a24f65619e19d8d31dea5b389f3d853d8bf297bbf607cd0014cc"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.16.2"
|
version = "0.16.2"
|
||||||
@@ -3409,9 +3432,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.7.6"
|
version = "0.7.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10"
|
checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
@@ -3440,13 +3463,33 @@ dependencies = [
|
|||||||
"lzma-sys",
|
"lzma-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.7.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive 0.7.35",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.24"
|
version = "0.8.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive 0.8.24",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.7.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.100",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ minreq = { version = "2.13.4", features = ["https", "serde_json"] }
|
|||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.140", features = ["float_roundtrip"] }
|
serde_json = { version = "1.0.140", features = ["float_roundtrip"] }
|
||||||
tabled = "0.18.0"
|
tabled = "0.19.0"
|
||||||
zerocopy = { version = "0.8.24", features = ["derive"] }
|
zerocopy = { version = "0.8.24", features = ["derive"] }
|
||||||
|
|
||||||
[workspace.metadata.release]
|
[workspace.metadata.release]
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_core::{AddressindexTxoutindex, Unit};
|
|
||||||
use brk_indexer::Store;
|
|
||||||
use brk_vec::Version;
|
|
||||||
use fjall::TransactionalKeyspace;
|
use fjall::TransactionalKeyspace;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Stores {
|
pub struct Stores {
|
||||||
pub address_to_utxos_received: Store<AddressindexTxoutindex, Unit>,
|
// pub address_to_utxos_received: Store<AddressIndexOutputIndex, Unit>,
|
||||||
pub address_to_utxos_spent: Store<AddressindexTxoutindex, Unit>,
|
// pub address_to_utxos_spent: Store<AddressIndexOutputIndex, Unit>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stores {
|
impl Stores {
|
||||||
pub fn import(path: &Path, keyspace: &TransactionalKeyspace) -> color_eyre::Result<Self> {
|
pub fn import(_: &Path, _: &TransactionalKeyspace) -> color_eyre::Result<Self> {
|
||||||
let address_to_utxos_received = Store::import(
|
// let address_to_utxos_received = Store::import(
|
||||||
keyspace.clone(),
|
// keyspace.clone(),
|
||||||
path,
|
// path,
|
||||||
"address_to_utxos_received",
|
// "address_to_utxos_received",
|
||||||
Version::ZERO,
|
// Version::ZERO,
|
||||||
)?;
|
// )?;
|
||||||
let address_to_utxos_spent = Store::import(
|
// let address_to_utxos_spent = Store::import(
|
||||||
keyspace.clone(),
|
// keyspace.clone(),
|
||||||
path,
|
// path,
|
||||||
"address_to_utxos_spent",
|
// "address_to_utxos_spent",
|
||||||
Version::ZERO,
|
// Version::ZERO,
|
||||||
)?;
|
// )?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
address_to_utxos_received,
|
// address_to_utxos_received,
|
||||||
address_to_utxos_spent,
|
// address_to_utxos_spent,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_core::{Dateindex, Decadeindex, Monthindex, Quarterindex, Weekindex, Yearindex};
|
use brk_core::{DateIndex, DecadeIndex, MonthIndex, QuarterIndex, WeekIndex, YearIndex};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
|
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
|
||||||
@@ -14,13 +14,13 @@ pub struct ComputedVecsFromDateindex<T>
|
|||||||
where
|
where
|
||||||
T: ComputedType + PartialOrd,
|
T: ComputedType + PartialOrd,
|
||||||
{
|
{
|
||||||
pub dateindex: EagerVec<Dateindex, T>,
|
pub dateindex: EagerVec<DateIndex, T>,
|
||||||
pub dateindex_extra: ComputedVecBuilder<Dateindex, T>,
|
pub dateindex_extra: ComputedVecBuilder<DateIndex, T>,
|
||||||
pub weekindex: ComputedVecBuilder<Weekindex, T>,
|
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
|
||||||
pub monthindex: ComputedVecBuilder<Monthindex, T>,
|
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
|
||||||
pub quarterindex: ComputedVecBuilder<Quarterindex, T>,
|
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
|
||||||
pub yearindex: ComputedVecBuilder<Yearindex, T>,
|
pub yearindex: ComputedVecBuilder<YearIndex, T>,
|
||||||
pub decadeindex: ComputedVecBuilder<Decadeindex, T>,
|
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
const VERSION: Version = Version::ZERO;
|
||||||
@@ -79,7 +79,7 @@ where
|
|||||||
) -> color_eyre::Result<()>
|
) -> color_eyre::Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(
|
F: FnMut(
|
||||||
&mut EagerVec<Dateindex, T>,
|
&mut EagerVec<DateIndex, T>,
|
||||||
&mut Indexer,
|
&mut Indexer,
|
||||||
&mut indexes::Vecs,
|
&mut indexes::Vecs,
|
||||||
&Indexes,
|
&Indexes,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
Dateindex, Decadeindex, Difficultyepoch, Height, Monthindex, Quarterindex, Weekindex, Yearindex,
|
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex,
|
||||||
};
|
};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -18,14 +18,14 @@ where
|
|||||||
{
|
{
|
||||||
pub height: Option<EagerVec<Height, T>>,
|
pub height: Option<EagerVec<Height, T>>,
|
||||||
pub height_extra: ComputedVecBuilder<Height, T>,
|
pub height_extra: ComputedVecBuilder<Height, T>,
|
||||||
pub dateindex: ComputedVecBuilder<Dateindex, T>,
|
pub dateindex: ComputedVecBuilder<DateIndex, T>,
|
||||||
pub weekindex: ComputedVecBuilder<Weekindex, T>,
|
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
|
||||||
pub difficultyepoch: ComputedVecBuilder<Difficultyepoch, T>,
|
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
|
||||||
pub monthindex: ComputedVecBuilder<Monthindex, T>,
|
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
|
||||||
pub quarterindex: ComputedVecBuilder<Quarterindex, T>,
|
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
|
||||||
pub yearindex: ComputedVecBuilder<Yearindex, T>,
|
pub yearindex: ComputedVecBuilder<YearIndex, T>,
|
||||||
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
||||||
pub decadeindex: ComputedVecBuilder<Decadeindex, T>,
|
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
const VERSION: Version = Version::ZERO;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_core::{Difficultyepoch, Height};
|
use brk_core::{DifficultyEpoch, Height};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
|
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
|
||||||
@@ -16,7 +16,7 @@ where
|
|||||||
{
|
{
|
||||||
pub height: EagerVec<Height, T>,
|
pub height: EagerVec<Height, T>,
|
||||||
pub height_extra: ComputedVecBuilder<Height, T>,
|
pub height_extra: ComputedVecBuilder<Height, T>,
|
||||||
pub difficultyepoch: ComputedVecBuilder<Difficultyepoch, T>,
|
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
|
||||||
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
Dateindex, Decadeindex, Difficultyepoch, Height, Monthindex, Quarterindex, Txindex, Weekindex,
|
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, TxIndex, WeekIndex,
|
||||||
Yearindex,
|
YearIndex,
|
||||||
};
|
};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -17,16 +17,16 @@ pub struct ComputedVecsFromTxindex<T>
|
|||||||
where
|
where
|
||||||
T: ComputedType + PartialOrd,
|
T: ComputedType + PartialOrd,
|
||||||
{
|
{
|
||||||
pub txindex: Option<EagerVec<Txindex, T>>,
|
pub txindex: Option<EagerVec<TxIndex, T>>,
|
||||||
pub height: ComputedVecBuilder<Height, T>,
|
pub height: ComputedVecBuilder<Height, T>,
|
||||||
pub dateindex: ComputedVecBuilder<Dateindex, T>,
|
pub dateindex: ComputedVecBuilder<DateIndex, T>,
|
||||||
pub weekindex: ComputedVecBuilder<Weekindex, T>,
|
pub weekindex: ComputedVecBuilder<WeekIndex, T>,
|
||||||
pub difficultyepoch: ComputedVecBuilder<Difficultyepoch, T>,
|
pub difficultyepoch: ComputedVecBuilder<DifficultyEpoch, T>,
|
||||||
pub monthindex: ComputedVecBuilder<Monthindex, T>,
|
pub monthindex: ComputedVecBuilder<MonthIndex, T>,
|
||||||
pub quarterindex: ComputedVecBuilder<Quarterindex, T>,
|
pub quarterindex: ComputedVecBuilder<QuarterIndex, T>,
|
||||||
pub yearindex: ComputedVecBuilder<Yearindex, T>,
|
pub yearindex: ComputedVecBuilder<YearIndex, T>,
|
||||||
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
// TODO: pub halvingepoch: StorableVecGeneator<Halvingepoch, T>,
|
||||||
pub decadeindex: ComputedVecBuilder<Decadeindex, T>,
|
pub decadeindex: ComputedVecBuilder<DecadeIndex, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
const VERSION: Version = Version::ZERO;
|
||||||
@@ -91,7 +91,7 @@ where
|
|||||||
) -> color_eyre::Result<()>
|
) -> color_eyre::Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(
|
F: FnMut(
|
||||||
&mut EagerVec<Txindex, T>,
|
&mut EagerVec<TxIndex, T>,
|
||||||
&mut Indexer,
|
&mut Indexer,
|
||||||
&mut indexes::Vecs,
|
&mut indexes::Vecs,
|
||||||
&Indexes,
|
&Indexes,
|
||||||
@@ -117,7 +117,7 @@ where
|
|||||||
indexes: &mut indexes::Vecs,
|
indexes: &mut indexes::Vecs,
|
||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
txindex: Option<&mut StoredVec<Txindex, T>>,
|
txindex: Option<&mut StoredVec<TxIndex, T>>,
|
||||||
) -> color_eyre::Result<()> {
|
) -> color_eyre::Result<()> {
|
||||||
let txindex = txindex.unwrap_or_else(|| self.txindex.as_mut().unwrap().mut_vec());
|
let txindex = txindex.unwrap_or_else(|| self.txindex.as_mut().unwrap().mut_vec());
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use brk_core::{Bitcoin, Dollars, Sats, Txindex};
|
use brk_core::{Bitcoin, Dollars, Sats, TxIndex};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_vec::{AnyStoredVec, Compressed, Result, StoredVec, Version};
|
use brk_vec::{AnyStoredVec, Compressed, Result, StoredVec, Version};
|
||||||
@@ -73,7 +73,7 @@ impl ComputedValueVecsFromTxindex {
|
|||||||
) -> color_eyre::Result<()>
|
) -> color_eyre::Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(
|
F: FnMut(
|
||||||
&mut EagerVec<Txindex, Sats>,
|
&mut EagerVec<TxIndex, Sats>,
|
||||||
&mut Indexer,
|
&mut Indexer,
|
||||||
&mut indexes::Vecs,
|
&mut indexes::Vecs,
|
||||||
&Indexes,
|
&Indexes,
|
||||||
@@ -100,7 +100,7 @@ impl ComputedValueVecsFromTxindex {
|
|||||||
marketprices: &mut Option<&mut marketprice::Vecs>,
|
marketprices: &mut Option<&mut marketprice::Vecs>,
|
||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
mut txindex: Option<&mut StoredVec<Txindex, Sats>>,
|
mut txindex: Option<&mut StoredVec<TxIndex, Sats>>,
|
||||||
) -> color_eyre::Result<()> {
|
) -> color_eyre::Result<()> {
|
||||||
if let Some(txindex) = txindex.as_mut() {
|
if let Some(txindex) = txindex.as_mut() {
|
||||||
self.sats
|
self.sats
|
||||||
@@ -136,11 +136,11 @@ impl ComputedValueVecsFromTxindex {
|
|||||||
indexes,
|
indexes,
|
||||||
starting_indexes,
|
starting_indexes,
|
||||||
exit,
|
exit,
|
||||||
|v, indexer, _, starting_indexes, exit| {
|
|v, _, indexes, starting_indexes, exit| {
|
||||||
v.compute_from_bitcoin(
|
v.compute_from_bitcoin(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
txindex,
|
txindex,
|
||||||
indexer.mut_vecs().txindex_to_height.mut_vec(),
|
indexes.txindex_to_height.mut_vec(),
|
||||||
price,
|
price,
|
||||||
exit,
|
exit,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use std::{fs, ops::Deref, path::Path};
|
use std::{fs, ops::Deref, path::Path};
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
Addressindex, Date, Dateindex, Decadeindex, Difficultyepoch, Emptyindex, Halvingepoch, Height,
|
Date, DateIndex, DecadeIndex, DifficultyEpoch, EmptyOutputIndex, HalvingEpoch, Height,
|
||||||
Monthindex, Multisigindex, Opreturnindex, P2PK33index, P2PK65index, P2PKHindex, P2SHindex,
|
InputIndex, MonthIndex, OpReturnIndex, OutputIndex, P2AIndex, P2MSIndex, P2PK33Index,
|
||||||
P2TRindex, P2WPKHindex, P2WSHindex, Pushonlyindex, Quarterindex, Timestamp, Txindex, Txinindex,
|
P2PK65Index, P2PKHIndex, P2SHIndex, P2TRIndex, P2WPKHIndex, P2WSHIndex, QuarterIndex,
|
||||||
Txoutindex, Unknownindex, Weekindex, Yearindex,
|
Timestamp, TxIndex, UnknownOutputIndex, WeekIndex, YearIndex,
|
||||||
};
|
};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -14,70 +14,70 @@ use super::EagerVec;
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Vecs {
|
pub struct Vecs {
|
||||||
pub addressindex_to_addressindex: EagerVec<Addressindex, Addressindex>,
|
pub dateindex_to_date: EagerVec<DateIndex, Date>,
|
||||||
pub dateindex_to_date: EagerVec<Dateindex, Date>,
|
pub dateindex_to_dateindex: EagerVec<DateIndex, DateIndex>,
|
||||||
pub dateindex_to_dateindex: EagerVec<Dateindex, Dateindex>,
|
pub dateindex_to_first_height: EagerVec<DateIndex, Height>,
|
||||||
pub dateindex_to_first_height: EagerVec<Dateindex, Height>,
|
pub dateindex_to_last_height: EagerVec<DateIndex, Height>,
|
||||||
pub dateindex_to_last_height: EagerVec<Dateindex, Height>,
|
pub dateindex_to_monthindex: EagerVec<DateIndex, MonthIndex>,
|
||||||
pub dateindex_to_monthindex: EagerVec<Dateindex, Monthindex>,
|
pub dateindex_to_timestamp: EagerVec<DateIndex, Timestamp>,
|
||||||
pub dateindex_to_timestamp: EagerVec<Dateindex, Timestamp>,
|
pub dateindex_to_weekindex: EagerVec<DateIndex, WeekIndex>,
|
||||||
pub dateindex_to_weekindex: EagerVec<Dateindex, Weekindex>,
|
pub decadeindex_to_decadeindex: EagerVec<DecadeIndex, DecadeIndex>,
|
||||||
pub decadeindex_to_decadeindex: EagerVec<Decadeindex, Decadeindex>,
|
pub decadeindex_to_first_yearindex: EagerVec<DecadeIndex, YearIndex>,
|
||||||
pub decadeindex_to_first_yearindex: EagerVec<Decadeindex, Yearindex>,
|
pub decadeindex_to_last_yearindex: EagerVec<DecadeIndex, YearIndex>,
|
||||||
pub decadeindex_to_last_yearindex: EagerVec<Decadeindex, Yearindex>,
|
pub decadeindex_to_timestamp: EagerVec<DecadeIndex, Timestamp>,
|
||||||
pub decadeindex_to_timestamp: EagerVec<Decadeindex, Timestamp>,
|
pub difficultyepoch_to_difficultyepoch: EagerVec<DifficultyEpoch, DifficultyEpoch>,
|
||||||
pub difficultyepoch_to_difficultyepoch: EagerVec<Difficultyepoch, Difficultyepoch>,
|
pub difficultyepoch_to_first_height: EagerVec<DifficultyEpoch, Height>,
|
||||||
pub difficultyepoch_to_first_height: EagerVec<Difficultyepoch, Height>,
|
pub difficultyepoch_to_last_height: EagerVec<DifficultyEpoch, Height>,
|
||||||
pub difficultyepoch_to_last_height: EagerVec<Difficultyepoch, Height>,
|
pub difficultyepoch_to_timestamp: EagerVec<DifficultyEpoch, Timestamp>,
|
||||||
pub difficultyepoch_to_timestamp: EagerVec<Difficultyepoch, Timestamp>,
|
pub emptyoutputindex_to_emptyoutputindex: EagerVec<EmptyOutputIndex, EmptyOutputIndex>,
|
||||||
pub emptyindex_to_emptyindex: EagerVec<Emptyindex, Emptyindex>,
|
pub halvingepoch_to_first_height: EagerVec<HalvingEpoch, Height>,
|
||||||
pub halvingepoch_to_first_height: EagerVec<Halvingepoch, Height>,
|
pub halvingepoch_to_halvingepoch: EagerVec<HalvingEpoch, HalvingEpoch>,
|
||||||
pub halvingepoch_to_halvingepoch: EagerVec<Halvingepoch, Halvingepoch>,
|
pub halvingepoch_to_last_height: EagerVec<HalvingEpoch, Height>,
|
||||||
pub halvingepoch_to_last_height: EagerVec<Halvingepoch, Height>,
|
pub halvingepoch_to_timestamp: EagerVec<HalvingEpoch, Timestamp>,
|
||||||
pub halvingepoch_to_timestamp: EagerVec<Halvingepoch, Timestamp>,
|
pub height_to_date: EagerVec<Height, Date>,
|
||||||
pub height_to_dateindex: EagerVec<Height, Dateindex>,
|
pub height_to_date_fixed: EagerVec<Height, Date>,
|
||||||
pub height_to_difficultyepoch: EagerVec<Height, Difficultyepoch>,
|
pub height_to_dateindex: EagerVec<Height, DateIndex>,
|
||||||
pub height_to_fixed_date: EagerVec<Height, Date>,
|
pub height_to_difficultyepoch: EagerVec<Height, DifficultyEpoch>,
|
||||||
pub height_to_fixed_timestamp: EagerVec<Height, Timestamp>,
|
pub height_to_halvingepoch: EagerVec<Height, HalvingEpoch>,
|
||||||
pub height_to_halvingepoch: EagerVec<Height, Halvingepoch>,
|
|
||||||
pub height_to_height: EagerVec<Height, Height>,
|
pub height_to_height: EagerVec<Height, Height>,
|
||||||
pub height_to_last_txindex: EagerVec<Height, Txindex>,
|
pub height_to_last_txindex: EagerVec<Height, TxIndex>,
|
||||||
pub height_to_real_date: EagerVec<Height, Date>,
|
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
|
||||||
pub monthindex_to_first_dateindex: EagerVec<Monthindex, Dateindex>,
|
pub inputindex_to_inputindex: EagerVec<InputIndex, InputIndex>,
|
||||||
pub monthindex_to_last_dateindex: EagerVec<Monthindex, Dateindex>,
|
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||||
pub monthindex_to_monthindex: EagerVec<Monthindex, Monthindex>,
|
pub monthindex_to_last_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||||
pub monthindex_to_quarterindex: EagerVec<Monthindex, Quarterindex>,
|
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
|
||||||
pub monthindex_to_timestamp: EagerVec<Monthindex, Timestamp>,
|
pub monthindex_to_quarterindex: EagerVec<MonthIndex, QuarterIndex>,
|
||||||
pub monthindex_to_yearindex: EagerVec<Monthindex, Yearindex>,
|
pub monthindex_to_timestamp: EagerVec<MonthIndex, Timestamp>,
|
||||||
pub multisigindex_to_multisigindex: EagerVec<Multisigindex, Multisigindex>,
|
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
|
||||||
pub opreturnindex_to_opreturnindex: EagerVec<Opreturnindex, Opreturnindex>,
|
pub opreturnindex_to_opreturnindex: EagerVec<OpReturnIndex, OpReturnIndex>,
|
||||||
pub p2pk33index_to_p2pk33index: EagerVec<P2PK33index, P2PK33index>,
|
pub outputindex_to_outputindex: EagerVec<OutputIndex, OutputIndex>,
|
||||||
pub p2pk65index_to_p2pk65index: EagerVec<P2PK65index, P2PK65index>,
|
pub p2aindex_to_p2aindex: EagerVec<P2AIndex, P2AIndex>,
|
||||||
pub p2pkhindex_to_p2pkhindex: EagerVec<P2PKHindex, P2PKHindex>,
|
pub p2msindex_to_p2msindex: EagerVec<P2MSIndex, P2MSIndex>,
|
||||||
pub p2shindex_to_p2shindex: EagerVec<P2SHindex, P2SHindex>,
|
pub p2pk33index_to_p2pk33index: EagerVec<P2PK33Index, P2PK33Index>,
|
||||||
pub p2trindex_to_p2trindex: EagerVec<P2TRindex, P2TRindex>,
|
pub p2pk65index_to_p2pk65index: EagerVec<P2PK65Index, P2PK65Index>,
|
||||||
pub p2wpkhindex_to_p2wpkhindex: EagerVec<P2WPKHindex, P2WPKHindex>,
|
pub p2pkhindex_to_p2pkhindex: EagerVec<P2PKHIndex, P2PKHIndex>,
|
||||||
pub p2wshindex_to_p2wshindex: EagerVec<P2WSHindex, P2WSHindex>,
|
pub p2shindex_to_p2shindex: EagerVec<P2SHIndex, P2SHIndex>,
|
||||||
pub pushonlyindex_to_pushonlyindex: EagerVec<Pushonlyindex, Pushonlyindex>,
|
pub p2trindex_to_p2trindex: EagerVec<P2TRIndex, P2TRIndex>,
|
||||||
pub quarterindex_to_first_monthindex: EagerVec<Quarterindex, Monthindex>,
|
pub p2wpkhindex_to_p2wpkhindex: EagerVec<P2WPKHIndex, P2WPKHIndex>,
|
||||||
pub quarterindex_to_last_monthindex: EagerVec<Quarterindex, Monthindex>,
|
pub p2wshindex_to_p2wshindex: EagerVec<P2WSHIndex, P2WSHIndex>,
|
||||||
pub quarterindex_to_quarterindex: EagerVec<Quarterindex, Quarterindex>,
|
pub quarterindex_to_first_monthindex: EagerVec<QuarterIndex, MonthIndex>,
|
||||||
pub quarterindex_to_timestamp: EagerVec<Quarterindex, Timestamp>,
|
pub quarterindex_to_last_monthindex: EagerVec<QuarterIndex, MonthIndex>,
|
||||||
pub txindex_to_last_txinindex: EagerVec<Txindex, Txinindex>,
|
pub quarterindex_to_quarterindex: EagerVec<QuarterIndex, QuarterIndex>,
|
||||||
pub txindex_to_last_txoutindex: EagerVec<Txindex, Txoutindex>,
|
pub quarterindex_to_timestamp: EagerVec<QuarterIndex, Timestamp>,
|
||||||
pub txindex_to_txindex: EagerVec<Txindex, Txindex>,
|
pub txindex_to_height: EagerVec<TxIndex, Height>,
|
||||||
pub txinindex_to_txinindex: EagerVec<Txinindex, Txinindex>,
|
pub txindex_to_last_inputindex: EagerVec<TxIndex, InputIndex>,
|
||||||
pub txoutindex_to_txoutindex: EagerVec<Txoutindex, Txoutindex>,
|
pub txindex_to_last_outputindex: EagerVec<TxIndex, OutputIndex>,
|
||||||
pub unknownindex_to_unknownindex: EagerVec<Unknownindex, Unknownindex>,
|
pub txindex_to_txindex: EagerVec<TxIndex, TxIndex>,
|
||||||
pub weekindex_to_first_dateindex: EagerVec<Weekindex, Dateindex>,
|
pub unknownoutputindex_to_unknownoutputindex: EagerVec<UnknownOutputIndex, UnknownOutputIndex>,
|
||||||
pub weekindex_to_last_dateindex: EagerVec<Weekindex, Dateindex>,
|
pub weekindex_to_first_dateindex: EagerVec<WeekIndex, DateIndex>,
|
||||||
pub weekindex_to_timestamp: EagerVec<Weekindex, Timestamp>,
|
pub weekindex_to_last_dateindex: EagerVec<WeekIndex, DateIndex>,
|
||||||
pub weekindex_to_weekindex: EagerVec<Weekindex, Weekindex>,
|
pub weekindex_to_timestamp: EagerVec<WeekIndex, Timestamp>,
|
||||||
pub yearindex_to_decadeindex: EagerVec<Yearindex, Decadeindex>,
|
pub weekindex_to_weekindex: EagerVec<WeekIndex, WeekIndex>,
|
||||||
pub yearindex_to_first_monthindex: EagerVec<Yearindex, Monthindex>,
|
pub yearindex_to_decadeindex: EagerVec<YearIndex, DecadeIndex>,
|
||||||
pub yearindex_to_last_monthindex: EagerVec<Yearindex, Monthindex>,
|
pub yearindex_to_first_monthindex: EagerVec<YearIndex, MonthIndex>,
|
||||||
pub yearindex_to_timestamp: EagerVec<Yearindex, Timestamp>,
|
pub yearindex_to_last_monthindex: EagerVec<YearIndex, MonthIndex>,
|
||||||
pub yearindex_to_yearindex: EagerVec<Yearindex, Yearindex>,
|
pub yearindex_to_timestamp: EagerVec<YearIndex, Timestamp>,
|
||||||
|
pub yearindex_to_yearindex: EagerVec<YearIndex, YearIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -105,13 +105,13 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_real_date: EagerVec::forced_import(
|
height_to_date: EagerVec::forced_import(
|
||||||
&path.join("height_to_real_date"),
|
&path.join("height_to_date"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_fixed_date: EagerVec::forced_import(
|
height_to_date_fixed: EagerVec::forced_import(
|
||||||
&path.join("height_to_fixed_date"),
|
&path.join("height_to_date_fixed"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -130,13 +130,18 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_last_txinindex: EagerVec::forced_import(
|
txindex_to_height: EagerVec::forced_import(
|
||||||
&path.join("txindex_to_last_txinindex"),
|
&path.join("txindex_to_height"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_last_txoutindex: EagerVec::forced_import(
|
txindex_to_last_inputindex: EagerVec::forced_import(
|
||||||
&path.join("txindex_to_last_txoutindex"),
|
&path.join("txindex_to_last_inputindex"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
txindex_to_last_outputindex: EagerVec::forced_import(
|
||||||
|
&path.join("txindex_to_last_outputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -295,8 +300,8 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_fixed_timestamp: EagerVec::forced_import(
|
height_to_timestamp_fixed: EagerVec::forced_import(
|
||||||
&path.join("height_to_fixed_timestamp"),
|
&path.join("height_to_timestamp_fixed"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -365,18 +370,18 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txinindex_to_txinindex: EagerVec::forced_import(
|
inputindex_to_inputindex: EagerVec::forced_import(
|
||||||
&path.join("txinindex_to_txinindex"),
|
&path.join("inputindex_to_inputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
emptyindex_to_emptyindex: EagerVec::forced_import(
|
emptyoutputindex_to_emptyoutputindex: EagerVec::forced_import(
|
||||||
&path.join("emptyindex_to_emptyindex"),
|
&path.join("emptyoutputindex_to_emptyoutputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
multisigindex_to_multisigindex: EagerVec::forced_import(
|
p2msindex_to_p2msindex: EagerVec::forced_import(
|
||||||
&path.join("multisigindex_to_multisigindex"),
|
&path.join("p2msindex_to_p2msindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -385,23 +390,18 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
pushonlyindex_to_pushonlyindex: EagerVec::forced_import(
|
p2aindex_to_p2aindex: EagerVec::forced_import(
|
||||||
&path.join("pushonlyindex_to_pushonlyindex"),
|
&path.join("p2aindex_to_p2aindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
unknownindex_to_unknownindex: EagerVec::forced_import(
|
unknownoutputindex_to_unknownoutputindex: EagerVec::forced_import(
|
||||||
&path.join("unknownindex_to_unknownindex"),
|
&path.join("unknownoutputindex_to_unknownoutputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
addressindex_to_addressindex: EagerVec::forced_import(
|
outputindex_to_outputindex: EagerVec::forced_import(
|
||||||
&path.join("addressindex_to_addressindex"),
|
&path.join("outputindex_to_outputindex"),
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
txoutindex_to_txoutindex: EagerVec::forced_import(
|
|
||||||
&path.join("txoutindex_to_txoutindex"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -418,8 +418,8 @@ impl Vecs {
|
|||||||
|
|
||||||
let height_count = indexer_vecs.height_to_total_size.len();
|
let height_count = indexer_vecs.height_to_total_size.len();
|
||||||
let txindexes_count = indexer_vecs.txindex_to_txid.len();
|
let txindexes_count = indexer_vecs.txindex_to_txid.len();
|
||||||
let txinindexes_count = indexer_vecs.txinindex_to_txoutindex.len();
|
let inputindexes_count = indexer_vecs.inputindex_to_outputindex.len();
|
||||||
let txoutindexes_count = indexer_vecs.txoutindex_to_addressindex.len();
|
let outputindexes_count = indexer_vecs.outputindex_to_value.len();
|
||||||
|
|
||||||
self.height_to_height.compute_range(
|
self.height_to_height.compute_range(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
@@ -428,14 +428,14 @@ impl Vecs {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.height_to_real_date.compute_transform(
|
self.height_to_date.compute_transform(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
indexer_vecs.height_to_timestamp.mut_vec(),
|
indexer_vecs.height_to_timestamp.mut_vec(),
|
||||||
|(h, t, ..)| (h, Date::from(t)),
|
|(h, t, ..)| (h, Date::from(t)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.height_to_fixed_timestamp.compute_transform(
|
self.height_to_timestamp_fixed.compute_transform(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
indexer_vecs.height_to_timestamp.mut_vec(),
|
indexer_vecs.height_to_timestamp.mut_vec(),
|
||||||
|(h, timestamp, s, ..)| {
|
|(h, timestamp, s, ..)| {
|
||||||
@@ -448,9 +448,9 @@ impl Vecs {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.height_to_fixed_date.compute_transform(
|
self.height_to_date_fixed.compute_transform(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
self.height_to_fixed_timestamp.mut_vec(),
|
self.height_to_timestamp_fixed.mut_vec(),
|
||||||
|(h, t, ..)| (h, Date::from(t)),
|
|(h, t, ..)| (h, Date::from(t)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -464,8 +464,8 @@ impl Vecs {
|
|||||||
|
|
||||||
self.height_to_dateindex.compute_transform(
|
self.height_to_dateindex.compute_transform(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
self.height_to_fixed_date.mut_vec(),
|
self.height_to_date_fixed.mut_vec(),
|
||||||
|(h, d, ..)| (h, Dateindex::try_from(d).unwrap()),
|
|(h, d, ..)| (h, DateIndex::try_from(d).unwrap()),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -516,19 +516,19 @@ impl Vecs {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.txindex_to_last_txinindex
|
self.txindex_to_last_inputindex
|
||||||
.compute_last_index_from_first(
|
.compute_last_index_from_first(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer_vecs.txindex_to_first_txinindex.mut_vec(),
|
indexer_vecs.txindex_to_first_inputindex.mut_vec(),
|
||||||
txinindexes_count,
|
inputindexes_count,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.txindex_to_last_txoutindex
|
self.txindex_to_last_outputindex
|
||||||
.compute_last_index_from_first(
|
.compute_last_index_from_first(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer_vecs.txindex_to_first_txoutindex.mut_vec(),
|
indexer_vecs.txindex_to_first_outputindex.mut_vec(),
|
||||||
txoutindexes_count,
|
outputindexes_count,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ impl Vecs {
|
|||||||
self.dateindex_to_weekindex.compute_range(
|
self.dateindex_to_weekindex.compute_range(
|
||||||
starting_dateindex,
|
starting_dateindex,
|
||||||
self.dateindex_to_dateindex.mut_vec(),
|
self.dateindex_to_dateindex.mut_vec(),
|
||||||
|di| (di, Weekindex::from(di)),
|
|di| (di, WeekIndex::from(di)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -592,7 +592,7 @@ impl Vecs {
|
|||||||
self.dateindex_to_monthindex.compute_range(
|
self.dateindex_to_monthindex.compute_range(
|
||||||
starting_dateindex,
|
starting_dateindex,
|
||||||
self.dateindex_to_dateindex.mut_vec(),
|
self.dateindex_to_dateindex.mut_vec(),
|
||||||
|di| (di, Monthindex::from(di)),
|
|di| (di, MonthIndex::from(di)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -637,7 +637,7 @@ impl Vecs {
|
|||||||
self.monthindex_to_quarterindex.compute_range(
|
self.monthindex_to_quarterindex.compute_range(
|
||||||
starting_monthindex,
|
starting_monthindex,
|
||||||
self.monthindex_to_monthindex.mut_vec(),
|
self.monthindex_to_monthindex.mut_vec(),
|
||||||
|mi| (mi, Quarterindex::from(mi)),
|
|mi| (mi, QuarterIndex::from(mi)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -682,7 +682,7 @@ impl Vecs {
|
|||||||
self.monthindex_to_yearindex.compute_range(
|
self.monthindex_to_yearindex.compute_range(
|
||||||
starting_monthindex,
|
starting_monthindex,
|
||||||
self.monthindex_to_monthindex.mut_vec(),
|
self.monthindex_to_monthindex.mut_vec(),
|
||||||
|i| (i, Yearindex::from(i)),
|
|i| (i, YearIndex::from(i)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -727,7 +727,7 @@ impl Vecs {
|
|||||||
self.yearindex_to_decadeindex.compute_range(
|
self.yearindex_to_decadeindex.compute_range(
|
||||||
starting_yearindex,
|
starting_yearindex,
|
||||||
self.yearindex_to_yearindex.mut_vec(),
|
self.yearindex_to_yearindex.mut_vec(),
|
||||||
|i| (i, Decadeindex::from(i)),
|
|i| (i, DecadeIndex::from(i)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -770,7 +770,7 @@ impl Vecs {
|
|||||||
self.height_to_difficultyepoch.compute_range(
|
self.height_to_difficultyepoch.compute_range(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
self.height_to_height.mut_vec(),
|
self.height_to_height.mut_vec(),
|
||||||
|h| (h, Difficultyepoch::from(h)),
|
|h| (h, DifficultyEpoch::from(h)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -818,7 +818,7 @@ impl Vecs {
|
|||||||
self.height_to_halvingepoch.compute_range(
|
self.height_to_halvingepoch.compute_range(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
self.height_to_height.mut_vec(),
|
self.height_to_height.mut_vec(),
|
||||||
|h| (h, Halvingepoch::from(h)),
|
|h| (h, HalvingEpoch::from(h)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -858,102 +858,97 @@ impl Vecs {
|
|||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
self.addressindex_to_addressindex.compute_range(
|
self.outputindex_to_outputindex.compute_range(
|
||||||
starting_indexes.addressindex,
|
starting_indexes.outputindex,
|
||||||
indexer_vecs.addressindex_to_height.mut_vec(),
|
indexer_vecs.outputindex_to_value.mut_vec(),
|
||||||
|i| (i, i),
|
|
||||||
exit,
|
|
||||||
)?;
|
|
||||||
self.txoutindex_to_txoutindex.compute_range(
|
|
||||||
starting_indexes.txoutindex,
|
|
||||||
indexer_vecs.txoutindex_to_height.mut_vec(),
|
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2pk33index_to_p2pk33index.compute_range(
|
self.p2pk33index_to_p2pk33index.compute_range(
|
||||||
starting_indexes.p2pk33index,
|
starting_indexes.p2pk33index,
|
||||||
indexer_vecs.p2pk33index_to_height.mut_vec(),
|
indexer_vecs.p2pk33index_to_p2pk33bytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2pk65index_to_p2pk65index.compute_range(
|
self.p2pk65index_to_p2pk65index.compute_range(
|
||||||
starting_indexes.p2pk65index,
|
starting_indexes.p2pk65index,
|
||||||
indexer_vecs.p2pk65index_to_height.mut_vec(),
|
indexer_vecs.p2pk65index_to_p2pk65bytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2pkhindex_to_p2pkhindex.compute_range(
|
self.p2pkhindex_to_p2pkhindex.compute_range(
|
||||||
starting_indexes.p2pkhindex,
|
starting_indexes.p2pkhindex,
|
||||||
indexer_vecs.p2pkhindex_to_height.mut_vec(),
|
indexer_vecs.p2pkhindex_to_p2pkhbytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2shindex_to_p2shindex.compute_range(
|
self.p2shindex_to_p2shindex.compute_range(
|
||||||
starting_indexes.p2shindex,
|
starting_indexes.p2shindex,
|
||||||
indexer_vecs.p2shindex_to_height.mut_vec(),
|
indexer_vecs.p2shindex_to_p2shbytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2trindex_to_p2trindex.compute_range(
|
self.p2trindex_to_p2trindex.compute_range(
|
||||||
starting_indexes.p2trindex,
|
starting_indexes.p2trindex,
|
||||||
indexer_vecs.p2trindex_to_height.mut_vec(),
|
indexer_vecs.p2trindex_to_p2trbytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2wpkhindex_to_p2wpkhindex.compute_range(
|
self.p2wpkhindex_to_p2wpkhindex.compute_range(
|
||||||
starting_indexes.p2wpkhindex,
|
starting_indexes.p2wpkhindex,
|
||||||
indexer_vecs.p2wpkhindex_to_height.mut_vec(),
|
indexer_vecs.p2wpkhindex_to_p2wpkhbytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.p2wshindex_to_p2wshindex.compute_range(
|
self.p2wshindex_to_p2wshindex.compute_range(
|
||||||
starting_indexes.p2wshindex,
|
starting_indexes.p2wshindex,
|
||||||
indexer_vecs.p2wshindex_to_height.mut_vec(),
|
indexer_vecs.p2wshindex_to_p2wshbytes.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.txindex_to_txindex.compute_range(
|
self.txindex_to_txindex.compute_range(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer_vecs.txindex_to_height.mut_vec(),
|
self.txindex_to_height.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.txinindex_to_txinindex.compute_range(
|
self.inputindex_to_inputindex.compute_range(
|
||||||
starting_indexes.txinindex,
|
starting_indexes.inputindex,
|
||||||
indexer_vecs.txinindex_to_height.mut_vec(),
|
indexer_vecs.inputindex_to_outputindex.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.emptyindex_to_emptyindex.compute_range(
|
self.emptyoutputindex_to_emptyoutputindex.compute_range(
|
||||||
starting_indexes.emptyindex,
|
starting_indexes.emptyoutputindex,
|
||||||
indexer_vecs.emptyindex_to_height.mut_vec(),
|
indexer_vecs.emptyoutputindex_to_txindex.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.multisigindex_to_multisigindex.compute_range(
|
self.p2msindex_to_p2msindex.compute_range(
|
||||||
starting_indexes.multisigindex,
|
starting_indexes.p2msindex,
|
||||||
indexer_vecs.multisigindex_to_height.mut_vec(),
|
indexer_vecs.p2msindex_to_txindex.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.opreturnindex_to_opreturnindex.compute_range(
|
self.opreturnindex_to_opreturnindex.compute_range(
|
||||||
starting_indexes.opreturnindex,
|
starting_indexes.opreturnindex,
|
||||||
indexer_vecs.opreturnindex_to_height.mut_vec(),
|
indexer_vecs.opreturnindex_to_txindex.mut_vec(),
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.pushonlyindex_to_pushonlyindex.compute_range(
|
self.p2aindex_to_p2aindex.compute_range(
|
||||||
starting_indexes.pushonlyindex,
|
starting_indexes.p2aindex,
|
||||||
indexer_vecs.pushonlyindex_to_height.mut_vec(),
|
indexer_vecs.p2aindex_to_p2abytes.mut_vec(),
|
||||||
|i| (i, i),
|
|
||||||
exit,
|
|
||||||
)?;
|
|
||||||
self.unknownindex_to_unknownindex.compute_range(
|
|
||||||
starting_indexes.unknownindex,
|
|
||||||
indexer_vecs.unknownindex_to_height.mut_vec(),
|
|
||||||
|i| (i, i),
|
|i| (i, i),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
self.unknownoutputindex_to_unknownoutputindex
|
||||||
|
.compute_range(
|
||||||
|
starting_indexes.unknownoutputindex,
|
||||||
|
indexer_vecs.unknownoutputindex_to_txindex.mut_vec(),
|
||||||
|
|i| (i, i),
|
||||||
|
exit,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(Indexes {
|
Ok(Indexes {
|
||||||
indexes: starting_indexes,
|
indexes: starting_indexes,
|
||||||
@@ -975,12 +970,12 @@ impl Vecs {
|
|||||||
self.dateindex_to_first_height.any_vec(),
|
self.dateindex_to_first_height.any_vec(),
|
||||||
self.dateindex_to_last_height.any_vec(),
|
self.dateindex_to_last_height.any_vec(),
|
||||||
self.height_to_dateindex.any_vec(),
|
self.height_to_dateindex.any_vec(),
|
||||||
self.height_to_fixed_date.any_vec(),
|
self.height_to_date_fixed.any_vec(),
|
||||||
self.height_to_height.any_vec(),
|
self.height_to_height.any_vec(),
|
||||||
self.height_to_last_txindex.any_vec(),
|
self.height_to_last_txindex.any_vec(),
|
||||||
self.height_to_real_date.any_vec(),
|
self.height_to_date.any_vec(),
|
||||||
self.txindex_to_last_txinindex.any_vec(),
|
self.txindex_to_last_inputindex.any_vec(),
|
||||||
self.txindex_to_last_txoutindex.any_vec(),
|
self.txindex_to_last_outputindex.any_vec(),
|
||||||
self.difficultyepoch_to_first_height.any_vec(),
|
self.difficultyepoch_to_first_height.any_vec(),
|
||||||
self.difficultyepoch_to_last_height.any_vec(),
|
self.difficultyepoch_to_last_height.any_vec(),
|
||||||
self.halvingepoch_to_first_height.any_vec(),
|
self.halvingepoch_to_first_height.any_vec(),
|
||||||
@@ -1012,7 +1007,7 @@ impl Vecs {
|
|||||||
self.monthindex_to_timestamp.any_vec(),
|
self.monthindex_to_timestamp.any_vec(),
|
||||||
self.weekindex_to_timestamp.any_vec(),
|
self.weekindex_to_timestamp.any_vec(),
|
||||||
self.yearindex_to_timestamp.any_vec(),
|
self.yearindex_to_timestamp.any_vec(),
|
||||||
self.height_to_fixed_timestamp.any_vec(),
|
self.height_to_timestamp_fixed.any_vec(),
|
||||||
self.monthindex_to_quarterindex.any_vec(),
|
self.monthindex_to_quarterindex.any_vec(),
|
||||||
self.quarterindex_to_first_monthindex.any_vec(),
|
self.quarterindex_to_first_monthindex.any_vec(),
|
||||||
self.quarterindex_to_last_monthindex.any_vec(),
|
self.quarterindex_to_last_monthindex.any_vec(),
|
||||||
@@ -1026,28 +1021,27 @@ impl Vecs {
|
|||||||
self.p2wpkhindex_to_p2wpkhindex.any_vec(),
|
self.p2wpkhindex_to_p2wpkhindex.any_vec(),
|
||||||
self.p2wshindex_to_p2wshindex.any_vec(),
|
self.p2wshindex_to_p2wshindex.any_vec(),
|
||||||
self.txindex_to_txindex.any_vec(),
|
self.txindex_to_txindex.any_vec(),
|
||||||
self.txinindex_to_txinindex.any_vec(),
|
self.inputindex_to_inputindex.any_vec(),
|
||||||
self.emptyindex_to_emptyindex.any_vec(),
|
self.emptyoutputindex_to_emptyoutputindex.any_vec(),
|
||||||
self.multisigindex_to_multisigindex.any_vec(),
|
self.p2msindex_to_p2msindex.any_vec(),
|
||||||
self.opreturnindex_to_opreturnindex.any_vec(),
|
self.opreturnindex_to_opreturnindex.any_vec(),
|
||||||
self.pushonlyindex_to_pushonlyindex.any_vec(),
|
self.p2aindex_to_p2aindex.any_vec(),
|
||||||
self.unknownindex_to_unknownindex.any_vec(),
|
self.unknownoutputindex_to_unknownoutputindex.any_vec(),
|
||||||
self.addressindex_to_addressindex.any_vec(),
|
self.outputindex_to_outputindex.any_vec(),
|
||||||
self.txoutindex_to_txoutindex.any_vec(),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Indexes {
|
pub struct Indexes {
|
||||||
indexes: brk_indexer::Indexes,
|
indexes: brk_indexer::Indexes,
|
||||||
pub dateindex: Dateindex,
|
pub dateindex: DateIndex,
|
||||||
pub weekindex: Weekindex,
|
pub weekindex: WeekIndex,
|
||||||
pub monthindex: Monthindex,
|
pub monthindex: MonthIndex,
|
||||||
pub quarterindex: Quarterindex,
|
pub quarterindex: QuarterIndex,
|
||||||
pub yearindex: Yearindex,
|
pub yearindex: YearIndex,
|
||||||
pub decadeindex: Decadeindex,
|
pub decadeindex: DecadeIndex,
|
||||||
pub difficultyepoch: Difficultyepoch,
|
pub difficultyepoch: DifficultyEpoch,
|
||||||
pub halvingepoch: Halvingepoch,
|
pub halvingepoch: HalvingEpoch,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Indexes {
|
impl Deref for Indexes {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
Cents, Close, Dateindex, Decadeindex, Difficultyepoch, Dollars, Height, High, Low, Monthindex,
|
Cents, Close, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, High, Low, MonthIndex,
|
||||||
OHLCCents, OHLCDollars, OHLCSats, Open, Quarterindex, Sats, Weekindex, Yearindex,
|
OHLCCents, OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, WeekIndex, YearIndex,
|
||||||
};
|
};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_fetcher::Fetcher;
|
use brk_fetcher::Fetcher;
|
||||||
@@ -19,13 +19,13 @@ use super::{
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Vecs {
|
pub struct Vecs {
|
||||||
pub dateindex_to_close_in_cents: EagerVec<Dateindex, Close<Cents>>,
|
pub dateindex_to_close_in_cents: EagerVec<DateIndex, Close<Cents>>,
|
||||||
pub dateindex_to_high_in_cents: EagerVec<Dateindex, High<Cents>>,
|
pub dateindex_to_high_in_cents: EagerVec<DateIndex, High<Cents>>,
|
||||||
pub dateindex_to_low_in_cents: EagerVec<Dateindex, Low<Cents>>,
|
pub dateindex_to_low_in_cents: EagerVec<DateIndex, Low<Cents>>,
|
||||||
pub dateindex_to_ohlc: EagerVec<Dateindex, OHLCDollars>,
|
pub dateindex_to_ohlc: EagerVec<DateIndex, OHLCDollars>,
|
||||||
pub dateindex_to_ohlc_in_sats: EagerVec<Dateindex, OHLCSats>,
|
pub dateindex_to_ohlc_in_sats: EagerVec<DateIndex, OHLCSats>,
|
||||||
pub dateindex_to_ohlc_in_cents: EagerVec<Dateindex, OHLCCents>,
|
pub dateindex_to_ohlc_in_cents: EagerVec<DateIndex, OHLCCents>,
|
||||||
pub dateindex_to_open_in_cents: EagerVec<Dateindex, Open<Cents>>,
|
pub dateindex_to_open_in_cents: EagerVec<DateIndex, Open<Cents>>,
|
||||||
pub height_to_close_in_cents: EagerVec<Height, Close<Cents>>,
|
pub height_to_close_in_cents: EagerVec<Height, Close<Cents>>,
|
||||||
pub height_to_high_in_cents: EagerVec<Height, High<Cents>>,
|
pub height_to_high_in_cents: EagerVec<Height, High<Cents>>,
|
||||||
pub height_to_low_in_cents: EagerVec<Height, Low<Cents>>,
|
pub height_to_low_in_cents: EagerVec<Height, Low<Cents>>,
|
||||||
@@ -49,20 +49,20 @@ pub struct Vecs {
|
|||||||
pub chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict<High<Sats>>,
|
pub chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict<High<Sats>>,
|
||||||
pub chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict<Low<Sats>>,
|
pub chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict<Low<Sats>>,
|
||||||
pub chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict<Close<Sats>>,
|
pub chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict<Close<Sats>>,
|
||||||
pub weekindex_to_ohlc: EagerVec<Weekindex, OHLCDollars>,
|
pub weekindex_to_ohlc: EagerVec<WeekIndex, OHLCDollars>,
|
||||||
pub weekindex_to_ohlc_in_sats: EagerVec<Weekindex, OHLCSats>,
|
pub weekindex_to_ohlc_in_sats: EagerVec<WeekIndex, OHLCSats>,
|
||||||
pub difficultyepoch_to_ohlc: EagerVec<Difficultyepoch, OHLCDollars>,
|
pub difficultyepoch_to_ohlc: EagerVec<DifficultyEpoch, OHLCDollars>,
|
||||||
pub difficultyepoch_to_ohlc_in_sats: EagerVec<Difficultyepoch, OHLCSats>,
|
pub difficultyepoch_to_ohlc_in_sats: EagerVec<DifficultyEpoch, OHLCSats>,
|
||||||
pub monthindex_to_ohlc: EagerVec<Monthindex, OHLCDollars>,
|
pub monthindex_to_ohlc: EagerVec<MonthIndex, OHLCDollars>,
|
||||||
pub monthindex_to_ohlc_in_sats: EagerVec<Monthindex, OHLCSats>,
|
pub monthindex_to_ohlc_in_sats: EagerVec<MonthIndex, OHLCSats>,
|
||||||
pub quarterindex_to_ohlc: EagerVec<Quarterindex, OHLCDollars>,
|
pub quarterindex_to_ohlc: EagerVec<QuarterIndex, OHLCDollars>,
|
||||||
pub quarterindex_to_ohlc_in_sats: EagerVec<Quarterindex, OHLCSats>,
|
pub quarterindex_to_ohlc_in_sats: EagerVec<QuarterIndex, OHLCSats>,
|
||||||
pub yearindex_to_ohlc: EagerVec<Yearindex, OHLCDollars>,
|
pub yearindex_to_ohlc: EagerVec<YearIndex, OHLCDollars>,
|
||||||
pub yearindex_to_ohlc_in_sats: EagerVec<Yearindex, OHLCSats>,
|
pub yearindex_to_ohlc_in_sats: EagerVec<YearIndex, OHLCSats>,
|
||||||
// pub halvingepoch_to_ohlc: StorableVec<Halvingepoch, OHLCDollars>,
|
// pub halvingepoch_to_ohlc: StorableVec<Halvingepoch, OHLCDollars>,
|
||||||
// pub halvingepoch_to_ohlc_in_sats: StorableVec<Halvingepoch, OHLCSats>,
|
// pub halvingepoch_to_ohlc_in_sats: StorableVec<Halvingepoch, OHLCSats>,
|
||||||
pub decadeindex_to_ohlc: EagerVec<Decadeindex, OHLCDollars>,
|
pub decadeindex_to_ohlc: EagerVec<DecadeIndex, OHLCDollars>,
|
||||||
pub decadeindex_to_ohlc_in_sats: EagerVec<Decadeindex, OHLCSats>,
|
pub decadeindex_to_ohlc_in_sats: EagerVec<DecadeIndex, OHLCSats>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
const VERSION: Version = Version::ZERO;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
CheckedSub, Feerate, Sats, StoredU32, StoredU64, StoredUsize, TxVersion, Txindex, Txinindex,
|
CheckedSub, Feerate, InputIndex, OutputIndex, Sats, StoredU32, StoredU64, StoredUsize, TxIndex,
|
||||||
Txoutindex, Weight,
|
TxVersion, Weight,
|
||||||
};
|
};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
@@ -34,12 +34,12 @@ pub struct Vecs {
|
|||||||
pub indexes_to_tx_vsize: ComputedVecsFromTxindex<StoredUsize>,
|
pub indexes_to_tx_vsize: ComputedVecsFromTxindex<StoredUsize>,
|
||||||
pub indexes_to_tx_weight: ComputedVecsFromTxindex<Weight>,
|
pub indexes_to_tx_weight: ComputedVecsFromTxindex<Weight>,
|
||||||
pub txindex_to_input_count: ComputedVecsFromTxindex<StoredU64>,
|
pub txindex_to_input_count: ComputedVecsFromTxindex<StoredU64>,
|
||||||
pub txindex_to_is_coinbase: EagerVec<Txindex, bool>,
|
pub txindex_to_is_coinbase: EagerVec<TxIndex, bool>,
|
||||||
pub txindex_to_output_count: ComputedVecsFromTxindex<StoredU64>,
|
pub txindex_to_output_count: ComputedVecsFromTxindex<StoredU64>,
|
||||||
pub txindex_to_vsize: EagerVec<Txindex, StoredUsize>,
|
pub txindex_to_vsize: EagerVec<TxIndex, StoredUsize>,
|
||||||
pub txindex_to_weight: EagerVec<Txindex, Weight>,
|
pub txindex_to_weight: EagerVec<TxIndex, Weight>,
|
||||||
/// Value == 0 when Coinbase
|
/// Value == 0 when Coinbase
|
||||||
pub txinindex_to_value: EagerVec<Txinindex, Sats>,
|
pub inputindex_to_value: EagerVec<InputIndex, Sats>,
|
||||||
pub indexes_to_subsidy: ComputedValueVecsFromHeight,
|
pub indexes_to_subsidy: ComputedValueVecsFromHeight,
|
||||||
pub indexes_to_coinbase: ComputedValueVecsFromHeight,
|
pub indexes_to_coinbase: ComputedValueVecsFromHeight,
|
||||||
}
|
}
|
||||||
@@ -98,8 +98,8 @@ impl Vecs {
|
|||||||
.add_sum()
|
.add_sum()
|
||||||
.add_total(),
|
.add_total(),
|
||||||
)?,
|
)?,
|
||||||
txinindex_to_value: EagerVec::forced_import(
|
inputindex_to_value: EagerVec::forced_import(
|
||||||
&path.join("txinindex_to_value"),
|
&path.join("inputindex_to_value"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -268,8 +268,8 @@ impl Vecs {
|
|||||||
|v, indexer, indexes, starting_indexes, exit| {
|
|v, indexer, indexes, starting_indexes, exit| {
|
||||||
v.compute_count_from_indexes(
|
v.compute_count_from_indexes(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer.mut_vecs().txindex_to_first_txinindex.mut_vec(),
|
indexer.mut_vecs().txindex_to_first_inputindex.mut_vec(),
|
||||||
indexes.txindex_to_last_txinindex.mut_vec(),
|
indexes.txindex_to_last_inputindex.mut_vec(),
|
||||||
exit,
|
exit,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -283,8 +283,8 @@ impl Vecs {
|
|||||||
|v, indexer, indexes, starting_indexes, exit| {
|
|v, indexer, indexes, starting_indexes, exit| {
|
||||||
v.compute_count_from_indexes(
|
v.compute_count_from_indexes(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer.mut_vecs().txindex_to_first_txoutindex.mut_vec(),
|
indexer.mut_vecs().txindex_to_first_outputindex.mut_vec(),
|
||||||
indexes.txindex_to_last_txoutindex.mut_vec(),
|
indexes.txindex_to_last_outputindex.mut_vec(),
|
||||||
exit,
|
exit,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -322,7 +322,7 @@ impl Vecs {
|
|||||||
|
|
||||||
self.txindex_to_is_coinbase.compute_is_first_ordered(
|
self.txindex_to_is_coinbase.compute_is_first_ordered(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer_vecs.txindex_to_height.mut_vec(),
|
indexes.txindex_to_height.mut_vec(),
|
||||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -337,7 +337,7 @@ impl Vecs {
|
|||||||
.double_unwrap_cached_get(txindex);
|
.double_unwrap_cached_get(txindex);
|
||||||
|
|
||||||
// This is the exact definition of a weight unit, as defined by BIP-141 (quote above).
|
// This is the exact definition of a weight unit, as defined by BIP-141 (quote above).
|
||||||
let wu = base_size * 3 + total_size;
|
let wu = usize::from(base_size) * 3 + usize::from(total_size);
|
||||||
let weight = Weight::from(bitcoin::Weight::from_wu_usize(wu));
|
let weight = Weight::from(bitcoin::Weight::from_wu_usize(wu));
|
||||||
|
|
||||||
(txindex, weight)
|
(txindex, weight)
|
||||||
@@ -356,23 +356,23 @@ impl Vecs {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.txinindex_to_value.compute_transform(
|
self.inputindex_to_value.compute_transform(
|
||||||
starting_indexes.txinindex,
|
starting_indexes.inputindex,
|
||||||
indexer_vecs.txinindex_to_txoutindex.mut_vec(),
|
indexer_vecs.inputindex_to_outputindex.mut_vec(),
|
||||||
|(txinindex, txoutindex, slf, other)| {
|
|(inputindex, outputindex, slf, other)| {
|
||||||
let value = if txoutindex == Txoutindex::COINBASE {
|
let value = if outputindex == OutputIndex::COINBASE {
|
||||||
Sats::ZERO
|
Sats::ZERO
|
||||||
} else if let Some(value) = indexer_vecs
|
} else if let Some(value) = indexer_vecs
|
||||||
.txoutindex_to_value
|
.outputindex_to_value
|
||||||
.mut_vec()
|
.mut_vec()
|
||||||
.unwrap_cached_get(txoutindex)
|
.unwrap_cached_get(outputindex)
|
||||||
{
|
{
|
||||||
value
|
value
|
||||||
} else {
|
} else {
|
||||||
dbg!(txinindex, txoutindex, slf.len(), other.len());
|
dbg!(inputindex, outputindex, slf.len(), other.len());
|
||||||
panic!()
|
panic!()
|
||||||
};
|
};
|
||||||
(txinindex, value)
|
(inputindex, value)
|
||||||
},
|
},
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -386,9 +386,9 @@ impl Vecs {
|
|||||||
let indexer_vecs = indexer.mut_vecs();
|
let indexer_vecs = indexer.mut_vecs();
|
||||||
vec.compute_sum_from_indexes(
|
vec.compute_sum_from_indexes(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer_vecs.txindex_to_first_txoutindex.mut_vec(),
|
indexer_vecs.txindex_to_first_outputindex.mut_vec(),
|
||||||
indexes.txindex_to_last_txoutindex.mut_vec(),
|
indexes.txindex_to_last_outputindex.mut_vec(),
|
||||||
indexer_vecs.txoutindex_to_value.mut_vec(),
|
indexer_vecs.outputindex_to_value.mut_vec(),
|
||||||
exit,
|
exit,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -403,9 +403,9 @@ impl Vecs {
|
|||||||
let indexer_vecs = indexer.mut_vecs();
|
let indexer_vecs = indexer.mut_vecs();
|
||||||
vec.compute_sum_from_indexes(
|
vec.compute_sum_from_indexes(
|
||||||
starting_indexes.txindex,
|
starting_indexes.txindex,
|
||||||
indexer_vecs.txindex_to_first_txinindex.mut_vec(),
|
indexer_vecs.txindex_to_first_inputindex.mut_vec(),
|
||||||
indexes.txindex_to_last_txinindex.mut_vec(),
|
indexes.txindex_to_last_inputindex.mut_vec(),
|
||||||
self.txinindex_to_value.mut_vec(),
|
self.inputindex_to_value.mut_vec(),
|
||||||
exit,
|
exit,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -495,20 +495,20 @@ impl Vecs {
|
|||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||||
|(height, txindex, ..)| {
|
|(height, txindex, ..)| {
|
||||||
let first_txoutindex = indexer_vecs
|
let first_outputindex = indexer_vecs
|
||||||
.txindex_to_first_txoutindex
|
.txindex_to_first_outputindex
|
||||||
.double_unwrap_cached_get(txindex)
|
.double_unwrap_cached_get(txindex)
|
||||||
.unwrap_to_usize();
|
.unwrap_to_usize();
|
||||||
let last_txoutindex = indexes
|
let last_outputindex = indexes
|
||||||
.txindex_to_last_txoutindex
|
.txindex_to_last_outputindex
|
||||||
.mut_vec()
|
.mut_vec()
|
||||||
.double_unwrap_cached_get(txindex)
|
.double_unwrap_cached_get(txindex)
|
||||||
.unwrap_to_usize();
|
.unwrap_to_usize();
|
||||||
let mut sats = Sats::ZERO;
|
let mut sats = Sats::ZERO;
|
||||||
(first_txoutindex..=last_txoutindex).for_each(|txoutindex| {
|
(first_outputindex..=last_outputindex).for_each(|outputindex| {
|
||||||
sats += indexer_vecs
|
sats += indexer_vecs
|
||||||
.txoutindex_to_value
|
.outputindex_to_value
|
||||||
.double_unwrap_cached_get(Txoutindex::from(txoutindex));
|
.double_unwrap_cached_get(OutputIndex::from(outputindex));
|
||||||
});
|
});
|
||||||
(height, sats)
|
(height, sats)
|
||||||
},
|
},
|
||||||
@@ -554,7 +554,7 @@ impl Vecs {
|
|||||||
[
|
[
|
||||||
vec![
|
vec![
|
||||||
self.txindex_to_is_coinbase.any_vec(),
|
self.txindex_to_is_coinbase.any_vec(),
|
||||||
self.txinindex_to_value.any_vec(),
|
self.inputindex_to_value.any_vec(),
|
||||||
self.txindex_to_weight.any_vec(),
|
self.txindex_to_weight.any_vec(),
|
||||||
self.txindex_to_vsize.any_vec(),
|
self.txindex_to_vsize.any_vec(),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use brk_core::{Bitcoin, CheckedSub, Close, Dollars, Height, Sats, Txindex};
|
use brk_core::{Bitcoin, CheckedSub, Close, Dollars, Height, Sats, TxIndex};
|
||||||
use brk_exit::Exit;
|
use brk_exit::Exit;
|
||||||
use brk_vec::{
|
use brk_vec::{
|
||||||
Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, Version,
|
Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, Version,
|
||||||
@@ -490,12 +490,12 @@ impl EagerVec<Height, Dollars> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EagerVec<Txindex, Dollars> {
|
impl EagerVec<TxIndex, Dollars> {
|
||||||
pub fn compute_from_bitcoin(
|
pub fn compute_from_bitcoin(
|
||||||
&mut self,
|
&mut self,
|
||||||
max_from: Txindex,
|
max_from: TxIndex,
|
||||||
bitcoin: &mut StoredVec<Txindex, Bitcoin>,
|
bitcoin: &mut StoredVec<TxIndex, Bitcoin>,
|
||||||
i_to_height: &mut StoredVec<Txindex, Height>,
|
i_to_height: &mut StoredVec<TxIndex, Height>,
|
||||||
price: &mut StoredVec<Height, Close<Dollars>>,
|
price: &mut StoredVec<Height, Close<Dollars>>,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@@ -503,7 +503,7 @@ impl EagerVec<Txindex, Dollars> {
|
|||||||
Version::ZERO + self.version() + bitcoin.version(),
|
Version::ZERO + self.version() + bitcoin.version(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let index = max_from.min(Txindex::from(self.len()));
|
let index = max_from.min(TxIndex::from(self.len()));
|
||||||
bitcoin.iter_from(index, |(i, bitcoin, ..)| {
|
bitcoin.iter_from(index, |(i, bitcoin, ..)| {
|
||||||
let height = i_to_height.double_unwrap_cached_get(i);
|
let height = i_to_height.double_unwrap_cached_get(i);
|
||||||
let dollars = price.double_unwrap_cached_get(height);
|
let dollars = price.double_unwrap_cached_get(height);
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ use crate::Error;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Addressindex(u32);
|
pub struct AddressIndex(u32);
|
||||||
|
|
||||||
impl Addressindex {
|
impl AddressIndex {
|
||||||
pub const BYTES: usize = size_of::<Self>();
|
pub const BYTES: usize = size_of::<Self>();
|
||||||
|
|
||||||
pub fn increment(&mut self) {
|
pub fn increment(&mut self) {
|
||||||
@@ -35,56 +35,56 @@ impl Addressindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u32> for Addressindex {
|
impl From<u32> for AddressIndex {
|
||||||
fn from(value: u32) -> Self {
|
fn from(value: u32) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u64> for Addressindex {
|
impl From<u64> for AddressIndex {
|
||||||
fn from(value: u64) -> Self {
|
fn from(value: u64) -> Self {
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Addressindex> for u64 {
|
impl From<AddressIndex> for u64 {
|
||||||
fn from(value: Addressindex) -> Self {
|
fn from(value: AddressIndex) -> Self {
|
||||||
value.0 as u64
|
value.0 as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Addressindex {
|
impl From<usize> for AddressIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Addressindex> for usize {
|
impl From<AddressIndex> for usize {
|
||||||
fn from(value: Addressindex) -> Self {
|
fn from(value: AddressIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<ByteView> for Addressindex {
|
impl TryFrom<ByteView> for AddressIndex {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
Ok(Self::read_from_bytes(&value)?)
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Addressindex> for ByteView {
|
impl From<AddressIndex> for ByteView {
|
||||||
fn from(value: Addressindex) -> Self {
|
fn from(value: AddressIndex) -> Self {
|
||||||
Self::new(value.as_bytes())
|
Self::new(value.as_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Addressindex {
|
impl Add<usize> for AddressIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(self.0 + rhs as u32)
|
Self(self.0 + rhs as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Addressindex> for Addressindex {
|
impl Add<AddressIndex> for AddressIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Addressindex) -> Self::Output {
|
fn add(self, rhs: AddressIndex) -> Self::Output {
|
||||||
Self(self.0 + rhs.0)
|
Self(self.0 + rhs.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
28
crates/brk_core/src/structs/_addressindexoutputindex.rs
Normal file
28
crates/brk_core/src/structs/_addressindexoutputindex.rs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
use byteview::ByteView;
|
||||||
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
|
|
||||||
|
use super::{AddressIndex, Outputindex};
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Immutable, IntoBytes, KnownLayout, FromBytes,
|
||||||
|
)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct AddressIndexOutputIndex {
|
||||||
|
addressindex: AddressIndex,
|
||||||
|
_padding: u32,
|
||||||
|
outputindex: Outputindex,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<ByteView> for AddressIndexOutputIndex {
|
||||||
|
type Error = Error;
|
||||||
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<AddressIndexOutputIndex> for ByteView {
|
||||||
|
fn from(value: AddressIndexOutputIndex) -> Self {
|
||||||
|
Self::new(value.as_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
48
crates/brk_core/src/structs/_addresstype.rs
Normal file
48
crates/brk_core/src/structs/_addresstype.rs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
use serde::Serialize;
|
||||||
|
use zerocopy::{Immutable, IntoBytes, KnownLayout, TryFromBytes};
|
||||||
|
|
||||||
|
use super::OutputType;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
TryFromBytes,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
Serialize,
|
||||||
|
)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum AddressType {
|
||||||
|
P2PK65,
|
||||||
|
P2PK33,
|
||||||
|
P2PKH,
|
||||||
|
P2SH,
|
||||||
|
P2WPKH,
|
||||||
|
P2WSH,
|
||||||
|
P2TR,
|
||||||
|
P2A,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OutputType> for AddressType {
|
||||||
|
fn from(value: OutputType) -> Self {
|
||||||
|
match value {
|
||||||
|
OutputType::P2A => Self::P2A,
|
||||||
|
OutputType::P2PK33 => Self::P2PK33,
|
||||||
|
OutputType::P2PK65 => Self::P2PK65,
|
||||||
|
OutputType::P2PKH => Self::P2PKH,
|
||||||
|
OutputType::P2SH => Self::P2SH,
|
||||||
|
OutputType::P2TR => Self::P2TR,
|
||||||
|
OutputType::P2WPKH => Self::P2WPKH,
|
||||||
|
OutputType::P2WSH => Self::P2WSH,
|
||||||
|
OutputType::Empty | OutputType::OpReturn | OutputType::P2MS | OutputType::Unknown => {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,40 +12,42 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
use super::Addresstype;
|
use super::OutputType;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum Addressbytes {
|
pub enum AddressBytes {
|
||||||
P2PK65(P2PK65AddressBytes),
|
P2PK65(P2PK65Bytes),
|
||||||
P2PK33(P2PK33AddressBytes),
|
P2PK33(P2PK33Bytes),
|
||||||
P2PKH(P2PKHAddressBytes),
|
P2PKH(P2PKHBytes),
|
||||||
P2SH(P2SHAddressBytes),
|
P2SH(P2SHBytes),
|
||||||
P2WPKH(P2WPKHAddressBytes),
|
P2WPKH(P2WPKHBytes),
|
||||||
P2WSH(P2WSHAddressBytes),
|
P2WSH(P2WSHBytes),
|
||||||
P2TR(P2TRAddressBytes),
|
P2TR(P2TRBytes),
|
||||||
|
P2A(P2ABytes),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Addressbytes {
|
impl AddressBytes {
|
||||||
pub fn as_slice(&self) -> &[u8] {
|
pub fn as_slice(&self) -> &[u8] {
|
||||||
match self {
|
match self {
|
||||||
Addressbytes::P2PK65(bytes) => &bytes[..],
|
AddressBytes::P2PK65(bytes) => &bytes[..],
|
||||||
Addressbytes::P2PK33(bytes) => &bytes[..],
|
AddressBytes::P2PK33(bytes) => &bytes[..],
|
||||||
Addressbytes::P2PKH(bytes) => &bytes[..],
|
AddressBytes::P2PKH(bytes) => &bytes[..],
|
||||||
Addressbytes::P2SH(bytes) => &bytes[..],
|
AddressBytes::P2SH(bytes) => &bytes[..],
|
||||||
Addressbytes::P2WPKH(bytes) => &bytes[..],
|
AddressBytes::P2WPKH(bytes) => &bytes[..],
|
||||||
Addressbytes::P2WSH(bytes) => &bytes[..],
|
AddressBytes::P2WSH(bytes) => &bytes[..],
|
||||||
Addressbytes::P2TR(bytes) => &bytes[..],
|
AddressBytes::P2TR(bytes) => &bytes[..],
|
||||||
|
AddressBytes::P2A(bytes) => &bytes[..],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<(&ScriptBuf, Addresstype)> for Addressbytes {
|
impl TryFrom<(&ScriptBuf, OutputType)> for AddressBytes {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
fn try_from(tuple: (&ScriptBuf, Addresstype)) -> Result<Self, Self::Error> {
|
fn try_from(tuple: (&ScriptBuf, OutputType)) -> Result<Self, Self::Error> {
|
||||||
let (script, addresstype) = tuple;
|
let (script, outputtype) = tuple;
|
||||||
|
|
||||||
match addresstype {
|
match outputtype {
|
||||||
Addresstype::P2PK65 => {
|
OutputType::P2PK65 => {
|
||||||
let bytes = script.as_bytes();
|
let bytes = script.as_bytes();
|
||||||
let bytes = match bytes.len() {
|
let bytes = match bytes.len() {
|
||||||
67 => &bytes[1..66],
|
67 => &bytes[1..66],
|
||||||
@@ -54,9 +56,9 @@ impl TryFrom<(&ScriptBuf, Addresstype)> for Addressbytes {
|
|||||||
return Err(Error::WrongLength);
|
return Err(Error::WrongLength);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(Self::P2PK65(P2PK65AddressBytes(U8x65::from(bytes))))
|
Ok(Self::P2PK65(P2PK65Bytes(U8x65::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::P2PK33 => {
|
OutputType::P2PK33 => {
|
||||||
let bytes = script.as_bytes();
|
let bytes = script.as_bytes();
|
||||||
let bytes = match bytes.len() {
|
let bytes = match bytes.len() {
|
||||||
35 => &bytes[1..34],
|
35 => &bytes[1..34],
|
||||||
@@ -65,47 +67,50 @@ impl TryFrom<(&ScriptBuf, Addresstype)> for Addressbytes {
|
|||||||
return Err(Error::WrongLength);
|
return Err(Error::WrongLength);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(Self::P2PK33(P2PK33AddressBytes(U8x33::from(bytes))))
|
Ok(Self::P2PK33(P2PK33Bytes(U8x33::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::P2PKH => {
|
OutputType::P2PKH => {
|
||||||
let bytes = &script.as_bytes()[3..23];
|
let bytes = &script.as_bytes()[3..23];
|
||||||
Ok(Self::P2PKH(P2PKHAddressBytes(U8x20::from(bytes))))
|
Ok(Self::P2PKH(P2PKHBytes(U8x20::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::P2SH => {
|
OutputType::P2SH => {
|
||||||
let bytes = &script.as_bytes()[2..22];
|
let bytes = &script.as_bytes()[2..22];
|
||||||
Ok(Self::P2SH(P2SHAddressBytes(U8x20::from(bytes))))
|
Ok(Self::P2SH(P2SHBytes(U8x20::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::P2WPKH => {
|
OutputType::P2WPKH => {
|
||||||
let bytes = &script.as_bytes()[2..];
|
let bytes = &script.as_bytes()[2..];
|
||||||
Ok(Self::P2WPKH(P2WPKHAddressBytes(U8x20::from(bytes))))
|
Ok(Self::P2WPKH(P2WPKHBytes(U8x20::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::P2WSH => {
|
OutputType::P2WSH => {
|
||||||
let bytes = &script.as_bytes()[2..];
|
let bytes = &script.as_bytes()[2..];
|
||||||
Ok(Self::P2WSH(P2WSHAddressBytes(U8x32::from(bytes))))
|
Ok(Self::P2WSH(P2WSHBytes(U8x32::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::P2TR => {
|
OutputType::P2TR => {
|
||||||
let bytes = &script.as_bytes()[2..];
|
let bytes = &script.as_bytes()[2..];
|
||||||
Ok(Self::P2TR(P2TRAddressBytes(U8x32::from(bytes))))
|
Ok(Self::P2TR(P2TRBytes(U8x32::from(bytes))))
|
||||||
}
|
}
|
||||||
Addresstype::Multisig => Err(Error::WrongAddressType),
|
OutputType::P2A => {
|
||||||
Addresstype::PushOnly => Err(Error::WrongAddressType),
|
let bytes = &script.as_bytes()[2..];
|
||||||
Addresstype::Unknown => Err(Error::WrongAddressType),
|
Ok(Self::P2A(P2ABytes(U8x2::from(bytes))))
|
||||||
Addresstype::Empty => Err(Error::WrongAddressType),
|
}
|
||||||
Addresstype::OpReturn => Err(Error::WrongAddressType),
|
OutputType::P2MS => Err(Error::WrongAddressType),
|
||||||
|
OutputType::Unknown => Err(Error::WrongAddressType),
|
||||||
|
OutputType::Empty => Err(Error::WrongAddressType),
|
||||||
|
OutputType::OpReturn => Err(Error::WrongAddressType),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2PK65AddressBytes(U8x65);
|
pub struct P2PK65Bytes(U8x65);
|
||||||
|
|
||||||
impl fmt::Display for P2PK65AddressBytes {
|
impl fmt::Display for P2PK65Bytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.to_hex_string(Case::Lower))
|
write!(f, "{}", self.to_hex_string(Case::Lower))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2PK65AddressBytes {
|
impl Serialize for P2PK65Bytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -114,22 +119,22 @@ impl Serialize for P2PK65AddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2PK65AddressBytes> for Addressbytes {
|
impl From<P2PK65Bytes> for AddressBytes {
|
||||||
fn from(value: P2PK65AddressBytes) -> Self {
|
fn from(value: P2PK65Bytes) -> Self {
|
||||||
Self::P2PK65(value)
|
Self::P2PK65(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2PK33AddressBytes(U8x33);
|
pub struct P2PK33Bytes(U8x33);
|
||||||
|
|
||||||
impl fmt::Display for P2PK33AddressBytes {
|
impl fmt::Display for P2PK33Bytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.to_hex_string(Case::Lower))
|
write!(f, "{}", self.to_hex_string(Case::Lower))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2PK33AddressBytes {
|
impl Serialize for P2PK33Bytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -138,16 +143,16 @@ impl Serialize for P2PK33AddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2PK33AddressBytes> for Addressbytes {
|
impl From<P2PK33Bytes> for AddressBytes {
|
||||||
fn from(value: P2PK33AddressBytes) -> Self {
|
fn from(value: P2PK33Bytes) -> Self {
|
||||||
Self::P2PK33(value)
|
Self::P2PK33(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2PKHAddressBytes(U8x20);
|
pub struct P2PKHBytes(U8x20);
|
||||||
|
|
||||||
impl fmt::Display for P2PKHAddressBytes {
|
impl fmt::Display for P2PKHBytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let script = Builder::new()
|
let script = Builder::new()
|
||||||
.push_opcode(opcodes::all::OP_DUP)
|
.push_opcode(opcodes::all::OP_DUP)
|
||||||
@@ -161,7 +166,7 @@ impl fmt::Display for P2PKHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2PKHAddressBytes {
|
impl Serialize for P2PKHBytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -170,16 +175,16 @@ impl Serialize for P2PKHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2PKHAddressBytes> for Addressbytes {
|
impl From<P2PKHBytes> for AddressBytes {
|
||||||
fn from(value: P2PKHAddressBytes) -> Self {
|
fn from(value: P2PKHBytes) -> Self {
|
||||||
Self::P2PKH(value)
|
Self::P2PKH(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2SHAddressBytes(U8x20);
|
pub struct P2SHBytes(U8x20);
|
||||||
|
|
||||||
impl fmt::Display for P2SHAddressBytes {
|
impl fmt::Display for P2SHBytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let script = Builder::new()
|
let script = Builder::new()
|
||||||
.push_opcode(opcodes::all::OP_HASH160)
|
.push_opcode(opcodes::all::OP_HASH160)
|
||||||
@@ -191,7 +196,7 @@ impl fmt::Display for P2SHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2SHAddressBytes {
|
impl Serialize for P2SHBytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -200,16 +205,16 @@ impl Serialize for P2SHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2SHAddressBytes> for Addressbytes {
|
impl From<P2SHBytes> for AddressBytes {
|
||||||
fn from(value: P2SHAddressBytes) -> Self {
|
fn from(value: P2SHBytes) -> Self {
|
||||||
Self::P2SH(value)
|
Self::P2SH(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2WPKHAddressBytes(U8x20);
|
pub struct P2WPKHBytes(U8x20);
|
||||||
|
|
||||||
impl fmt::Display for P2WPKHAddressBytes {
|
impl fmt::Display for P2WPKHBytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let script = Builder::new().push_int(0).push_slice(*self.0).into_script();
|
let script = Builder::new().push_int(0).push_slice(*self.0).into_script();
|
||||||
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
||||||
@@ -217,7 +222,7 @@ impl fmt::Display for P2WPKHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2WPKHAddressBytes {
|
impl Serialize for P2WPKHBytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -226,16 +231,16 @@ impl Serialize for P2WPKHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2WPKHAddressBytes> for Addressbytes {
|
impl From<P2WPKHBytes> for AddressBytes {
|
||||||
fn from(value: P2WPKHAddressBytes) -> Self {
|
fn from(value: P2WPKHBytes) -> Self {
|
||||||
Self::P2WPKH(value)
|
Self::P2WPKH(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2WSHAddressBytes(U8x32);
|
pub struct P2WSHBytes(U8x32);
|
||||||
|
|
||||||
impl fmt::Display for P2WSHAddressBytes {
|
impl fmt::Display for P2WSHBytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let script = Builder::new().push_int(0).push_slice(*self.0).into_script();
|
let script = Builder::new().push_int(0).push_slice(*self.0).into_script();
|
||||||
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
||||||
@@ -243,7 +248,7 @@ impl fmt::Display for P2WSHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2WSHAddressBytes {
|
impl Serialize for P2WSHBytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -252,16 +257,16 @@ impl Serialize for P2WSHAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2WSHAddressBytes> for Addressbytes {
|
impl From<P2WSHBytes> for AddressBytes {
|
||||||
fn from(value: P2WSHAddressBytes) -> Self {
|
fn from(value: P2WSHBytes) -> Self {
|
||||||
Self::P2WSH(value)
|
Self::P2WSH(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
pub struct P2TRAddressBytes(U8x32);
|
pub struct P2TRBytes(U8x32);
|
||||||
|
|
||||||
impl fmt::Display for P2TRAddressBytes {
|
impl fmt::Display for P2TRBytes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let script = Builder::new().push_int(1).push_slice(*self.0).into_script();
|
let script = Builder::new().push_int(1).push_slice(*self.0).into_script();
|
||||||
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
||||||
@@ -269,7 +274,7 @@ impl fmt::Display for P2TRAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for P2TRAddressBytes {
|
impl Serialize for P2TRBytes {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -278,12 +283,60 @@ impl Serialize for P2TRAddressBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<P2TRAddressBytes> for Addressbytes {
|
impl From<P2TRBytes> for AddressBytes {
|
||||||
fn from(value: P2TRAddressBytes) -> Self {
|
fn from(value: P2TRBytes) -> Self {
|
||||||
Self::P2TR(value)
|
Self::P2TR(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deref, PartialEq, Eq, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||||
|
pub struct P2ABytes(U8x2);
|
||||||
|
|
||||||
|
impl fmt::Display for P2ABytes {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let script = Builder::new().push_int(1).push_slice(*self.0).into_script();
|
||||||
|
let address = Address::from_script(&script, Network::Bitcoin).unwrap();
|
||||||
|
write!(f, "{}", address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serialize for P2ABytes {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
serializer.collect_str(&self.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<P2ABytes> for AddressBytes {
|
||||||
|
fn from(value: P2ABytes) -> Self {
|
||||||
|
Self::P2A(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Clone,
|
||||||
|
Deref,
|
||||||
|
DerefMut,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
FromBytes,
|
||||||
|
Serialize,
|
||||||
|
)]
|
||||||
|
pub struct U8x2([u8; 2]);
|
||||||
|
impl From<&[u8]> for U8x2 {
|
||||||
|
fn from(slice: &[u8]) -> Self {
|
||||||
|
let mut arr = [0; 2];
|
||||||
|
arr.copy_from_slice(slice);
|
||||||
|
Self(arr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
Clone,
|
Clone,
|
||||||
|
|||||||
60
crates/brk_core/src/structs/addressbyteshash.rs
Normal file
60
crates/brk_core/src/structs/addressbyteshash.rs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
use std::hash::Hasher;
|
||||||
|
|
||||||
|
use byteview::ByteView;
|
||||||
|
use derive_deref::Deref;
|
||||||
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
|
|
||||||
|
use super::{AddressBytes, OutputType};
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
FromBytes,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
)]
|
||||||
|
pub struct AddressBytesHash([u8; 8]);
|
||||||
|
|
||||||
|
impl From<(&AddressBytes, OutputType)> for AddressBytesHash {
|
||||||
|
fn from((address_bytes, outputtype): (&AddressBytes, OutputType)) -> Self {
|
||||||
|
let mut hasher = rapidhash::RapidHasher::default();
|
||||||
|
hasher.write(address_bytes.as_slice());
|
||||||
|
let mut slice = hasher.finish().to_le_bytes();
|
||||||
|
slice[0] = slice[0].wrapping_add(outputtype as u8);
|
||||||
|
Self(slice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<[u8; 8]> for AddressBytesHash {
|
||||||
|
fn from(value: [u8; 8]) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<ByteView> for AddressBytesHash {
|
||||||
|
type Error = Error;
|
||||||
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&AddressBytesHash> for ByteView {
|
||||||
|
fn from(value: &AddressBytesHash) -> Self {
|
||||||
|
Self::new(value.as_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AddressBytesHash> for ByteView {
|
||||||
|
fn from(value: AddressBytesHash) -> Self {
|
||||||
|
Self::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
use byteview::ByteView;
|
|
||||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|
||||||
|
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
use super::{Addressindex, Txoutindex};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct AddressindexTxoutindex {
|
|
||||||
addressindex: Addressindex,
|
|
||||||
_padding: u32,
|
|
||||||
txoutindex: Txoutindex,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<ByteView> for AddressindexTxoutindex {
|
|
||||||
type Error = Error;
|
|
||||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
|
||||||
Ok(Self::read_from_bytes(&value)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<AddressindexTxoutindex> for ByteView {
|
|
||||||
fn from(value: AddressindexTxoutindex) -> Self {
|
|
||||||
Self::new(value.as_bytes())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
54
crates/brk_core/src/structs/blockhashprefix.rs
Normal file
54
crates/brk_core/src/structs/blockhashprefix.rs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
use byteview::ByteView;
|
||||||
|
use derive_deref::Deref;
|
||||||
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::{Error, copy_first_8bytes};
|
||||||
|
|
||||||
|
use super::BlockHash;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
FromBytes,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
)]
|
||||||
|
pub struct BlockHashPrefix([u8; 8]);
|
||||||
|
|
||||||
|
impl From<BlockHash> for BlockHashPrefix {
|
||||||
|
fn from(value: BlockHash) -> Self {
|
||||||
|
Self::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&BlockHash> for BlockHashPrefix {
|
||||||
|
fn from(value: &BlockHash) -> Self {
|
||||||
|
Self(copy_first_8bytes(&value[..]).unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<ByteView> for BlockHashPrefix {
|
||||||
|
type Error = Error;
|
||||||
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&BlockHashPrefix> for ByteView {
|
||||||
|
fn from(value: &BlockHashPrefix) -> Self {
|
||||||
|
Self::new(value.as_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<BlockHashPrefix> for ByteView {
|
||||||
|
fn from(value: BlockHashPrefix) -> Self {
|
||||||
|
Self::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
use std::hash::Hasher;
|
|
||||||
|
|
||||||
use byteview::ByteView;
|
|
||||||
use derive_deref::Deref;
|
|
||||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|
||||||
|
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
use super::{Addressbytes, Addresstype, BlockHash, Txid};
|
|
||||||
|
|
||||||
#[derive(
|
|
||||||
Debug,
|
|
||||||
Deref,
|
|
||||||
Clone,
|
|
||||||
Copy,
|
|
||||||
PartialEq,
|
|
||||||
Eq,
|
|
||||||
PartialOrd,
|
|
||||||
Ord,
|
|
||||||
FromBytes,
|
|
||||||
Immutable,
|
|
||||||
IntoBytes,
|
|
||||||
KnownLayout,
|
|
||||||
)]
|
|
||||||
pub struct AddressHash([u8; 8]);
|
|
||||||
impl From<(&Addressbytes, Addresstype)> for AddressHash {
|
|
||||||
fn from((addressbytes, addresstype): (&Addressbytes, Addresstype)) -> Self {
|
|
||||||
let mut hasher = rapidhash::RapidHasher::default();
|
|
||||||
hasher.write(addressbytes.as_slice());
|
|
||||||
let mut slice = hasher.finish().to_le_bytes();
|
|
||||||
slice[0] = slice[0].wrapping_add(addresstype as u8);
|
|
||||||
Self(slice)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<[u8; 8]> for AddressHash {
|
|
||||||
fn from(value: [u8; 8]) -> Self {
|
|
||||||
Self(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl TryFrom<ByteView> for AddressHash {
|
|
||||||
type Error = Error;
|
|
||||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
|
||||||
Ok(Self::read_from_bytes(&value)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<&AddressHash> for ByteView {
|
|
||||||
fn from(value: &AddressHash) -> Self {
|
|
||||||
Self::new(value.as_bytes())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<AddressHash> for ByteView {
|
|
||||||
fn from(value: AddressHash) -> Self {
|
|
||||||
Self::from(&value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(
|
|
||||||
Debug,
|
|
||||||
Deref,
|
|
||||||
Clone,
|
|
||||||
Copy,
|
|
||||||
PartialEq,
|
|
||||||
Eq,
|
|
||||||
PartialOrd,
|
|
||||||
Ord,
|
|
||||||
FromBytes,
|
|
||||||
Immutable,
|
|
||||||
IntoBytes,
|
|
||||||
KnownLayout,
|
|
||||||
)]
|
|
||||||
pub struct BlockHashPrefix([u8; 8]);
|
|
||||||
impl From<BlockHash> for BlockHashPrefix {
|
|
||||||
fn from(value: BlockHash) -> Self {
|
|
||||||
Self::from(&value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<&BlockHash> for BlockHashPrefix {
|
|
||||||
fn from(value: &BlockHash) -> Self {
|
|
||||||
Self(copy_first_8bytes(&value[..]).unwrap())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl TryFrom<ByteView> for BlockHashPrefix {
|
|
||||||
type Error = Error;
|
|
||||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
|
||||||
Ok(Self::read_from_bytes(&value)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<&BlockHashPrefix> for ByteView {
|
|
||||||
fn from(value: &BlockHashPrefix) -> Self {
|
|
||||||
Self::new(value.as_bytes())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<BlockHashPrefix> for ByteView {
|
|
||||||
fn from(value: BlockHashPrefix) -> Self {
|
|
||||||
Self::from(&value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(
|
|
||||||
Debug,
|
|
||||||
Deref,
|
|
||||||
Clone,
|
|
||||||
Copy,
|
|
||||||
PartialEq,
|
|
||||||
Eq,
|
|
||||||
PartialOrd,
|
|
||||||
Ord,
|
|
||||||
FromBytes,
|
|
||||||
Immutable,
|
|
||||||
IntoBytes,
|
|
||||||
KnownLayout,
|
|
||||||
)]
|
|
||||||
pub struct TxidPrefix([u8; 8]);
|
|
||||||
impl From<Txid> for TxidPrefix {
|
|
||||||
fn from(value: Txid) -> Self {
|
|
||||||
Self::from(&value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<&Txid> for TxidPrefix {
|
|
||||||
fn from(value: &Txid) -> Self {
|
|
||||||
Self(copy_first_8bytes(&value[..]).unwrap())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl TryFrom<ByteView> for TxidPrefix {
|
|
||||||
type Error = Error;
|
|
||||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
|
||||||
Ok(Self::read_from_bytes(&value)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<&TxidPrefix> for ByteView {
|
|
||||||
fn from(value: &TxidPrefix) -> Self {
|
|
||||||
Self::new(value.as_bytes())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<TxidPrefix> for ByteView {
|
|
||||||
fn from(value: TxidPrefix) -> Self {
|
|
||||||
Self::from(&value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<[u8; 8]> for TxidPrefix {
|
|
||||||
fn from(value: [u8; 8]) -> Self {
|
|
||||||
Self(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn copy_first_8bytes(slice: &[u8]) -> Result<[u8; 8], ()> {
|
|
||||||
let mut buf: [u8; 8] = [0; 8];
|
|
||||||
let buf_len = buf.len();
|
|
||||||
if slice.len() < buf_len {
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
slice.iter().take(buf_len).enumerate().for_each(|(i, r)| {
|
|
||||||
buf[i] = *r;
|
|
||||||
});
|
|
||||||
Ok(buf)
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ use jiff::{Span, civil::Date as Date_, tz::TimeZone};
|
|||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
use super::{Dateindex, Timestamp};
|
use super::{DateIndex, Timestamp};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, FromBytes, Immutable, IntoBytes, KnownLayout,
|
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, FromBytes, Immutable, IntoBytes, KnownLayout,
|
||||||
@@ -58,9 +58,9 @@ impl From<Timestamp> for Date {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for Date {
|
impl From<DateIndex> for Date {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
if value == Dateindex::default() {
|
if value == DateIndex::default() {
|
||||||
Date::INDEX_ZERO
|
Date::INDEX_ZERO
|
||||||
} else {
|
} else {
|
||||||
Self::from(
|
Self::from(
|
||||||
|
|||||||
@@ -23,38 +23,38 @@ use super::Date;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Dateindex(u16);
|
pub struct DateIndex(u16);
|
||||||
|
|
||||||
impl Dateindex {
|
impl DateIndex {
|
||||||
pub const BYTES: usize = size_of::<Self>();
|
pub const BYTES: usize = size_of::<Self>();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for usize {
|
impl From<DateIndex> for usize {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Dateindex {
|
impl From<usize> for DateIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u16)
|
Self(value as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for i64 {
|
impl From<DateIndex> for i64 {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
value.0 as i64
|
value.0 as i64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Dateindex {
|
impl Add<usize> for DateIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(self.0 + rhs as u16)
|
Self(self.0 + rhs as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Date> for Dateindex {
|
impl TryFrom<Date> for DateIndex {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
fn try_from(value: Date) -> Result<Self, Self::Error> {
|
fn try_from(value: Date) -> Result<Self, Self::Error> {
|
||||||
let value_ = jiff::civil::Date::from(value);
|
let value_ = jiff::civil::Date::from(value);
|
||||||
@@ -72,7 +72,7 @@ impl TryFrom<Date> for Dateindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Dateindex {
|
impl CheckedSub for DateIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::CheckedSub;
|
use crate::CheckedSub;
|
||||||
|
|
||||||
use super::{Date, Dateindex, Yearindex};
|
use super::{Date, DateIndex, YearIndex};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -23,27 +23,27 @@ use super::{Date, Dateindex, Yearindex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Decadeindex(u8);
|
pub struct DecadeIndex(u8);
|
||||||
|
|
||||||
impl From<u8> for Decadeindex {
|
impl From<u8> for DecadeIndex {
|
||||||
fn from(value: u8) -> Self {
|
fn from(value: u8) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Decadeindex {
|
impl From<usize> for DecadeIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u8)
|
Self(value as u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Decadeindex> for usize {
|
impl From<DecadeIndex> for usize {
|
||||||
fn from(value: Decadeindex) -> Self {
|
fn from(value: DecadeIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Decadeindex {
|
impl Add<usize> for DecadeIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,13 +51,13 @@ impl Add<usize> for Decadeindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for Decadeindex {
|
impl From<DateIndex> for DecadeIndex {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
Self::from(Date::from(value))
|
Self::from(Date::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Date> for Decadeindex {
|
impl From<Date> for DecadeIndex {
|
||||||
fn from(value: Date) -> Self {
|
fn from(value: Date) -> Self {
|
||||||
let year = value.year();
|
let year = value.year();
|
||||||
if year < 2000 {
|
if year < 2000 {
|
||||||
@@ -67,14 +67,14 @@ impl From<Date> for Decadeindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Decadeindex {
|
impl CheckedSub for DecadeIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Yearindex> for Decadeindex {
|
impl From<YearIndex> for DecadeIndex {
|
||||||
fn from(value: Yearindex) -> Self {
|
fn from(value: YearIndex) -> Self {
|
||||||
let v = usize::from(value);
|
let v = usize::from(value);
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
Self(0)
|
Self(0)
|
||||||
|
|||||||
@@ -23,27 +23,27 @@ use super::Height;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Difficultyepoch(u16);
|
pub struct DifficultyEpoch(u16);
|
||||||
|
|
||||||
impl From<u16> for Difficultyepoch {
|
impl From<u16> for DifficultyEpoch {
|
||||||
fn from(value: u16) -> Self {
|
fn from(value: u16) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Difficultyepoch {
|
impl From<usize> for DifficultyEpoch {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u16)
|
Self(value as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Difficultyepoch> for usize {
|
impl From<DifficultyEpoch> for usize {
|
||||||
fn from(value: Difficultyepoch) -> Self {
|
fn from(value: DifficultyEpoch) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Difficultyepoch {
|
impl Add<usize> for DifficultyEpoch {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,13 +51,13 @@ impl Add<usize> for Difficultyepoch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Height> for Difficultyepoch {
|
impl From<Height> for DifficultyEpoch {
|
||||||
fn from(value: Height) -> Self {
|
fn from(value: Height) -> Self {
|
||||||
Self((u32::from(value) / 2016) as u16)
|
Self((u32::from(value) / 2016) as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Difficultyepoch {
|
impl CheckedSub for DifficultyEpoch {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,27 +23,27 @@ use super::Height;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Halvingepoch(u8);
|
pub struct HalvingEpoch(u8);
|
||||||
|
|
||||||
impl From<u8> for Halvingepoch {
|
impl From<u8> for HalvingEpoch {
|
||||||
fn from(value: u8) -> Self {
|
fn from(value: u8) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Halvingepoch {
|
impl From<usize> for HalvingEpoch {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u8)
|
Self(value as u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Halvingepoch> for usize {
|
impl From<HalvingEpoch> for usize {
|
||||||
fn from(value: Halvingepoch) -> Self {
|
fn from(value: HalvingEpoch) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Halvingepoch {
|
impl Add<usize> for HalvingEpoch {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,13 +51,13 @@ impl Add<usize> for Halvingepoch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Height> for Halvingepoch {
|
impl From<Height> for HalvingEpoch {
|
||||||
fn from(value: Height) -> Self {
|
fn from(value: Height) -> Self {
|
||||||
Self((u32::from(value) / 210_000) as u8)
|
Self((u32::from(value) / 210_000) as u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Halvingepoch {
|
impl CheckedSub for HalvingEpoch {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,49 +25,49 @@ use super::Vin;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Txinindex(u64);
|
pub struct InputIndex(u64);
|
||||||
|
|
||||||
impl Txinindex {
|
impl InputIndex {
|
||||||
pub fn incremented(self) -> Self {
|
pub fn incremented(self) -> Self {
|
||||||
Self(*self + 1)
|
Self(*self + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Txinindex> for Txinindex {
|
impl Add<InputIndex> for InputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Txinindex) -> Self::Output {
|
fn add(self, rhs: InputIndex) -> Self::Output {
|
||||||
Self(self.0 + rhs.0)
|
Self(self.0 + rhs.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Vin> for Txinindex {
|
impl Add<Vin> for InputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Vin) -> Self::Output {
|
fn add(self, rhs: Vin) -> Self::Output {
|
||||||
Self(self.0 + u64::from(rhs))
|
Self(self.0 + u64::from(rhs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Txinindex {
|
impl Add<usize> for InputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(self.0 + rhs as u64)
|
Self(self.0 + rhs as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddAssign<Txinindex> for Txinindex {
|
impl AddAssign<InputIndex> for InputIndex {
|
||||||
fn add_assign(&mut self, rhs: Txinindex) {
|
fn add_assign(&mut self, rhs: InputIndex) {
|
||||||
self.0 += rhs.0
|
self.0 += rhs.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub<Txinindex> for Txinindex {
|
impl CheckedSub<InputIndex> for InputIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self::from)
|
self.0.checked_sub(rhs.0).map(Self::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Txinindex> for u32 {
|
impl From<InputIndex> for u32 {
|
||||||
fn from(value: Txinindex) -> Self {
|
fn from(value: InputIndex) -> Self {
|
||||||
if value.0 > u32::MAX as u64 {
|
if value.0 > u32::MAX as u64 {
|
||||||
panic!()
|
panic!()
|
||||||
}
|
}
|
||||||
@@ -75,24 +75,24 @@ impl From<Txinindex> for u32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u64> for Txinindex {
|
impl From<u64> for InputIndex {
|
||||||
fn from(value: u64) -> Self {
|
fn from(value: u64) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txinindex> for u64 {
|
impl From<InputIndex> for u64 {
|
||||||
fn from(value: Txinindex) -> Self {
|
fn from(value: InputIndex) -> Self {
|
||||||
value.0
|
value.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Txinindex {
|
impl From<usize> for InputIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u64)
|
Self(value as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txinindex> for usize {
|
impl From<InputIndex> for usize {
|
||||||
fn from(value: Txinindex) -> Self {
|
fn from(value: InputIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
mod addressbytes;
|
mod addressbytes;
|
||||||
mod addressindex;
|
mod addressbyteshash;
|
||||||
mod addressindextxoutindex;
|
// mod addressindex;
|
||||||
mod addresstype;
|
// mod addressindexoutputindex;
|
||||||
mod addresstypeindex;
|
// mod addresstype;
|
||||||
mod bitcoin;
|
mod bitcoin;
|
||||||
mod blockhash;
|
mod blockhash;
|
||||||
|
mod blockhashprefix;
|
||||||
mod cents;
|
mod cents;
|
||||||
mod compressed;
|
|
||||||
mod date;
|
mod date;
|
||||||
mod dateindex;
|
mod dateindex;
|
||||||
mod decadeindex;
|
mod decadeindex;
|
||||||
@@ -15,8 +15,12 @@ mod dollars;
|
|||||||
mod feerate;
|
mod feerate;
|
||||||
mod halvingepoch;
|
mod halvingepoch;
|
||||||
mod height;
|
mod height;
|
||||||
|
mod inputindex;
|
||||||
mod monthindex;
|
mod monthindex;
|
||||||
mod ohlc;
|
mod ohlc;
|
||||||
|
mod outputindex;
|
||||||
|
mod outputtype;
|
||||||
|
mod outputtypeindex;
|
||||||
mod quarterindex;
|
mod quarterindex;
|
||||||
mod rawlocktime;
|
mod rawlocktime;
|
||||||
mod sats;
|
mod sats;
|
||||||
@@ -26,9 +30,8 @@ mod stored_u8;
|
|||||||
mod stored_usize;
|
mod stored_usize;
|
||||||
mod timestamp;
|
mod timestamp;
|
||||||
mod txid;
|
mod txid;
|
||||||
|
mod txidprefix;
|
||||||
mod txindex;
|
mod txindex;
|
||||||
mod txinindex;
|
|
||||||
mod txoutindex;
|
|
||||||
mod txversion;
|
mod txversion;
|
||||||
mod unit;
|
mod unit;
|
||||||
mod vin;
|
mod vin;
|
||||||
@@ -38,14 +41,14 @@ mod weight;
|
|||||||
mod yearindex;
|
mod yearindex;
|
||||||
|
|
||||||
pub use addressbytes::*;
|
pub use addressbytes::*;
|
||||||
pub use addressindex::*;
|
pub use addressbyteshash::*;
|
||||||
pub use addressindextxoutindex::*;
|
// pub use addressindex::*;
|
||||||
pub use addresstype::*;
|
// pub use addressindexoutputindex::*;
|
||||||
pub use addresstypeindex::*;
|
// pub use addresstype::*;
|
||||||
pub use bitcoin::*;
|
pub use bitcoin::*;
|
||||||
pub use blockhash::*;
|
pub use blockhash::*;
|
||||||
|
pub use blockhashprefix::*;
|
||||||
pub use cents::*;
|
pub use cents::*;
|
||||||
pub use compressed::*;
|
|
||||||
pub use date::*;
|
pub use date::*;
|
||||||
pub use dateindex::*;
|
pub use dateindex::*;
|
||||||
pub use decadeindex::*;
|
pub use decadeindex::*;
|
||||||
@@ -54,8 +57,12 @@ pub use dollars::*;
|
|||||||
pub use feerate::*;
|
pub use feerate::*;
|
||||||
pub use halvingepoch::*;
|
pub use halvingepoch::*;
|
||||||
pub use height::*;
|
pub use height::*;
|
||||||
|
pub use inputindex::*;
|
||||||
pub use monthindex::*;
|
pub use monthindex::*;
|
||||||
pub use ohlc::*;
|
pub use ohlc::*;
|
||||||
|
pub use outputindex::*;
|
||||||
|
pub use outputtype::*;
|
||||||
|
pub use outputtypeindex::*;
|
||||||
pub use quarterindex::*;
|
pub use quarterindex::*;
|
||||||
pub use rawlocktime::*;
|
pub use rawlocktime::*;
|
||||||
pub use sats::*;
|
pub use sats::*;
|
||||||
@@ -65,9 +72,8 @@ pub use stored_u64::*;
|
|||||||
pub use stored_usize::*;
|
pub use stored_usize::*;
|
||||||
pub use timestamp::*;
|
pub use timestamp::*;
|
||||||
pub use txid::*;
|
pub use txid::*;
|
||||||
|
pub use txidprefix::*;
|
||||||
pub use txindex::*;
|
pub use txindex::*;
|
||||||
pub use txinindex::*;
|
|
||||||
pub use txoutindex::*;
|
|
||||||
pub use txversion::*;
|
pub use txversion::*;
|
||||||
pub use unit::*;
|
pub use unit::*;
|
||||||
pub use vin::*;
|
pub use vin::*;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::CheckedSub;
|
use crate::CheckedSub;
|
||||||
|
|
||||||
use super::{Date, Dateindex, Yearindex};
|
use super::{Date, DateIndex, YearIndex};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -23,27 +23,27 @@ use super::{Date, Dateindex, Yearindex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Monthindex(u16);
|
pub struct MonthIndex(u16);
|
||||||
|
|
||||||
impl From<u16> for Monthindex {
|
impl From<u16> for MonthIndex {
|
||||||
fn from(value: u16) -> Self {
|
fn from(value: u16) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Monthindex {
|
impl From<usize> for MonthIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u16)
|
Self(value as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Monthindex> for usize {
|
impl From<MonthIndex> for usize {
|
||||||
fn from(value: Monthindex) -> Self {
|
fn from(value: MonthIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Monthindex {
|
impl Add<usize> for MonthIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,19 +51,19 @@ impl Add<usize> for Monthindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for Monthindex {
|
impl From<DateIndex> for MonthIndex {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
Self::from(Date::from(value))
|
Self::from(Date::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Date> for Monthindex {
|
impl From<Date> for MonthIndex {
|
||||||
fn from(value: Date) -> Self {
|
fn from(value: Date) -> Self {
|
||||||
Self(u16::from(Yearindex::from(value)) * 12 + value.month() as u16 - 1)
|
Self(u16::from(YearIndex::from(value)) * 12 + value.month() as u16 - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Monthindex {
|
impl CheckedSub for MonthIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ use super::Vout;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Txoutindex(u64);
|
pub struct OutputIndex(u64);
|
||||||
|
|
||||||
impl Txoutindex {
|
impl OutputIndex {
|
||||||
pub const COINBASE: Self = Self(u64::MAX);
|
pub const COINBASE: Self = Self(u64::MAX);
|
||||||
|
|
||||||
pub fn incremented(self) -> Self {
|
pub fn incremented(self) -> Self {
|
||||||
@@ -39,41 +39,41 @@ impl Txoutindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Txoutindex> for Txoutindex {
|
impl Add<OutputIndex> for OutputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Txoutindex) -> Self::Output {
|
fn add(self, rhs: OutputIndex) -> Self::Output {
|
||||||
Self(self.0 + rhs.0)
|
Self(self.0 + rhs.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Vout> for Txoutindex {
|
impl Add<Vout> for OutputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Vout) -> Self::Output {
|
fn add(self, rhs: Vout) -> Self::Output {
|
||||||
Self(self.0 + u64::from(rhs))
|
Self(self.0 + u64::from(rhs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Txoutindex {
|
impl Add<usize> for OutputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(self.0 + rhs as u64)
|
Self(self.0 + rhs as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddAssign<Txoutindex> for Txoutindex {
|
impl AddAssign<OutputIndex> for OutputIndex {
|
||||||
fn add_assign(&mut self, rhs: Txoutindex) {
|
fn add_assign(&mut self, rhs: OutputIndex) {
|
||||||
self.0 += rhs.0
|
self.0 += rhs.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub<Txoutindex> for Txoutindex {
|
impl CheckedSub<OutputIndex> for OutputIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self::from)
|
self.0.checked_sub(rhs.0).map(Self::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Txoutindex> for u32 {
|
impl From<OutputIndex> for u32 {
|
||||||
fn from(value: Txoutindex) -> Self {
|
fn from(value: OutputIndex) -> Self {
|
||||||
if value.0 > u32::MAX as u64 {
|
if value.0 > u32::MAX as u64 {
|
||||||
panic!()
|
panic!()
|
||||||
}
|
}
|
||||||
@@ -81,24 +81,24 @@ impl From<Txoutindex> for u32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u64> for Txoutindex {
|
impl From<u64> for OutputIndex {
|
||||||
fn from(value: u64) -> Self {
|
fn from(value: u64) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txoutindex> for u64 {
|
impl From<OutputIndex> for u64 {
|
||||||
fn from(value: Txoutindex) -> Self {
|
fn from(value: OutputIndex) -> Self {
|
||||||
value.0
|
value.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Txoutindex {
|
impl From<usize> for OutputIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u64)
|
Self(value as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txoutindex> for usize {
|
impl From<OutputIndex> for usize {
|
||||||
fn from(value: Txoutindex) -> Self {
|
fn from(value: OutputIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,38 @@
|
|||||||
use bitcoin::ScriptBuf;
|
use bitcoin::{ScriptBuf, opcodes::all::OP_PUSHBYTES_2};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use zerocopy::{Immutable, IntoBytes, KnownLayout, TryFromBytes};
|
use zerocopy::{Immutable, IntoBytes, KnownLayout, TryFromBytes};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, TryFromBytes, Immutable, IntoBytes, KnownLayout, Serialize,
|
Debug,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
TryFromBytes,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
Serialize,
|
||||||
)]
|
)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Addresstype {
|
pub enum OutputType {
|
||||||
P2PK65,
|
P2PK65,
|
||||||
P2PK33,
|
P2PK33,
|
||||||
P2PKH,
|
P2PKH,
|
||||||
|
P2MS,
|
||||||
P2SH,
|
P2SH,
|
||||||
|
OpReturn,
|
||||||
P2WPKH,
|
P2WPKH,
|
||||||
P2WSH,
|
P2WSH,
|
||||||
P2TR,
|
P2TR,
|
||||||
Multisig = 251,
|
P2A,
|
||||||
PushOnly = 252,
|
|
||||||
OpReturn = 253,
|
|
||||||
Empty = 254,
|
Empty = 254,
|
||||||
Unknown = 255,
|
Unknown = 255,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&ScriptBuf> for Addresstype {
|
impl From<&ScriptBuf> for OutputType {
|
||||||
fn from(script: &ScriptBuf) -> Self {
|
fn from(script: &ScriptBuf) -> Self {
|
||||||
if script.is_p2pk() {
|
if script.is_p2pk() {
|
||||||
let bytes = script.as_bytes();
|
let bytes = script.as_bytes();
|
||||||
@@ -36,22 +47,26 @@ impl From<&ScriptBuf> for Addresstype {
|
|||||||
}
|
}
|
||||||
} else if script.is_p2pkh() {
|
} else if script.is_p2pkh() {
|
||||||
Self::P2PKH
|
Self::P2PKH
|
||||||
|
} else if script.is_multisig() {
|
||||||
|
Self::P2MS
|
||||||
} else if script.is_p2sh() {
|
} else if script.is_p2sh() {
|
||||||
Self::P2SH
|
Self::P2SH
|
||||||
|
} else if script.is_op_return() {
|
||||||
|
Self::OpReturn
|
||||||
} else if script.is_p2wpkh() {
|
} else if script.is_p2wpkh() {
|
||||||
Self::P2WPKH
|
Self::P2WPKH
|
||||||
} else if script.is_p2wsh() {
|
} else if script.is_p2wsh() {
|
||||||
Self::P2WSH
|
Self::P2WSH
|
||||||
} else if script.is_p2tr() {
|
} else if script.is_p2tr() {
|
||||||
Self::P2TR
|
Self::P2TR
|
||||||
|
} else if script.witness_version() == Some(bitcoin::WitnessVersion::V1)
|
||||||
|
&& script.len() == 4
|
||||||
|
&& script.as_bytes()[1] == OP_PUSHBYTES_2.to_u8()
|
||||||
|
&& script.as_bytes()[2..4] == [78, 115]
|
||||||
|
{
|
||||||
|
Self::P2A
|
||||||
} else if script.is_empty() {
|
} else if script.is_empty() {
|
||||||
Self::Empty
|
Self::Empty
|
||||||
} else if script.is_op_return() {
|
|
||||||
Self::OpReturn
|
|
||||||
} else if script.is_push_only() {
|
|
||||||
Self::PushOnly
|
|
||||||
} else if script.is_multisig() {
|
|
||||||
Self::Multisig
|
|
||||||
} else {
|
} else {
|
||||||
Self::Unknown
|
Self::Unknown
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
|
use byteview::ByteView;
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
PartialEq,
|
PartialEq,
|
||||||
@@ -19,9 +22,9 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Addresstypeindex(u32);
|
pub struct OutputTypeIndex(u32);
|
||||||
|
|
||||||
impl Addresstypeindex {
|
impl OutputTypeIndex {
|
||||||
pub fn increment(&mut self) {
|
pub fn increment(&mut self) {
|
||||||
self.0 += 1;
|
self.0 += 1;
|
||||||
}
|
}
|
||||||
@@ -37,47 +40,58 @@ impl Addresstypeindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u32> for Addresstypeindex {
|
impl From<u32> for OutputTypeIndex {
|
||||||
fn from(value: u32) -> Self {
|
fn from(value: u32) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u64> for Addresstypeindex {
|
impl From<u64> for OutputTypeIndex {
|
||||||
fn from(value: u64) -> Self {
|
fn from(value: u64) -> Self {
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Addresstypeindex> for u64 {
|
impl From<OutputTypeIndex> for u64 {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
value.0 as u64
|
value.0 as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Addresstypeindex {
|
impl From<usize> for OutputTypeIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Addresstypeindex> for usize {
|
impl From<OutputTypeIndex> for usize {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Addresstypeindex {
|
impl Add<usize> for OutputTypeIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(self.0 + rhs as u32)
|
Self(self.0 + rhs as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Addresstypeindex> for Addresstypeindex {
|
impl Add<OutputTypeIndex> for OutputTypeIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Addresstypeindex) -> Self::Output {
|
fn add(self, rhs: OutputTypeIndex) -> Self::Output {
|
||||||
Self(self.0 + rhs.0)
|
Self(self.0 + rhs.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl TryFrom<ByteView> for OutputTypeIndex {
|
||||||
|
type Error = Error;
|
||||||
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<OutputTypeIndex> for ByteView {
|
||||||
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
|
Self::new(value.as_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -96,23 +110,23 @@ impl Add<Addresstypeindex> for Addresstypeindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Emptyindex(Addresstypeindex);
|
pub struct EmptyOutputIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for Emptyindex {
|
impl From<OutputTypeIndex> for EmptyOutputIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Emptyindex> for usize {
|
impl From<EmptyOutputIndex> for usize {
|
||||||
fn from(value: Emptyindex) -> Self {
|
fn from(value: EmptyOutputIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for Emptyindex {
|
impl From<usize> for EmptyOutputIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for Emptyindex {
|
impl Add<usize> for EmptyOutputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -136,23 +150,23 @@ impl Add<usize> for Emptyindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Multisigindex(Addresstypeindex);
|
pub struct P2MSIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for Multisigindex {
|
impl From<OutputTypeIndex> for P2MSIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Multisigindex> for usize {
|
impl From<P2MSIndex> for usize {
|
||||||
fn from(value: Multisigindex) -> Self {
|
fn from(value: P2MSIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for Multisigindex {
|
impl From<usize> for P2MSIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for Multisigindex {
|
impl Add<usize> for P2MSIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -176,23 +190,23 @@ impl Add<usize> for Multisigindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Opreturnindex(Addresstypeindex);
|
pub struct P2AIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for Opreturnindex {
|
impl From<OutputTypeIndex> for P2AIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Opreturnindex> for usize {
|
impl From<P2AIndex> for usize {
|
||||||
fn from(value: Opreturnindex) -> Self {
|
fn from(value: P2AIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for Opreturnindex {
|
impl From<usize> for P2AIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for Opreturnindex {
|
impl Add<usize> for P2AIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -216,23 +230,23 @@ impl Add<usize> for Opreturnindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Pushonlyindex(Addresstypeindex);
|
pub struct OpReturnIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for Pushonlyindex {
|
impl From<OutputTypeIndex> for OpReturnIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Pushonlyindex> for usize {
|
impl From<OpReturnIndex> for usize {
|
||||||
fn from(value: Pushonlyindex) -> Self {
|
fn from(value: OpReturnIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for Pushonlyindex {
|
impl From<usize> for OpReturnIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for Pushonlyindex {
|
impl Add<usize> for OpReturnIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -256,23 +270,23 @@ impl Add<usize> for Pushonlyindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Unknownindex(Addresstypeindex);
|
pub struct UnknownOutputIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for Unknownindex {
|
impl From<OutputTypeIndex> for UnknownOutputIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Unknownindex> for usize {
|
impl From<UnknownOutputIndex> for usize {
|
||||||
fn from(value: Unknownindex) -> Self {
|
fn from(value: UnknownOutputIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for Unknownindex {
|
impl From<usize> for UnknownOutputIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for Unknownindex {
|
impl Add<usize> for UnknownOutputIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -296,23 +310,23 @@ impl Add<usize> for Unknownindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2PK33index(Addresstypeindex);
|
pub struct P2PK33Index(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2PK33index {
|
impl From<OutputTypeIndex> for P2PK33Index {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2PK33index> for usize {
|
impl From<P2PK33Index> for usize {
|
||||||
fn from(value: P2PK33index) -> Self {
|
fn from(value: P2PK33Index) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2PK33index {
|
impl From<usize> for P2PK33Index {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2PK33index {
|
impl Add<usize> for P2PK33Index {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -336,23 +350,23 @@ impl Add<usize> for P2PK33index {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2PK65index(Addresstypeindex);
|
pub struct P2PK65Index(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2PK65index {
|
impl From<OutputTypeIndex> for P2PK65Index {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2PK65index> for usize {
|
impl From<P2PK65Index> for usize {
|
||||||
fn from(value: P2PK65index) -> Self {
|
fn from(value: P2PK65Index) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2PK65index {
|
impl From<usize> for P2PK65Index {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2PK65index {
|
impl Add<usize> for P2PK65Index {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -376,23 +390,23 @@ impl Add<usize> for P2PK65index {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2PKHindex(Addresstypeindex);
|
pub struct P2PKHIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2PKHindex {
|
impl From<OutputTypeIndex> for P2PKHIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2PKHindex> for usize {
|
impl From<P2PKHIndex> for usize {
|
||||||
fn from(value: P2PKHindex) -> Self {
|
fn from(value: P2PKHIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2PKHindex {
|
impl From<usize> for P2PKHIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2PKHindex {
|
impl Add<usize> for P2PKHIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -416,23 +430,23 @@ impl Add<usize> for P2PKHindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2SHindex(Addresstypeindex);
|
pub struct P2SHIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2SHindex {
|
impl From<OutputTypeIndex> for P2SHIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2SHindex> for usize {
|
impl From<P2SHIndex> for usize {
|
||||||
fn from(value: P2SHindex) -> Self {
|
fn from(value: P2SHIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2SHindex {
|
impl From<usize> for P2SHIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2SHindex {
|
impl Add<usize> for P2SHIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -456,23 +470,23 @@ impl Add<usize> for P2SHindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2TRindex(Addresstypeindex);
|
pub struct P2TRIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2TRindex {
|
impl From<OutputTypeIndex> for P2TRIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2TRindex> for usize {
|
impl From<P2TRIndex> for usize {
|
||||||
fn from(value: P2TRindex) -> Self {
|
fn from(value: P2TRIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2TRindex {
|
impl From<usize> for P2TRIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2TRindex {
|
impl Add<usize> for P2TRIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -496,23 +510,23 @@ impl Add<usize> for P2TRindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2WPKHindex(Addresstypeindex);
|
pub struct P2WPKHIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2WPKHindex {
|
impl From<OutputTypeIndex> for P2WPKHIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2WPKHindex> for usize {
|
impl From<P2WPKHIndex> for usize {
|
||||||
fn from(value: P2WPKHindex) -> Self {
|
fn from(value: P2WPKHIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2WPKHindex {
|
impl From<usize> for P2WPKHIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2WPKHindex {
|
impl Add<usize> for P2WPKHIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -536,23 +550,23 @@ impl Add<usize> for P2WPKHindex {
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct P2WSHindex(Addresstypeindex);
|
pub struct P2WSHIndex(OutputTypeIndex);
|
||||||
impl From<Addresstypeindex> for P2WSHindex {
|
impl From<OutputTypeIndex> for P2WSHIndex {
|
||||||
fn from(value: Addresstypeindex) -> Self {
|
fn from(value: OutputTypeIndex) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<P2WSHindex> for usize {
|
impl From<P2WSHIndex> for usize {
|
||||||
fn from(value: P2WSHindex) -> Self {
|
fn from(value: P2WSHIndex) -> Self {
|
||||||
Self::from(*value)
|
Self::from(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<usize> for P2WSHindex {
|
impl From<usize> for P2WSHIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(Addresstypeindex::from(value))
|
Self(OutputTypeIndex::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Add<usize> for P2WSHindex {
|
impl Add<usize> for P2WSHIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(*self + rhs)
|
Self(*self + rhs)
|
||||||
@@ -5,7 +5,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::CheckedSub;
|
use crate::CheckedSub;
|
||||||
|
|
||||||
use super::Monthindex;
|
use super::MonthIndex;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -23,27 +23,27 @@ use super::Monthindex;
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Quarterindex(u16);
|
pub struct QuarterIndex(u16);
|
||||||
|
|
||||||
impl From<u16> for Quarterindex {
|
impl From<u16> for QuarterIndex {
|
||||||
fn from(value: u16) -> Self {
|
fn from(value: u16) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Quarterindex {
|
impl From<usize> for QuarterIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u16)
|
Self(value as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Quarterindex> for usize {
|
impl From<QuarterIndex> for usize {
|
||||||
fn from(value: Quarterindex) -> Self {
|
fn from(value: QuarterIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Quarterindex {
|
impl Add<usize> for QuarterIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,13 +51,13 @@ impl Add<usize> for Quarterindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Monthindex> for Quarterindex {
|
impl From<MonthIndex> for QuarterIndex {
|
||||||
fn from(value: Monthindex) -> Self {
|
fn from(value: MonthIndex) -> Self {
|
||||||
Self((usize::from(value) / 3) as u16)
|
Self((usize::from(value) / 3) as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Quarterindex {
|
impl CheckedSub for QuarterIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ impl From<u32> for StoredU32 {
|
|||||||
|
|
||||||
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 {
|
||||||
|
panic!("usize too big (value = {value})")
|
||||||
|
}
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,3 +80,9 @@ impl From<StoredU32> for f64 {
|
|||||||
value.0 as f64
|
value.0 as f64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<StoredU32> for usize {
|
||||||
|
fn from(value: StoredU32) -> Self {
|
||||||
|
value.0 as usize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::CheckedSub;
|
use crate::CheckedSub;
|
||||||
|
|
||||||
use super::{Txindex, Txinindex, Txoutindex};
|
use super::{InputIndex, OutputIndex, TxIndex};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -80,20 +80,20 @@ impl From<StoredU64> for f64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Txindex> for StoredU64 {
|
impl From<TxIndex> for StoredU64 {
|
||||||
fn from(value: Txindex) -> Self {
|
fn from(value: TxIndex) -> Self {
|
||||||
Self(*value as u64)
|
Self(*value as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Txinindex> for StoredU64 {
|
impl From<InputIndex> for StoredU64 {
|
||||||
fn from(value: Txinindex) -> Self {
|
fn from(value: InputIndex) -> Self {
|
||||||
Self(*value)
|
Self(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Txoutindex> for StoredU64 {
|
impl From<OutputIndex> for StoredU64 {
|
||||||
fn from(value: Txoutindex) -> Self {
|
fn from(value: OutputIndex) -> Self {
|
||||||
Self(*value)
|
Self(*value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
60
crates/brk_core/src/structs/txidprefix.rs
Normal file
60
crates/brk_core/src/structs/txidprefix.rs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
use byteview::ByteView;
|
||||||
|
use derive_deref::Deref;
|
||||||
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||||
|
|
||||||
|
use crate::{Error, copy_first_8bytes};
|
||||||
|
|
||||||
|
use super::Txid;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
FromBytes,
|
||||||
|
Immutable,
|
||||||
|
IntoBytes,
|
||||||
|
KnownLayout,
|
||||||
|
)]
|
||||||
|
pub struct TxidPrefix([u8; 8]);
|
||||||
|
|
||||||
|
impl From<Txid> for TxidPrefix {
|
||||||
|
fn from(value: Txid) -> Self {
|
||||||
|
Self::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&Txid> for TxidPrefix {
|
||||||
|
fn from(value: &Txid) -> Self {
|
||||||
|
Self(copy_first_8bytes(&value[..]).unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<ByteView> for TxidPrefix {
|
||||||
|
type Error = Error;
|
||||||
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&TxidPrefix> for ByteView {
|
||||||
|
fn from(value: &TxidPrefix) -> Self {
|
||||||
|
Self::new(value.as_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TxidPrefix> for ByteView {
|
||||||
|
fn from(value: TxidPrefix) -> Self {
|
||||||
|
Self::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<[u8; 8]> for TxidPrefix {
|
||||||
|
fn from(value: [u8; 8]) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,82 +26,82 @@ use super::StoredU32;
|
|||||||
KnownLayout,
|
KnownLayout,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Txindex(u32);
|
pub struct TxIndex(u32);
|
||||||
|
|
||||||
impl Txindex {
|
impl TxIndex {
|
||||||
pub fn incremented(self) -> Self {
|
pub fn incremented(self) -> Self {
|
||||||
Self(*self + 1)
|
Self(*self + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Txindex> for Txindex {
|
impl Add<TxIndex> for TxIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: Txindex) -> Self::Output {
|
fn add(self, rhs: TxIndex) -> Self::Output {
|
||||||
Self(self.0 + rhs.0)
|
Self(self.0 + rhs.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Txindex {
|
impl Add<usize> for TxIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
Self(self.0 + rhs as u32)
|
Self(self.0 + rhs as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddAssign<Txindex> for Txindex {
|
impl AddAssign<TxIndex> for TxIndex {
|
||||||
fn add_assign(&mut self, rhs: Txindex) {
|
fn add_assign(&mut self, rhs: TxIndex) {
|
||||||
self.0 += rhs.0
|
self.0 += rhs.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub<Txindex> for Txindex {
|
impl CheckedSub<TxIndex> for TxIndex {
|
||||||
fn checked_sub(self, rhs: Txindex) -> Option<Self> {
|
fn checked_sub(self, rhs: TxIndex) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Txindex::from)
|
self.0.checked_sub(rhs.0).map(TxIndex::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u32> for Txindex {
|
impl From<u32> for TxIndex {
|
||||||
fn from(value: u32) -> Self {
|
fn from(value: u32) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u64> for Txindex {
|
impl From<u64> for TxIndex {
|
||||||
fn from(value: u64) -> Self {
|
fn from(value: u64) -> Self {
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txindex> for u64 {
|
impl From<TxIndex> for u64 {
|
||||||
fn from(value: Txindex) -> Self {
|
fn from(value: TxIndex) -> Self {
|
||||||
value.0 as u64
|
value.0 as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Txindex {
|
impl From<usize> for TxIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u32)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txindex> for usize {
|
impl From<TxIndex> for usize {
|
||||||
fn from(value: Txindex) -> Self {
|
fn from(value: TxIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<ByteView> for Txindex {
|
impl TryFrom<ByteView> for TxIndex {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||||
Ok(Self::read_from_bytes(&value)?)
|
Ok(Self::read_from_bytes(&value)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Txindex> for ByteView {
|
impl From<TxIndex> for ByteView {
|
||||||
fn from(value: Txindex) -> Self {
|
fn from(value: TxIndex) -> Self {
|
||||||
Self::new(value.as_bytes())
|
Self::new(value.as_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Txindex> for StoredU32 {
|
impl From<TxIndex> for StoredU32 {
|
||||||
fn from(value: Txindex) -> Self {
|
fn from(value: TxIndex) -> Self {
|
||||||
Self::from(value.0)
|
Self::from(value.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,28 +19,34 @@ use super::StoredU8;
|
|||||||
FromBytes,
|
FromBytes,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct TxVersion(i32);
|
pub struct TxVersion(u8);
|
||||||
|
|
||||||
impl TxVersion {
|
impl TxVersion {
|
||||||
pub const ONE: Self = Self(1);
|
pub const ONE: Self = Self(1);
|
||||||
pub const TWO: Self = Self(2);
|
pub const TWO: Self = Self(2);
|
||||||
pub const THREE: Self = Self(3);
|
pub const THREE: Self = Self(3);
|
||||||
|
pub const NON_STANDARD: Self = Self(u8::MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bitcoin::transaction::Version> for TxVersion {
|
impl From<bitcoin::transaction::Version> for TxVersion {
|
||||||
fn from(value: bitcoin::transaction::Version) -> Self {
|
fn from(value: bitcoin::transaction::Version) -> Self {
|
||||||
Self(value.0)
|
match value.0 {
|
||||||
|
1 => Self::ONE,
|
||||||
|
2 => Self::TWO,
|
||||||
|
3 => Self::THREE,
|
||||||
|
_ => Self::NON_STANDARD,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TxVersion> for bitcoin::transaction::Version {
|
impl From<TxVersion> for bitcoin::transaction::Version {
|
||||||
fn from(value: TxVersion) -> Self {
|
fn from(value: TxVersion) -> Self {
|
||||||
Self(value.0)
|
Self(value.0 as i32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TxVersion> for StoredU8 {
|
impl From<TxVersion> for StoredU8 {
|
||||||
fn from(value: TxVersion) -> Self {
|
fn from(value: TxVersion) -> Self {
|
||||||
Self::from(value.0 as u8)
|
Self::from(value.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::CheckedSub;
|
use crate::CheckedSub;
|
||||||
|
|
||||||
use super::{Date, Dateindex};
|
use super::{Date, DateIndex};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -23,27 +23,27 @@ use super::{Date, Dateindex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Weekindex(u16);
|
pub struct WeekIndex(u16);
|
||||||
|
|
||||||
impl From<u16> for Weekindex {
|
impl From<u16> for WeekIndex {
|
||||||
fn from(value: u16) -> Self {
|
fn from(value: u16) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Weekindex {
|
impl From<usize> for WeekIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u16)
|
Self(value as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Weekindex> for usize {
|
impl From<WeekIndex> for usize {
|
||||||
fn from(value: Weekindex) -> Self {
|
fn from(value: WeekIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Weekindex {
|
impl Add<usize> for WeekIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,13 +51,13 @@ impl Add<usize> for Weekindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for Weekindex {
|
impl From<DateIndex> for WeekIndex {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
Self::from(Date::from(value))
|
Self::from(Date::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Date> for Weekindex {
|
impl From<Date> for WeekIndex {
|
||||||
fn from(value: Date) -> Self {
|
fn from(value: Date) -> Self {
|
||||||
let date = jiff::civil::Date::from(value).iso_week_date();
|
let date = jiff::civil::Date::from(value).iso_week_date();
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ impl From<Date> for Weekindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Weekindex {
|
impl CheckedSub for WeekIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,29 +19,36 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
FromBytes,
|
FromBytes,
|
||||||
Serialize,
|
Serialize,
|
||||||
)]
|
)]
|
||||||
pub struct Weight(u64);
|
pub struct Weight(u32);
|
||||||
|
|
||||||
impl From<bitcoin::Weight> for Weight {
|
impl From<bitcoin::Weight> for Weight {
|
||||||
fn from(value: bitcoin::Weight) -> Self {
|
fn from(value: bitcoin::Weight) -> Self {
|
||||||
Self(value.to_wu())
|
let wu = value.to_wu();
|
||||||
|
if wu > u32::MAX as u64 {
|
||||||
|
unreachable!("wu is too big, shouldn't happen")
|
||||||
|
}
|
||||||
|
Self(wu as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Weight> for bitcoin::Weight {
|
impl From<Weight> for bitcoin::Weight {
|
||||||
fn from(value: Weight) -> Self {
|
fn from(value: Weight) -> Self {
|
||||||
Self::from_wu(*value)
|
Self::from_wu(*value as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Weight {
|
impl From<usize> for Weight {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u64)
|
if value > u32::MAX as usize {
|
||||||
|
panic!()
|
||||||
|
}
|
||||||
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<f64> for Weight {
|
impl From<f64> for Weight {
|
||||||
fn from(value: f64) -> Self {
|
fn from(value: f64) -> Self {
|
||||||
Self(value as u64)
|
Self(value as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|||||||
|
|
||||||
use crate::CheckedSub;
|
use crate::CheckedSub;
|
||||||
|
|
||||||
use super::{Date, Dateindex, Monthindex};
|
use super::{Date, DateIndex, MonthIndex};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@@ -23,27 +23,27 @@ use super::{Date, Dateindex, Monthindex};
|
|||||||
IntoBytes,
|
IntoBytes,
|
||||||
KnownLayout,
|
KnownLayout,
|
||||||
)]
|
)]
|
||||||
pub struct Yearindex(u8);
|
pub struct YearIndex(u8);
|
||||||
|
|
||||||
impl From<u8> for Yearindex {
|
impl From<u8> for YearIndex {
|
||||||
fn from(value: u8) -> Self {
|
fn from(value: u8) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for Yearindex {
|
impl From<usize> for YearIndex {
|
||||||
fn from(value: usize) -> Self {
|
fn from(value: usize) -> Self {
|
||||||
Self(value as u8)
|
Self(value as u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Yearindex> for usize {
|
impl From<YearIndex> for usize {
|
||||||
fn from(value: Yearindex) -> Self {
|
fn from(value: YearIndex) -> Self {
|
||||||
value.0 as usize
|
value.0 as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Yearindex {
|
impl Add<usize> for YearIndex {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: usize) -> Self::Output {
|
fn add(self, rhs: usize) -> Self::Output {
|
||||||
@@ -51,32 +51,32 @@ impl Add<usize> for Yearindex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Dateindex> for Yearindex {
|
impl From<DateIndex> for YearIndex {
|
||||||
fn from(value: Dateindex) -> Self {
|
fn from(value: DateIndex) -> Self {
|
||||||
Self::from(Date::from(value))
|
Self::from(Date::from(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Date> for Yearindex {
|
impl From<Date> for YearIndex {
|
||||||
fn from(value: Date) -> Self {
|
fn from(value: Date) -> Self {
|
||||||
Self((value.year() - 2009) as u8)
|
Self((value.year() - 2009) as u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Yearindex> for u16 {
|
impl From<YearIndex> for u16 {
|
||||||
fn from(value: Yearindex) -> Self {
|
fn from(value: YearIndex) -> Self {
|
||||||
value.0 as u16
|
value.0 as u16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckedSub for Yearindex {
|
impl CheckedSub for YearIndex {
|
||||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||||
self.0.checked_sub(rhs.0).map(Self)
|
self.0.checked_sub(rhs.0).map(Self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Monthindex> for Yearindex {
|
impl From<MonthIndex> for YearIndex {
|
||||||
fn from(value: Monthindex) -> Self {
|
fn from(value: MonthIndex) -> Self {
|
||||||
Self((usize::from(value) / 12) as u8)
|
Self((usize::from(value) / 12) as u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
crates/brk_core/src/utils/bytes.rs
Normal file
12
crates/brk_core/src/utils/bytes.rs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#[allow(clippy::result_unit_err)]
|
||||||
|
pub fn copy_first_8bytes(slice: &[u8]) -> Result<[u8; 8], ()> {
|
||||||
|
let mut buf: [u8; 8] = [0; 8];
|
||||||
|
let buf_len = buf.len();
|
||||||
|
if slice.len() < buf_len {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
slice.iter().take(buf_len).enumerate().for_each(|(i, r)| {
|
||||||
|
buf[i] = *r;
|
||||||
|
});
|
||||||
|
Ok(buf)
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
mod bytes;
|
||||||
mod checked_sub;
|
mod checked_sub;
|
||||||
mod paths;
|
mod paths;
|
||||||
mod pause;
|
mod pause;
|
||||||
mod rlimit;
|
mod rlimit;
|
||||||
|
|
||||||
|
pub use bytes::*;
|
||||||
pub use checked_sub::*;
|
pub use checked_sub::*;
|
||||||
pub use paths::*;
|
pub use paths::*;
|
||||||
pub use pause::*;
|
pub use pause::*;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
|
|
||||||
let outputs = Path::new("../../_outputs");
|
let outputs = Path::new("../../_outputs");
|
||||||
|
|
||||||
let mut indexer = Indexer::new(outputs, false, false)?;
|
let mut indexer = Indexer::new(outputs, false, true)?;
|
||||||
|
|
||||||
indexer.import_stores()?;
|
indexer.import_stores()?;
|
||||||
indexer.import_vecs()?;
|
indexer.import_vecs()?;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use bitcoincore_rpc::Client;
|
use bitcoincore_rpc::Client;
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
Addressindex, BlockHash, CheckedSub, Emptyindex, Height, Multisigindex, Opreturnindex,
|
BlockHash, CheckedSub, EmptyOutputIndex, Height, InputIndex, OpReturnIndex, OutputIndex,
|
||||||
P2PK33index, P2PK65index, P2PKHindex, P2SHindex, P2TRindex, P2WPKHindex, P2WSHindex,
|
OutputType, OutputTypeIndex, P2AIndex, P2MSIndex, P2PK33Index, P2PK65Index, P2PKHIndex,
|
||||||
Pushonlyindex, Txindex, Txinindex, Txoutindex, Unknownindex,
|
P2SHIndex, P2TRIndex, P2WPKHIndex, P2WSHIndex, TxIndex, UnknownOutputIndex,
|
||||||
};
|
};
|
||||||
use brk_parser::NUMBER_OF_UNSAFE_BLOCKS;
|
use brk_parser::NUMBER_OF_UNSAFE_BLOCKS;
|
||||||
use brk_vec::{Result, StoredIndex, StoredType, Value};
|
use brk_vec::{Result, StoredIndex, StoredType, Value};
|
||||||
@@ -12,46 +12,60 @@ use crate::{IndexedVec, Stores, Vecs};
|
|||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct Indexes {
|
pub struct Indexes {
|
||||||
pub addressindex: Addressindex,
|
pub emptyoutputindex: EmptyOutputIndex,
|
||||||
pub emptyindex: Emptyindex,
|
|
||||||
pub height: Height,
|
pub height: Height,
|
||||||
pub multisigindex: Multisigindex,
|
pub opreturnindex: OpReturnIndex,
|
||||||
pub opreturnindex: Opreturnindex,
|
pub p2msindex: P2MSIndex,
|
||||||
pub p2pk33index: P2PK33index,
|
pub p2pk33index: P2PK33Index,
|
||||||
pub p2pk65index: P2PK65index,
|
pub p2pk65index: P2PK65Index,
|
||||||
pub p2pkhindex: P2PKHindex,
|
pub p2pkhindex: P2PKHIndex,
|
||||||
pub p2shindex: P2SHindex,
|
pub p2shindex: P2SHIndex,
|
||||||
pub p2trindex: P2TRindex,
|
pub p2trindex: P2TRIndex,
|
||||||
pub p2wpkhindex: P2WPKHindex,
|
pub p2wpkhindex: P2WPKHIndex,
|
||||||
pub p2wshindex: P2WSHindex,
|
pub p2wshindex: P2WSHIndex,
|
||||||
pub pushonlyindex: Pushonlyindex,
|
pub p2aindex: P2AIndex,
|
||||||
pub txindex: Txindex,
|
pub txindex: TxIndex,
|
||||||
pub txinindex: Txinindex,
|
pub inputindex: InputIndex,
|
||||||
pub txoutindex: Txoutindex,
|
pub outputindex: OutputIndex,
|
||||||
pub unknownindex: Unknownindex,
|
pub unknownoutputindex: UnknownOutputIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Indexes {
|
impl Indexes {
|
||||||
|
pub fn outputtypeindex(&self, outputtype: OutputType) -> OutputTypeIndex {
|
||||||
|
match outputtype {
|
||||||
|
OutputType::Empty => *self.emptyoutputindex,
|
||||||
|
OutputType::OpReturn => *self.opreturnindex,
|
||||||
|
OutputType::P2A => *self.p2aindex,
|
||||||
|
OutputType::P2MS => *self.p2msindex,
|
||||||
|
OutputType::P2PK33 => *self.p2pkhindex,
|
||||||
|
OutputType::P2PK65 => *self.p2pk65index,
|
||||||
|
OutputType::P2PKH => *self.p2pkhindex,
|
||||||
|
OutputType::P2SH => *self.p2shindex,
|
||||||
|
OutputType::P2TR => *self.p2trindex,
|
||||||
|
OutputType::P2WPKH => *self.p2wpkhindex,
|
||||||
|
OutputType::P2WSH => *self.p2wshindex,
|
||||||
|
OutputType::Unknown => *self.unknownoutputindex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn push_if_needed(&self, vecs: &mut Vecs) -> brk_vec::Result<()> {
|
pub fn push_if_needed(&self, vecs: &mut Vecs) -> brk_vec::Result<()> {
|
||||||
let height = self.height;
|
let height = self.height;
|
||||||
vecs.height_to_first_txindex
|
vecs.height_to_first_txindex
|
||||||
.push_if_needed(height, self.txindex)?;
|
.push_if_needed(height, self.txindex)?;
|
||||||
vecs.height_to_first_txinindex
|
vecs.height_to_first_inputindex
|
||||||
.push_if_needed(height, self.txinindex)?;
|
.push_if_needed(height, self.inputindex)?;
|
||||||
vecs.height_to_first_txoutindex
|
vecs.height_to_first_outputindex
|
||||||
.push_if_needed(height, self.txoutindex)?;
|
.push_if_needed(height, self.outputindex)?;
|
||||||
vecs.height_to_first_addressindex
|
vecs.height_to_first_emptyoutputindex
|
||||||
.push_if_needed(height, self.addressindex)?;
|
.push_if_needed(height, self.emptyoutputindex)?;
|
||||||
vecs.height_to_first_emptyindex
|
vecs.height_to_first_p2msindex
|
||||||
.push_if_needed(height, self.emptyindex)?;
|
.push_if_needed(height, self.p2msindex)?;
|
||||||
vecs.height_to_first_multisigindex
|
|
||||||
.push_if_needed(height, self.multisigindex)?;
|
|
||||||
vecs.height_to_first_opreturnindex
|
vecs.height_to_first_opreturnindex
|
||||||
.push_if_needed(height, self.opreturnindex)?;
|
.push_if_needed(height, self.opreturnindex)?;
|
||||||
vecs.height_to_first_pushonlyindex
|
vecs.height_to_first_p2aindex
|
||||||
.push_if_needed(height, self.pushonlyindex)?;
|
.push_if_needed(height, self.p2aindex)?;
|
||||||
vecs.height_to_first_unknownindex
|
vecs.height_to_first_unknownoutputindex
|
||||||
.push_if_needed(height, self.unknownindex)?;
|
.push_if_needed(height, self.unknownoutputindex)?;
|
||||||
vecs.height_to_first_p2pk33index
|
vecs.height_to_first_p2pk33index
|
||||||
.push_if_needed(height, self.p2pk33index)?;
|
.push_if_needed(height, self.p2pk33index)?;
|
||||||
vecs.height_to_first_p2pk65index
|
vecs.height_to_first_p2pk65index
|
||||||
@@ -106,100 +120,90 @@ impl TryFrom<(&mut Vecs, &Stores, &Client)> for Indexes {
|
|||||||
.unwrap_or(starting_height);
|
.unwrap_or(starting_height);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
addressindex: *starting_index(
|
emptyoutputindex: *starting_index(
|
||||||
&vecs.height_to_first_addressindex,
|
&vecs.height_to_first_emptyoutputindex,
|
||||||
&vecs.addressindex_to_height,
|
&vecs.emptyoutputindex_to_txindex,
|
||||||
height,
|
|
||||||
)?
|
|
||||||
.context("")?,
|
|
||||||
emptyindex: *starting_index(
|
|
||||||
&vecs.height_to_first_emptyindex,
|
|
||||||
&vecs.emptyindex_to_height,
|
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
height,
|
height,
|
||||||
multisigindex: *starting_index(
|
p2msindex: *starting_index(
|
||||||
&vecs.height_to_first_multisigindex,
|
&vecs.height_to_first_p2msindex,
|
||||||
&vecs.multisigindex_to_height,
|
&vecs.p2msindex_to_txindex,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
opreturnindex: *starting_index(
|
opreturnindex: *starting_index(
|
||||||
&vecs.height_to_first_opreturnindex,
|
&vecs.height_to_first_opreturnindex,
|
||||||
&vecs.opreturnindex_to_height,
|
&vecs.opreturnindex_to_txindex,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2pk33index: *starting_index(
|
p2pk33index: *starting_index(
|
||||||
&vecs.height_to_first_p2pk33index,
|
&vecs.height_to_first_p2pk33index,
|
||||||
&vecs.p2pk33index_to_height,
|
&vecs.p2pk33index_to_p2pk33bytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2pk65index: *starting_index(
|
p2pk65index: *starting_index(
|
||||||
&vecs.height_to_first_p2pk65index,
|
&vecs.height_to_first_p2pk65index,
|
||||||
&vecs.p2pk65index_to_height,
|
&vecs.p2pk65index_to_p2pk65bytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2pkhindex: *starting_index(
|
p2pkhindex: *starting_index(
|
||||||
&vecs.height_to_first_p2pkhindex,
|
&vecs.height_to_first_p2pkhindex,
|
||||||
&vecs.p2pkhindex_to_height,
|
&vecs.p2pkhindex_to_p2pkhbytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2shindex: *starting_index(
|
p2shindex: *starting_index(
|
||||||
&vecs.height_to_first_p2shindex,
|
&vecs.height_to_first_p2shindex,
|
||||||
&vecs.p2shindex_to_height,
|
&vecs.p2shindex_to_p2shbytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2trindex: *starting_index(
|
p2trindex: *starting_index(
|
||||||
&vecs.height_to_first_p2trindex,
|
&vecs.height_to_first_p2trindex,
|
||||||
&vecs.p2trindex_to_height,
|
&vecs.p2trindex_to_p2trbytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2wpkhindex: *starting_index(
|
p2wpkhindex: *starting_index(
|
||||||
&vecs.height_to_first_p2wpkhindex,
|
&vecs.height_to_first_p2wpkhindex,
|
||||||
&vecs.p2wpkhindex_to_height,
|
&vecs.p2wpkhindex_to_p2wpkhbytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
p2wshindex: *starting_index(
|
p2wshindex: *starting_index(
|
||||||
&vecs.height_to_first_p2wshindex,
|
&vecs.height_to_first_p2wshindex,
|
||||||
&vecs.p2wshindex_to_height,
|
&vecs.p2wshindex_to_p2wshbytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
pushonlyindex: *starting_index(
|
p2aindex: *starting_index(
|
||||||
&vecs.height_to_first_pushonlyindex,
|
&vecs.height_to_first_p2aindex,
|
||||||
&vecs.pushonlyindex_to_height,
|
&vecs.p2aindex_to_p2abytes,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
txindex: *starting_index(
|
txindex: *starting_index(&vecs.height_to_first_txindex, &vecs.txindex_to_txid, height)?
|
||||||
&vecs.height_to_first_txindex,
|
.context("")?,
|
||||||
&vecs.txindex_to_height,
|
inputindex: *starting_index(
|
||||||
|
&vecs.height_to_first_inputindex,
|
||||||
|
&vecs.inputindex_to_outputindex,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
txinindex: *starting_index(
|
outputindex: *starting_index(
|
||||||
&vecs.height_to_first_txinindex,
|
&vecs.height_to_first_outputindex,
|
||||||
&vecs.txinindex_to_height,
|
&vecs.outputindex_to_value,
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
txoutindex: *starting_index(
|
unknownoutputindex: *starting_index(
|
||||||
&vecs.height_to_first_txoutindex,
|
&vecs.height_to_first_unknownoutputindex,
|
||||||
&vecs.txoutindex_to_height,
|
&vecs.unknownoutputindex_to_txindex,
|
||||||
height,
|
|
||||||
)?
|
|
||||||
.context("")?,
|
|
||||||
unknownindex: *starting_index(
|
|
||||||
&vecs.height_to_first_unknownindex,
|
|
||||||
&vecs.unknownindex_to_height,
|
|
||||||
height,
|
height,
|
||||||
)?
|
)?
|
||||||
.context("")?,
|
.context("")?,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
AddressHash, Addressbytes, Addressindex, Addresstype, BlockHash, BlockHashPrefix, Height, Sats,
|
AddressBytes, AddressBytesHash, BlockHash, BlockHashPrefix, Height, InputIndex, OutputIndex,
|
||||||
Timestamp, Txid, TxidPrefix, Txindex, Txinindex, Txoutindex, Vin, Vout, setrlimit,
|
OutputType, OutputTypeIndex, Sats, Timestamp, TxIndex, Txid, TxidPrefix, Vin, Vout, setrlimit,
|
||||||
};
|
};
|
||||||
pub use brk_parser::*;
|
pub use brk_parser::*;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ use brk_exit::Exit;
|
|||||||
use brk_vec::Compressed;
|
use brk_vec::Compressed;
|
||||||
use color_eyre::eyre::{ContextCompat, eyre};
|
use color_eyre::eyre::{ContextCompat, eyre};
|
||||||
use fjall::TransactionalKeyspace;
|
use fjall::TransactionalKeyspace;
|
||||||
use log::info;
|
use log::{error, info};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
mod indexes;
|
mod indexes;
|
||||||
mod stores;
|
mod stores;
|
||||||
@@ -32,7 +32,7 @@ pub use stores::*;
|
|||||||
pub use vecs::*;
|
pub use vecs::*;
|
||||||
|
|
||||||
const SNAPSHOT_BLOCK_RANGE: usize = 1000;
|
const SNAPSHOT_BLOCK_RANGE: usize = 1000;
|
||||||
const COLLISIONS_CHECKED_UP_TO: u32 = 893_000;
|
const COLLISIONS_CHECKED_UP_TO: u32 = 0;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Indexer {
|
pub struct Indexer {
|
||||||
@@ -150,18 +150,18 @@ impl Indexer {
|
|||||||
let blockhash_prefix = BlockHashPrefix::from(&blockhash);
|
let blockhash_prefix = BlockHashPrefix::from(&blockhash);
|
||||||
|
|
||||||
if stores
|
if stores
|
||||||
.blockhash_prefix_to_height
|
.blockhashprefix_to_height
|
||||||
.get(&blockhash_prefix)?
|
.get(&blockhash_prefix)?
|
||||||
.is_some_and(|prev_height| *prev_height != height)
|
.is_some_and(|prev_height| *prev_height != height)
|
||||||
{
|
{
|
||||||
dbg!(blockhash);
|
error!("BlockHash: {blockhash}");
|
||||||
return Err(eyre!("Collision, expect prefix to need be set yet"));
|
return Err(eyre!("Collision, expect prefix to need be set yet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
idxs.push_if_needed(vecs)?;
|
idxs.push_if_needed(vecs)?;
|
||||||
|
|
||||||
stores
|
stores
|
||||||
.blockhash_prefix_to_height
|
.blockhashprefix_to_height
|
||||||
.insert_if_needed(blockhash_prefix, height, height);
|
.insert_if_needed(blockhash_prefix, height, height);
|
||||||
|
|
||||||
vecs.height_to_blockhash.push_if_needed(height, blockhash)?;
|
vecs.height_to_blockhash.push_if_needed(height, blockhash)?;
|
||||||
@@ -172,29 +172,33 @@ impl Indexer {
|
|||||||
vecs.height_to_total_size.push_if_needed(height, block.total_size().into())?;
|
vecs.height_to_total_size.push_if_needed(height, block.total_size().into())?;
|
||||||
vecs.height_to_weight.push_if_needed(height, block.weight().into())?;
|
vecs.height_to_weight.push_if_needed(height, block.weight().into())?;
|
||||||
|
|
||||||
let inputs = block
|
let (inputs, outputs) = thread::scope(|s| {
|
||||||
.txdata
|
let inputs_handle = s.spawn(|| block
|
||||||
.iter()
|
.txdata
|
||||||
.enumerate()
|
.iter()
|
||||||
.flat_map(|(index, tx)| {
|
.enumerate()
|
||||||
tx.input
|
.flat_map(|(index, tx)| {
|
||||||
.iter()
|
tx.input
|
||||||
.enumerate()
|
.iter()
|
||||||
.map(move |(vin, txin)| (Txindex::from(index), Vin::from(vin), txin, tx))
|
.enumerate()
|
||||||
})
|
.map(move |(vin, txin)| (TxIndex::from(index), Vin::from(vin), txin, tx))
|
||||||
.collect::<Vec<_>>();
|
})
|
||||||
|
.collect::<Vec<_>>());
|
||||||
|
|
||||||
let outputs = block
|
let outputs_handle = s.spawn(|| block
|
||||||
.txdata
|
.txdata
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.flat_map(|(index, tx)| {
|
.flat_map(|(index, tx)| {
|
||||||
tx.output
|
tx.output
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(move |(vout, txout)| (Txindex::from(index), Vout::from(vout), txout, tx))
|
.map(move |(vout, txout)| (TxIndex::from(index), Vout::from(vout), txout, tx))
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>());
|
||||||
|
|
||||||
|
(inputs_handle.join().unwrap(), outputs_handle.join().unwrap())
|
||||||
|
});
|
||||||
|
|
||||||
let tx_len = block.txdata.len();
|
let tx_len = block.txdata.len();
|
||||||
let outputs_len = outputs.len();
|
let outputs_len = outputs.len();
|
||||||
@@ -203,7 +207,7 @@ impl Indexer {
|
|||||||
let (
|
let (
|
||||||
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_join_handle,
|
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_join_handle,
|
||||||
input_source_vec_handle,
|
input_source_vec_handle,
|
||||||
txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt_handle,
|
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle,
|
||||||
) = thread::scope(|scope| {
|
) = thread::scope(|scope| {
|
||||||
let txid_prefix_to_txid_and_block_txindex_and_prev_txindex_handle =
|
let txid_prefix_to_txid_and_block_txindex_and_prev_txindex_handle =
|
||||||
scope.spawn(|| -> color_eyre::Result<_> {
|
scope.spawn(|| -> color_eyre::Result<_> {
|
||||||
@@ -217,14 +221,14 @@ impl Indexer {
|
|||||||
let txid_prefix = TxidPrefix::from(&txid);
|
let txid_prefix = TxidPrefix::from(&txid);
|
||||||
|
|
||||||
let prev_txindex_opt =
|
let prev_txindex_opt =
|
||||||
if check_collisions && stores.txid_prefix_to_txindex.needs(height) {
|
if check_collisions && stores.txidprefix_to_txindex.needs(height) {
|
||||||
// Should only find collisions for two txids (duplicates), see below
|
// Should only find collisions for two txids (duplicates), see below
|
||||||
stores.txid_prefix_to_txindex.get(&txid_prefix)?.map(|v| *v)
|
stores.txidprefix_to_txindex.get(&txid_prefix)?.map(|v| *v)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((txid_prefix, (tx, txid, Txindex::from(index), prev_txindex_opt)))
|
Ok((txid_prefix, (tx, txid, TxIndex::from(index), prev_txindex_opt)))
|
||||||
})
|
})
|
||||||
.try_fold(BTreeMap::new, |mut map, tuple| {
|
.try_fold(BTreeMap::new, |mut map, tuple| {
|
||||||
let (key, value) = tuple?;
|
let (key, value) = tuple?;
|
||||||
@@ -246,19 +250,19 @@ impl Indexer {
|
|||||||
inputs
|
inputs
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(block_txinindex, (block_txindex, vin, txin, tx))| -> color_eyre::Result<(Txinindex, InputSource)> {
|
.map(|(block_inputindex, (block_txindex, vin, txin, tx))| -> color_eyre::Result<(InputIndex, InputSource)> {
|
||||||
let txindex = idxs.txindex + block_txindex;
|
let txindex = idxs.txindex + block_txindex;
|
||||||
let txinindex = idxs.txinindex + Txinindex::from(block_txinindex);
|
let inputindex = idxs.inputindex + InputIndex::from(block_inputindex);
|
||||||
|
|
||||||
let outpoint = txin.previous_output;
|
let outpoint = txin.previous_output;
|
||||||
let txid = Txid::from(outpoint.txid);
|
let txid = Txid::from(outpoint.txid);
|
||||||
|
|
||||||
if tx.is_coinbase() {
|
if tx.is_coinbase() {
|
||||||
return Ok((txinindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
||||||
}
|
}
|
||||||
|
|
||||||
let prev_txindex = if let Some(txindex) = stores
|
let prev_txindex = if let Some(txindex) = stores
|
||||||
.txid_prefix_to_txindex
|
.txidprefix_to_txindex
|
||||||
.get(&TxidPrefix::from(&txid))?
|
.get(&TxidPrefix::from(&txid))?
|
||||||
.map(|v| *v)
|
.map(|v| *v)
|
||||||
.and_then(|txindex| {
|
.and_then(|txindex| {
|
||||||
@@ -268,24 +272,24 @@ impl Indexer {
|
|||||||
txindex
|
txindex
|
||||||
} else {
|
} else {
|
||||||
// dbg!(indexes.txindex + block_txindex, txindex, txin, vin);
|
// dbg!(indexes.txindex + block_txindex, txindex, txin, vin);
|
||||||
return Ok((txinindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
|
||||||
};
|
};
|
||||||
|
|
||||||
let vout = Vout::from(outpoint.vout);
|
let vout = Vout::from(outpoint.vout);
|
||||||
|
|
||||||
let txoutindex = *vecs
|
let outputindex = *vecs
|
||||||
.txindex_to_first_txoutindex
|
.txindex_to_first_outputindex
|
||||||
.get(prev_txindex)?
|
.get(prev_txindex)?
|
||||||
.context("Expect txoutindex to not be none")
|
.context("Expect outputindex to not be none")
|
||||||
.inspect_err(|_| {
|
.inspect_err(|_| {
|
||||||
dbg!(outpoint.txid, prev_txindex, vout);
|
dbg!(outpoint.txid, prev_txindex, vout);
|
||||||
})?
|
})?
|
||||||
+ vout;
|
+ vout;
|
||||||
|
|
||||||
Ok((txinindex, InputSource::PreviousBlock((
|
Ok((inputindex, InputSource::PreviousBlock((
|
||||||
vin,
|
vin,
|
||||||
txindex,
|
txindex,
|
||||||
txoutindex,
|
outputindex,
|
||||||
))))
|
))))
|
||||||
})
|
})
|
||||||
.try_fold(BTreeMap::new, |mut map, tuple| -> color_eyre::Result<_> {
|
.try_fold(BTreeMap::new, |mut map, tuple| -> color_eyre::Result<_> {
|
||||||
@@ -304,71 +308,58 @@ impl Indexer {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt_handle = scope.spawn(|| {
|
let outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle = scope.spawn(|| {
|
||||||
outputs
|
outputs
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(
|
.map(
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|(block_txoutindex, (block_txindex, vout, txout, tx))| -> color_eyre::Result<(
|
|(block_outputindex, (block_txindex, vout, txout, tx))| -> color_eyre::Result<(
|
||||||
Txoutindex,
|
OutputIndex,
|
||||||
(
|
(
|
||||||
&TxOut,
|
&TxOut,
|
||||||
Txindex,
|
TxIndex,
|
||||||
Vout,
|
Vout,
|
||||||
Addresstype,
|
OutputType,
|
||||||
brk_core::Result<Addressbytes>,
|
brk_core::Result<AddressBytes>,
|
||||||
Option<Addressindex>,
|
Option<OutputTypeIndex>,
|
||||||
&Transaction,
|
&Transaction,
|
||||||
),
|
),
|
||||||
)> {
|
)> {
|
||||||
let txindex = idxs.txindex + block_txindex;
|
let txindex = idxs.txindex + block_txindex;
|
||||||
let txoutindex = idxs.txoutindex + Txoutindex::from(block_txoutindex);
|
let outputindex = idxs.outputindex + OutputIndex::from(block_outputindex);
|
||||||
|
|
||||||
let script = &txout.script_pubkey;
|
let script = &txout.script_pubkey;
|
||||||
|
|
||||||
let addresstype = Addresstype::from(script);
|
let outputtype = OutputType::from(script);
|
||||||
|
|
||||||
let addressbytes_res =
|
let address_bytes_res =
|
||||||
Addressbytes::try_from((script, addresstype)).inspect_err(|_| {
|
AddressBytes::try_from((script, outputtype)).inspect_err(|_| {
|
||||||
// dbg!(&txout, height, txi, &tx.compute_txid());
|
// dbg!(&txout, height, txi, &tx.compute_txid());
|
||||||
});
|
});
|
||||||
|
|
||||||
let addressindex_opt = addressbytes_res.as_ref().ok().and_then(|addressbytes| {
|
let outputtypeindex_opt = address_bytes_res.as_ref().ok().and_then(|addressbytes| {
|
||||||
stores
|
stores
|
||||||
.addresshash_to_addressindex
|
.addressbyteshash_to_outputtypeindex
|
||||||
.get(&AddressHash::from((addressbytes, addresstype)))
|
.get(&AddressBytesHash::from((addressbytes, outputtype)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.map(|v| *v)
|
.map(|v| *v)
|
||||||
// Checking if not in the future
|
// Checking if not in the future
|
||||||
.and_then(|addressindex_local| {
|
.and_then(|outputtypeindex_local| {
|
||||||
(addressindex_local < idxs.addressindex).then_some(addressindex_local)
|
(outputtypeindex_local < idxs.outputtypeindex(outputtype)).then_some(outputtypeindex_local)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(Some(addressindex)) = check_collisions.then_some(addressindex_opt) {
|
if let Some(Some(outputtypeindex)) = check_collisions.then_some(outputtypeindex_opt) {
|
||||||
let addressbytes = addressbytes_res.as_ref().unwrap();
|
let addressbytes = address_bytes_res.as_ref().unwrap();
|
||||||
|
|
||||||
let prev_addresstype = *vecs
|
|
||||||
.addressindex_to_addresstype
|
|
||||||
.get(addressindex)?
|
|
||||||
.context("Expect to have address type")?;
|
|
||||||
|
|
||||||
let addresstypeindex = *vecs
|
|
||||||
.addressindex_to_addresstypeindex
|
|
||||||
.get(addressindex)?
|
|
||||||
.context("Expect to have address type index")?;
|
|
||||||
|
|
||||||
let prev_addressbytes_opt =
|
let prev_addressbytes_opt =
|
||||||
vecs.get_addressbytes(prev_addresstype, addresstypeindex)?;
|
vecs.get_addressbytes(outputtype, outputtypeindex)?;
|
||||||
|
|
||||||
let prev_addressbytes =
|
let prev_addressbytes =
|
||||||
prev_addressbytes_opt.as_ref().context("Expect to have addressbytes")?;
|
prev_addressbytes_opt.as_ref().context("Expect to have addressbytes")?;
|
||||||
|
|
||||||
if (vecs.addressindex_to_addresstype.hasnt(addressindex)?
|
if stores.addressbyteshash_to_outputtypeindex.needs(height)
|
||||||
&& addresstype != prev_addresstype)
|
&& prev_addressbytes != addressbytes
|
||||||
|| (stores.addresshash_to_addressindex.needs(height)
|
|
||||||
&& prev_addressbytes != addressbytes)
|
|
||||||
{
|
{
|
||||||
let txid = tx.compute_txid();
|
let txid = tx.compute_txid();
|
||||||
dbg!(
|
dbg!(
|
||||||
@@ -376,30 +367,28 @@ impl Indexer {
|
|||||||
txid,
|
txid,
|
||||||
vout,
|
vout,
|
||||||
block_txindex,
|
block_txindex,
|
||||||
addresstype,
|
outputtype,
|
||||||
prev_addresstype,
|
|
||||||
prev_addressbytes,
|
prev_addressbytes,
|
||||||
addressbytes,
|
addressbytes,
|
||||||
idxs.addressindex,
|
&idxs,
|
||||||
addressindex,
|
outputtypeindex,
|
||||||
addresstypeindex,
|
outputtypeindex,
|
||||||
txout,
|
txout,
|
||||||
AddressHash::from((addressbytes, addresstype)),
|
AddressBytesHash::from((addressbytes, outputtype)),
|
||||||
AddressHash::from((prev_addressbytes, prev_addresstype))
|
|
||||||
);
|
);
|
||||||
panic!()
|
panic!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
txoutindex,
|
outputindex,
|
||||||
(
|
(
|
||||||
txout,
|
txout,
|
||||||
txindex,
|
txindex,
|
||||||
vout,
|
vout,
|
||||||
addresstype,
|
outputtype,
|
||||||
addressbytes_res,
|
address_bytes_res,
|
||||||
addressindex_opt,
|
outputtypeindex_opt,
|
||||||
tx,
|
tx,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
@@ -424,7 +413,7 @@ impl Indexer {
|
|||||||
(
|
(
|
||||||
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_handle.join(),
|
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_handle.join(),
|
||||||
input_source_vec_handle.join(),
|
input_source_vec_handle.join(),
|
||||||
txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt_handle.join(),
|
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle.join(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -439,158 +428,139 @@ impl Indexer {
|
|||||||
.ok()
|
.ok()
|
||||||
.context("Export input_source_vec_handle to join")??;
|
.context("Export input_source_vec_handle to join")??;
|
||||||
|
|
||||||
let txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt =
|
let outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt =
|
||||||
txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt_handle
|
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle
|
||||||
.ok()
|
.ok()
|
||||||
.context(
|
.context(
|
||||||
"Expect txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt_handle to join",
|
"Expect outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle to join",
|
||||||
)??;
|
)??;
|
||||||
|
|
||||||
let mut new_txindexvout_to_txoutindex: BTreeMap<
|
let mut new_txindexvout_to_outputindex: BTreeMap<
|
||||||
(Txindex, Vout),
|
(TxIndex, Vout),
|
||||||
Txoutindex,
|
OutputIndex,
|
||||||
> = BTreeMap::new();
|
> = BTreeMap::new();
|
||||||
|
|
||||||
let mut already_added_addresshash: BTreeMap<AddressHash, Addressindex> = BTreeMap::new();
|
let mut already_added_addressbyteshash: BTreeMap<AddressBytesHash, OutputTypeIndex> = BTreeMap::new();
|
||||||
|
|
||||||
txoutindex_to_txout_addresstype_addressbytes_res_addressindex_opt
|
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.try_for_each(
|
.try_for_each(
|
||||||
|(
|
|(
|
||||||
txoutindex,
|
outputindex,
|
||||||
(txout, txindex, vout, addresstype, addressbytes_res, addressindex_opt, _tx),
|
(txout, txindex, vout, outputtype, addressbytes_res, outputtypeindex_opt, _tx),
|
||||||
)|
|
)|
|
||||||
-> color_eyre::Result<()> {
|
-> color_eyre::Result<()> {
|
||||||
let sats = Sats::from(txout.value);
|
let sats = Sats::from(txout.value);
|
||||||
|
|
||||||
if vout.is_zero() {
|
if vout.is_zero() {
|
||||||
vecs.txindex_to_first_txoutindex.push_if_needed(txindex, txoutindex)?;
|
vecs.txindex_to_first_outputindex.push_if_needed(txindex, outputindex)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
vecs.txoutindex_to_value.push_if_needed(txoutindex, sats)?;
|
vecs.outputindex_to_value.push_if_needed(outputindex, sats)?;
|
||||||
|
|
||||||
vecs.txoutindex_to_height
|
vecs.outputindex_to_outputtype
|
||||||
.push_if_needed(txoutindex, height)?;
|
.push_if_needed(outputindex, outputtype)?;
|
||||||
|
|
||||||
let mut addressindex = idxs.addressindex;
|
let mut addressbyteshash = None;
|
||||||
|
|
||||||
let mut addresshash = None;
|
let outputtypeindex;
|
||||||
|
|
||||||
if let Some(addressindex_local) = addressindex_opt.or_else(|| {
|
if let Some(outputtypeindex_local) = outputtypeindex_opt.or_else(|| {
|
||||||
addressbytes_res.as_ref().ok().and_then(|addressbytes| {
|
addressbytes_res.as_ref().ok().and_then(|addressbytes| {
|
||||||
// Check if address was first seen before in this iterator
|
// Check if address was first seen before in this iterator
|
||||||
// Example: https://mempool.space/address/046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0c
|
// Example: https://mempool.space/address/046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0c
|
||||||
addresshash.replace(AddressHash::from((addressbytes, addresstype)));
|
addressbyteshash.replace(AddressBytesHash::from((addressbytes, outputtype)));
|
||||||
already_added_addresshash
|
already_added_addressbyteshash
|
||||||
.get(addresshash.as_ref().unwrap())
|
.get(addressbyteshash.as_ref().unwrap())
|
||||||
.cloned()
|
.cloned()
|
||||||
})
|
})
|
||||||
}) {
|
}) {
|
||||||
addressindex = addressindex_local;
|
outputtypeindex = outputtypeindex_local;
|
||||||
} else {
|
} else {
|
||||||
idxs.addressindex.increment();
|
outputtypeindex = match outputtype {
|
||||||
|
OutputType::P2PK65 => {
|
||||||
let addresstypeindex = match addresstype {
|
|
||||||
Addresstype::Empty => {
|
|
||||||
vecs.emptyindex_to_height
|
|
||||||
.push_if_needed(idxs.emptyindex, height)?;
|
|
||||||
idxs.emptyindex.copy_then_increment()
|
|
||||||
},
|
|
||||||
Addresstype::Multisig => {
|
|
||||||
vecs.multisigindex_to_height.push_if_needed(idxs.multisigindex, height)?;
|
|
||||||
idxs.multisigindex.copy_then_increment()
|
|
||||||
},
|
|
||||||
Addresstype::OpReturn => {
|
|
||||||
vecs.opreturnindex_to_height.push_if_needed(idxs.opreturnindex, height)?;
|
|
||||||
idxs.opreturnindex.copy_then_increment()
|
|
||||||
},
|
|
||||||
Addresstype::PushOnly => {
|
|
||||||
vecs.pushonlyindex_to_height.push_if_needed(idxs.pushonlyindex, height)?;
|
|
||||||
idxs.pushonlyindex.copy_then_increment()
|
|
||||||
},
|
|
||||||
Addresstype::Unknown => {
|
|
||||||
vecs.unknownindex_to_height.push_if_needed(idxs.unknownindex, height)?;
|
|
||||||
idxs.unknownindex.copy_then_increment()
|
|
||||||
},
|
|
||||||
Addresstype::P2PK65 => {
|
|
||||||
vecs.p2pk65index_to_height.push_if_needed(idxs.p2pk65index, height)?;
|
|
||||||
idxs.p2pk65index.copy_then_increment()
|
idxs.p2pk65index.copy_then_increment()
|
||||||
},
|
},
|
||||||
Addresstype::P2PK33 => {
|
OutputType::P2PK33 => {
|
||||||
vecs.p2pk33index_to_height.push_if_needed(idxs.p2pk33index, height)?;
|
|
||||||
idxs.p2pk33index.copy_then_increment()
|
idxs.p2pk33index.copy_then_increment()
|
||||||
},
|
},
|
||||||
Addresstype::P2PKH => {
|
OutputType::P2PKH => {
|
||||||
vecs.p2pkhindex_to_height.push_if_needed(idxs.p2pkhindex, height)?;
|
|
||||||
idxs.p2pkhindex.copy_then_increment()
|
idxs.p2pkhindex.copy_then_increment()
|
||||||
},
|
},
|
||||||
Addresstype::P2SH => {
|
OutputType::P2MS => {
|
||||||
vecs.p2shindex_to_height.push_if_needed(idxs.p2shindex, height)?;
|
vecs.p2msindex_to_txindex.push_if_needed(idxs.p2msindex, txindex)?;
|
||||||
|
idxs.p2msindex.copy_then_increment()
|
||||||
|
},
|
||||||
|
OutputType::P2SH => {
|
||||||
idxs.p2shindex.copy_then_increment()
|
idxs.p2shindex.copy_then_increment()
|
||||||
},
|
},
|
||||||
Addresstype::P2WPKH => {
|
OutputType::OpReturn => {
|
||||||
vecs.p2wpkhindex_to_height.push_if_needed(idxs.p2wpkhindex, height)?;
|
vecs.opreturnindex_to_txindex.push_if_needed(idxs.opreturnindex, txindex)?;
|
||||||
|
idxs.opreturnindex.copy_then_increment()
|
||||||
|
},
|
||||||
|
OutputType::P2WPKH => {
|
||||||
idxs.p2wpkhindex.copy_then_increment()
|
idxs.p2wpkhindex.copy_then_increment()
|
||||||
},
|
},
|
||||||
Addresstype::P2WSH => {
|
OutputType::P2WSH => {
|
||||||
vecs.p2wshindex_to_height.push_if_needed(idxs.p2wshindex, height)?;
|
|
||||||
idxs.p2wshindex.copy_then_increment()
|
idxs.p2wshindex.copy_then_increment()
|
||||||
},
|
},
|
||||||
Addresstype::P2TR => {
|
OutputType::P2TR => {
|
||||||
vecs.p2trindex_to_height.push_if_needed(idxs.p2trindex, height)?;
|
|
||||||
idxs.p2trindex.copy_then_increment()
|
idxs.p2trindex.copy_then_increment()
|
||||||
},
|
},
|
||||||
|
OutputType::P2A => {
|
||||||
|
idxs.p2aindex.copy_then_increment()
|
||||||
|
},
|
||||||
|
OutputType::Empty => {
|
||||||
|
vecs.emptyoutputindex_to_txindex
|
||||||
|
.push_if_needed(idxs.emptyoutputindex, txindex)?;
|
||||||
|
idxs.emptyoutputindex.copy_then_increment()
|
||||||
|
},
|
||||||
|
OutputType::Unknown => {
|
||||||
|
vecs.unknownoutputindex_to_txindex.push_if_needed(idxs.unknownoutputindex, txindex)?;
|
||||||
|
idxs.unknownoutputindex.copy_then_increment()
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
vecs.addressindex_to_addresstype
|
|
||||||
.push_if_needed(addressindex, addresstype)?;
|
|
||||||
|
|
||||||
vecs.addressindex_to_addresstypeindex
|
|
||||||
.push_if_needed(addressindex, addresstypeindex)?;
|
|
||||||
|
|
||||||
vecs.addressindex_to_height
|
|
||||||
.push_if_needed(addressindex, height)?;
|
|
||||||
|
|
||||||
if let Ok(addressbytes) = addressbytes_res {
|
if let Ok(addressbytes) = addressbytes_res {
|
||||||
let addresshash = addresshash.unwrap();
|
let addressbyteshash = addressbyteshash.unwrap();
|
||||||
|
|
||||||
already_added_addresshash
|
already_added_addressbyteshash
|
||||||
.insert(addresshash, addressindex);
|
.insert(addressbyteshash, outputtypeindex);
|
||||||
|
|
||||||
stores.addresshash_to_addressindex.insert_if_needed(
|
stores.addressbyteshash_to_outputtypeindex.insert_if_needed(
|
||||||
addresshash,
|
addressbyteshash,
|
||||||
addressindex,
|
outputtypeindex,
|
||||||
height,
|
height,
|
||||||
);
|
);
|
||||||
|
|
||||||
vecs.push_addressbytes_if_needed(addresstypeindex, addressbytes)?;
|
vecs.push_bytes_if_needed(outputtypeindex, addressbytes)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new_txindexvout_to_txoutindex
|
vecs.outputindex_to_outputtypeindex
|
||||||
.insert((txindex, vout), txoutindex);
|
.push_if_needed(outputindex, outputtypeindex)?;
|
||||||
|
|
||||||
vecs.txoutindex_to_addressindex
|
new_txindexvout_to_outputindex
|
||||||
.push_if_needed(txoutindex, addressindex)?;
|
.insert((txindex, vout), outputindex);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
drop(already_added_addresshash);
|
drop(already_added_addressbyteshash);
|
||||||
|
|
||||||
input_source_vec
|
input_source_vec
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(
|
.map(
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|(txinindex, input_source)| -> color_eyre::Result<(
|
|(inputindex, input_source)| -> color_eyre::Result<(
|
||||||
Txinindex, Vin, Txindex, Txoutindex
|
InputIndex, Vin, TxIndex, OutputIndex
|
||||||
)> {
|
)> {
|
||||||
match input_source {
|
match input_source {
|
||||||
InputSource::PreviousBlock((vin, txindex, txoutindex)) => Ok((txinindex, vin, txindex, txoutindex)),
|
InputSource::PreviousBlock((vin, txindex, outputindex)) => Ok((inputindex, vin, txindex, outputindex)),
|
||||||
InputSource::SameBlock((tx, txindex, txin, vin)) => {
|
InputSource::SameBlock((tx, txindex, txin, vin)) => {
|
||||||
if tx.is_coinbase() {
|
if tx.is_coinbase() {
|
||||||
return Ok((txinindex, vin, txindex, Txoutindex::COINBASE));
|
return Ok((inputindex, vin, txindex, OutputIndex::COINBASE));
|
||||||
}
|
}
|
||||||
|
|
||||||
let outpoint = txin.previous_output;
|
let outpoint = txin.previous_output;
|
||||||
@@ -606,37 +576,33 @@ impl Indexer {
|
|||||||
.2;
|
.2;
|
||||||
let prev_txindex = idxs.txindex + block_txindex;
|
let prev_txindex = idxs.txindex + block_txindex;
|
||||||
|
|
||||||
let prev_txoutindex = new_txindexvout_to_txoutindex
|
let prev_outputindex = new_txindexvout_to_outputindex
|
||||||
.remove(&(prev_txindex, vout))
|
.remove(&(prev_txindex, vout))
|
||||||
.context("should have found addressindex from same block")
|
.context("should have found addressindex from same block")
|
||||||
.inspect_err(|_| {
|
.inspect_err(|_| {
|
||||||
dbg!(&new_txindexvout_to_txoutindex, txin, prev_txindex, vout, txid);
|
dbg!(&new_txindexvout_to_outputindex, txin, prev_txindex, vout, txid);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok((txinindex, vin, txindex, prev_txoutindex))
|
Ok((inputindex, vin, txindex, prev_outputindex))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.try_for_each(|res| -> color_eyre::Result<()> {
|
.try_for_each(|res| -> color_eyre::Result<()> {
|
||||||
let (txinindex, vin, txindex, txoutindex) = res?;
|
let (inputindex, vin, txindex, outputindex) = res?;
|
||||||
|
|
||||||
if vin.is_zero() {
|
if vin.is_zero() {
|
||||||
vecs.txindex_to_first_txinindex.push_if_needed(txindex, txinindex)?;
|
vecs.txindex_to_first_inputindex.push_if_needed(txindex, inputindex)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
vecs.txinindex_to_txoutindex.push_if_needed(txinindex, txoutindex)?;
|
vecs.inputindex_to_outputindex.push_if_needed(inputindex, outputindex)?;
|
||||||
|
|
||||||
vecs.txinindex_to_height
|
|
||||||
.push_if_needed(txinindex, height)?;
|
|
||||||
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
drop(new_txindexvout_to_txoutindex);
|
drop(new_txindexvout_to_outputindex);
|
||||||
|
|
||||||
let mut txindex_to_tx_and_txid: BTreeMap<Txindex, (&Transaction, Txid)> = BTreeMap::default();
|
let mut txindex_to_tx_and_txid: BTreeMap<TxIndex, (&Transaction, Txid)> = BTreeMap::default();
|
||||||
|
|
||||||
txid_prefix_to_txid_and_block_txindex_and_prev_txindex
|
txid_prefix_to_txid_and_block_txindex_and_prev_txindex
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -649,7 +615,7 @@ impl Indexer {
|
|||||||
match prev_txindex_opt {
|
match prev_txindex_opt {
|
||||||
None => {
|
None => {
|
||||||
stores
|
stores
|
||||||
.txid_prefix_to_txindex
|
.txidprefix_to_txindex
|
||||||
.insert_if_needed(txid_prefix, txindex, height);
|
.insert_if_needed(txid_prefix, txindex, height);
|
||||||
}
|
}
|
||||||
Some(prev_txindex) => {
|
Some(prev_txindex) => {
|
||||||
@@ -659,7 +625,7 @@ impl Indexer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !check_collisions {
|
if !check_collisions {
|
||||||
return Ok(())
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = vecs.txindex_to_txid.len();
|
let len = vecs.txindex_to_txid.len();
|
||||||
@@ -690,9 +656,7 @@ impl Indexer {
|
|||||||
let is_dup = only_known_dup_txids.contains(prev_txid);
|
let is_dup = only_known_dup_txids.contains(prev_txid);
|
||||||
|
|
||||||
if !is_dup {
|
if !is_dup {
|
||||||
let prev_height =
|
dbg!(height, txindex, prev_txid, prev_txindex);
|
||||||
vecs.txindex_to_height.get(prev_txindex)?.expect("To have height");
|
|
||||||
dbg!(height, txindex, prev_height, prev_txid, prev_txindex);
|
|
||||||
return Err(eyre!("Expect none"));
|
return Err(eyre!("Expect none"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,17 +671,16 @@ impl Indexer {
|
|||||||
.try_for_each(|(txindex, (tx, txid))| -> color_eyre::Result<()> {
|
.try_for_each(|(txindex, (tx, txid))| -> color_eyre::Result<()> {
|
||||||
vecs.txindex_to_txversion.push_if_needed(txindex, tx.version.into())?;
|
vecs.txindex_to_txversion.push_if_needed(txindex, tx.version.into())?;
|
||||||
vecs.txindex_to_txid.push_if_needed(txindex, txid)?;
|
vecs.txindex_to_txid.push_if_needed(txindex, txid)?;
|
||||||
vecs.txindex_to_height.push_if_needed(txindex, height)?;
|
|
||||||
vecs.txindex_to_rawlocktime.push_if_needed(txindex, tx.lock_time.into())?;
|
vecs.txindex_to_rawlocktime.push_if_needed(txindex, tx.lock_time.into())?;
|
||||||
vecs.txindex_to_base_size.push_if_needed(txindex, tx.base_size())?;
|
vecs.txindex_to_base_size.push_if_needed(txindex, tx.base_size().into())?;
|
||||||
vecs.txindex_to_total_size.push_if_needed(txindex, tx.total_size())?;
|
vecs.txindex_to_total_size.push_if_needed(txindex, tx.total_size().into())?;
|
||||||
vecs.txindex_to_is_explicitly_rbf.push_if_needed(txindex, tx.is_explicitly_rbf())?;
|
vecs.txindex_to_is_explicitly_rbf.push_if_needed(txindex, tx.is_explicitly_rbf())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
idxs.txindex += Txindex::from(tx_len);
|
idxs.txindex += TxIndex::from(tx_len);
|
||||||
idxs.txinindex += Txinindex::from(inputs_len);
|
idxs.inputindex += InputIndex::from(inputs_len);
|
||||||
idxs.txoutindex += Txoutindex::from(outputs_len);
|
idxs.outputindex += OutputIndex::from(outputs_len);
|
||||||
|
|
||||||
export_if_needed(stores, vecs, height, false, exit)?;
|
export_if_needed(stores, vecs, height, false, exit)?;
|
||||||
|
|
||||||
@@ -755,6 +718,6 @@ impl Indexer {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum InputSource<'a> {
|
enum InputSource<'a> {
|
||||||
PreviousBlock((Vin, Txindex, Txoutindex)),
|
PreviousBlock((Vin, TxIndex, OutputIndex)),
|
||||||
SameBlock((&'a Transaction, Txindex, &'a TxIn, Vin)),
|
SameBlock((&'a Transaction, TxIndex, &'a TxIn, Vin)),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::{fs, path::Path, thread};
|
use std::{fs, path::Path, thread};
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
AddressHash, Addressbytes, Addressindex, Addresstype, BlockHashPrefix, Height, TxidPrefix,
|
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutputType, OutputTypeIndex, TxIndex,
|
||||||
Txindex,
|
TxidPrefix,
|
||||||
};
|
};
|
||||||
use brk_vec::{Value, Version};
|
use brk_vec::{Value, Version};
|
||||||
use fjall::{PersistMode, TransactionalKeyspace};
|
use fjall::{PersistMode, TransactionalKeyspace};
|
||||||
@@ -20,9 +20,9 @@ use super::Vecs;
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Stores {
|
pub struct Stores {
|
||||||
pub keyspace: TransactionalKeyspace,
|
pub keyspace: TransactionalKeyspace,
|
||||||
pub addresshash_to_addressindex: Store<AddressHash, Addressindex>,
|
pub addressbyteshash_to_outputtypeindex: Store<AddressBytesHash, OutputTypeIndex>,
|
||||||
pub blockhash_prefix_to_height: Store<BlockHashPrefix, Height>,
|
pub blockhashprefix_to_height: Store<BlockHashPrefix, Height>,
|
||||||
pub txid_prefix_to_txindex: Store<TxidPrefix, Txindex>,
|
pub txidprefix_to_txindex: Store<TxidPrefix, TxIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stores {
|
impl Stores {
|
||||||
@@ -38,36 +38,38 @@ impl Stores {
|
|||||||
};
|
};
|
||||||
|
|
||||||
thread::scope(|scope| {
|
thread::scope(|scope| {
|
||||||
let addresshash_to_addressindex = scope.spawn(|| {
|
let addressbyteshash_to_outputtypeindex = scope.spawn(|| {
|
||||||
Store::import(
|
Store::import(
|
||||||
keyspace.clone(),
|
keyspace.clone(),
|
||||||
path,
|
path,
|
||||||
"addresshash_to_addressindex",
|
"addressbyteshash_to_outputtypeindex",
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let blockhash_prefix_to_height = scope.spawn(|| {
|
let blockhashprefix_to_height = scope.spawn(|| {
|
||||||
Store::import(
|
Store::import(
|
||||||
keyspace.clone(),
|
keyspace.clone(),
|
||||||
path,
|
path,
|
||||||
"blockhash_prefix_to_height",
|
"blockhashprefix_to_height",
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let txid_prefix_to_txindex = scope.spawn(|| {
|
let txidprefix_to_txindex = scope.spawn(|| {
|
||||||
Store::import(
|
Store::import(
|
||||||
keyspace.clone(),
|
keyspace.clone(),
|
||||||
path,
|
path,
|
||||||
"txid_prefix_to_txindex",
|
"txidprefix_to_txindex",
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
keyspace: keyspace.clone(),
|
keyspace: keyspace.clone(),
|
||||||
addresshash_to_addressindex: addresshash_to_addressindex.join().unwrap()?,
|
addressbyteshash_to_outputtypeindex: addressbyteshash_to_outputtypeindex
|
||||||
blockhash_prefix_to_height: blockhash_prefix_to_height.join().unwrap()?,
|
.join()
|
||||||
txid_prefix_to_txindex: txid_prefix_to_txindex.join().unwrap()?,
|
.unwrap()?,
|
||||||
|
blockhashprefix_to_height: blockhashprefix_to_height.join().unwrap()?,
|
||||||
|
txidprefix_to_txindex: txidprefix_to_txindex.join().unwrap()?,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -77,24 +79,24 @@ impl Stores {
|
|||||||
vecs: &mut Vecs,
|
vecs: &mut Vecs,
|
||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
) -> color_eyre::Result<()> {
|
) -> color_eyre::Result<()> {
|
||||||
if self.addresshash_to_addressindex.is_empty()
|
if self.addressbyteshash_to_outputtypeindex.is_empty()
|
||||||
&& self.blockhash_prefix_to_height.is_empty()
|
&& self.blockhashprefix_to_height.is_empty()
|
||||||
&& self.txid_prefix_to_txindex.is_empty()
|
&& self.txidprefix_to_txindex.is_empty()
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
vecs.height_to_blockhash
|
vecs.height_to_blockhash
|
||||||
.iter_from(starting_indexes.height, |(_, blockhash, ..)| {
|
.iter_from(starting_indexes.height, |(_, blockhash, ..)| {
|
||||||
let blockhash_prefix = BlockHashPrefix::from(blockhash);
|
let blockhashprefix = BlockHashPrefix::from(blockhash);
|
||||||
self.blockhash_prefix_to_height.remove(blockhash_prefix);
|
self.blockhashprefix_to_height.remove(blockhashprefix);
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
vecs.txindex_to_txid
|
vecs.txindex_to_txid
|
||||||
.iter_from(starting_indexes.txindex, |(_txindex, txid, ..)| {
|
.iter_from(starting_indexes.txindex, |(_txindex, txid, ..)| {
|
||||||
let txid_prefix = TxidPrefix::from(txid);
|
let txidprefix = TxidPrefix::from(txid);
|
||||||
self.txid_prefix_to_txindex.remove(txid_prefix);
|
self.txidprefix_to_txindex.remove(txidprefix);
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -104,13 +106,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2pk65index_to_p2pk65addressbytes
|
.p2pk65index_to_p2pk65bytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2PK65));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2PK65));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,13 +123,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2pk33index_to_p2pk33addressbytes
|
.p2pk33index_to_p2pk33bytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2PK33));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2PK33));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,13 +140,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2pkhindex_to_p2pkhaddressbytes
|
.p2pkhindex_to_p2pkhbytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2PKH));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2PKH));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,13 +157,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2shindex_to_p2shaddressbytes
|
.p2shindex_to_p2shbytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2SH));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2SH));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,13 +174,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2trindex_to_p2traddressbytes
|
.p2trindex_to_p2trbytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2TR));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2TR));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,13 +191,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2wpkhindex_to_p2wpkhaddressbytes
|
.p2wpkhindex_to_p2wpkhbytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2WPKH));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2WPKH));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,13 +208,13 @@ impl Stores {
|
|||||||
{
|
{
|
||||||
let mut index = index.into_inner();
|
let mut index = index.into_inner();
|
||||||
while let Some(typedbytes) = vecs
|
while let Some(typedbytes) = vecs
|
||||||
.p2wshindex_to_p2wshaddressbytes
|
.p2wshindex_to_p2wshbytes
|
||||||
.get(index)?
|
.get(index)?
|
||||||
.map(Value::into_inner)
|
.map(Value::into_inner)
|
||||||
{
|
{
|
||||||
let bytes = Addressbytes::from(typedbytes);
|
let bytes = AddressBytes::from(typedbytes);
|
||||||
let hash = AddressHash::from((&bytes, Addresstype::P2WSH));
|
let hash = AddressBytesHash::from((&bytes, OutputType::P2WSH));
|
||||||
self.addresshash_to_addressindex.remove(hash);
|
self.addressbyteshash_to_outputtypeindex.remove(hash);
|
||||||
index.increment();
|
index.increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,9 +226,9 @@ impl Stores {
|
|||||||
|
|
||||||
pub fn starting_height(&self) -> Height {
|
pub fn starting_height(&self) -> Height {
|
||||||
[
|
[
|
||||||
self.addresshash_to_addressindex.height(),
|
self.addressbyteshash_to_outputtypeindex.height(),
|
||||||
self.blockhash_prefix_to_height.height(),
|
self.blockhashprefix_to_height.height(),
|
||||||
self.txid_prefix_to_txindex.height(),
|
self.txidprefix_to_txindex.height(),
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|height| height.map(Height::incremented).unwrap_or_default())
|
.map(|height| height.map(Height::incremented).unwrap_or_default())
|
||||||
@@ -236,16 +238,18 @@ impl Stores {
|
|||||||
|
|
||||||
pub fn commit(&mut self, height: Height) -> fjall::Result<()> {
|
pub fn commit(&mut self, height: Height) -> fjall::Result<()> {
|
||||||
thread::scope(|scope| -> fjall::Result<()> {
|
thread::scope(|scope| -> fjall::Result<()> {
|
||||||
let addresshash_to_addressindex_commit_handle =
|
let addressbyteshash_to_outputtypeindex_commit_handle =
|
||||||
scope.spawn(|| self.addresshash_to_addressindex.commit(height));
|
scope.spawn(|| self.addressbyteshash_to_outputtypeindex.commit(height));
|
||||||
let blockhash_prefix_to_height_commit_handle =
|
let blockhashprefix_to_height_commit_handle =
|
||||||
scope.spawn(|| self.blockhash_prefix_to_height.commit(height));
|
scope.spawn(|| self.blockhashprefix_to_height.commit(height));
|
||||||
let txid_prefix_to_txindex_commit_handle =
|
let txidprefix_to_txindex_commit_handle =
|
||||||
scope.spawn(|| self.txid_prefix_to_txindex.commit(height));
|
scope.spawn(|| self.txidprefix_to_txindex.commit(height));
|
||||||
|
|
||||||
addresshash_to_addressindex_commit_handle.join().unwrap()?;
|
addressbyteshash_to_outputtypeindex_commit_handle
|
||||||
blockhash_prefix_to_height_commit_handle.join().unwrap()?;
|
.join()
|
||||||
txid_prefix_to_txindex_commit_handle.join().unwrap()?;
|
.unwrap()?;
|
||||||
|
blockhashprefix_to_height_commit_handle.join().unwrap()?;
|
||||||
|
txidprefix_to_txindex_commit_handle.join().unwrap()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
@@ -254,9 +258,9 @@ impl Stores {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn rotate_memtables(&self) {
|
pub fn rotate_memtables(&self) {
|
||||||
self.addresshash_to_addressindex.rotate_memtable();
|
self.addressbyteshash_to_outputtypeindex.rotate_memtable();
|
||||||
self.blockhash_prefix_to_height.rotate_memtable();
|
self.blockhashprefix_to_height.rotate_memtable();
|
||||||
self.txid_prefix_to_txindex.rotate_memtable();
|
self.txidprefix_to_txindex.rotate_memtable();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_keyspace(path: &Path) -> fjall::Result<TransactionalKeyspace> {
|
fn open_keyspace(path: &Path) -> fjall::Result<TransactionalKeyspace> {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
use brk_core::{
|
use brk_core::{
|
||||||
Addressbytes, Addressindex, Addresstype, Addresstypeindex, BlockHash, Emptyindex, Height,
|
AddressBytes, BlockHash, EmptyOutputIndex, Height, InputIndex, OpReturnIndex, OutputIndex,
|
||||||
Multisigindex, Opreturnindex, P2PK33AddressBytes, P2PK33index, P2PK65AddressBytes, P2PK65index,
|
OutputType, OutputTypeIndex, P2ABytes, P2AIndex, P2MSIndex, P2PK33Bytes, P2PK33Index,
|
||||||
P2PKHAddressBytes, P2PKHindex, P2SHAddressBytes, P2SHindex, P2TRAddressBytes, P2TRindex,
|
P2PK65Bytes, P2PK65Index, P2PKHBytes, P2PKHIndex, P2SHBytes, P2SHIndex, P2TRBytes, P2TRIndex,
|
||||||
P2WPKHAddressBytes, P2WPKHindex, P2WSHAddressBytes, P2WSHindex, Pushonlyindex, RawLockTime,
|
P2WPKHBytes, P2WPKHIndex, P2WSHBytes, P2WSHIndex, RawLockTime, Sats, StoredU32, StoredUsize,
|
||||||
Sats, StoredUsize, Timestamp, TxVersion, Txid, Txindex, Txinindex, Txoutindex, Unknownindex,
|
Timestamp, TxIndex, TxVersion, Txid, UnknownOutputIndex, Weight,
|
||||||
Weight,
|
|
||||||
};
|
};
|
||||||
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
|
use brk_vec::{AnyStoredVec, Compressed, Result, Version};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
@@ -19,64 +18,52 @@ pub use base::*;
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Vecs {
|
pub struct Vecs {
|
||||||
pub addressindex_to_addresstype: IndexedVec<Addressindex, Addresstype>,
|
pub emptyoutputindex_to_txindex: IndexedVec<EmptyOutputIndex, TxIndex>,
|
||||||
pub addressindex_to_addresstypeindex: IndexedVec<Addressindex, Addresstypeindex>,
|
|
||||||
pub addressindex_to_height: IndexedVec<Addressindex, Height>,
|
|
||||||
pub emptyindex_to_height: IndexedVec<Emptyindex, Height>,
|
|
||||||
pub height_to_blockhash: IndexedVec<Height, BlockHash>,
|
pub height_to_blockhash: IndexedVec<Height, BlockHash>,
|
||||||
pub height_to_difficulty: IndexedVec<Height, f64>,
|
pub height_to_difficulty: IndexedVec<Height, f64>,
|
||||||
pub height_to_first_addressindex: IndexedVec<Height, Addressindex>,
|
pub height_to_first_emptyoutputindex: IndexedVec<Height, EmptyOutputIndex>,
|
||||||
pub height_to_first_emptyindex: IndexedVec<Height, Emptyindex>,
|
pub height_to_first_inputindex: IndexedVec<Height, InputIndex>,
|
||||||
pub height_to_first_multisigindex: IndexedVec<Height, Multisigindex>,
|
pub height_to_first_opreturnindex: IndexedVec<Height, OpReturnIndex>,
|
||||||
pub height_to_first_opreturnindex: IndexedVec<Height, Opreturnindex>,
|
pub height_to_first_outputindex: IndexedVec<Height, OutputIndex>,
|
||||||
pub height_to_first_p2pk33index: IndexedVec<Height, P2PK33index>,
|
pub height_to_first_p2aindex: IndexedVec<Height, P2AIndex>,
|
||||||
pub height_to_first_p2pk65index: IndexedVec<Height, P2PK65index>,
|
pub height_to_first_p2msindex: IndexedVec<Height, P2MSIndex>,
|
||||||
pub height_to_first_p2pkhindex: IndexedVec<Height, P2PKHindex>,
|
pub height_to_first_p2pk33index: IndexedVec<Height, P2PK33Index>,
|
||||||
pub height_to_first_p2shindex: IndexedVec<Height, P2SHindex>,
|
pub height_to_first_p2pk65index: IndexedVec<Height, P2PK65Index>,
|
||||||
pub height_to_first_p2trindex: IndexedVec<Height, P2TRindex>,
|
pub height_to_first_p2pkhindex: IndexedVec<Height, P2PKHIndex>,
|
||||||
pub height_to_first_p2wpkhindex: IndexedVec<Height, P2WPKHindex>,
|
pub height_to_first_p2shindex: IndexedVec<Height, P2SHIndex>,
|
||||||
pub height_to_first_p2wshindex: IndexedVec<Height, P2WSHindex>,
|
pub height_to_first_p2trindex: IndexedVec<Height, P2TRIndex>,
|
||||||
pub height_to_first_pushonlyindex: IndexedVec<Height, Pushonlyindex>,
|
pub height_to_first_p2wpkhindex: IndexedVec<Height, P2WPKHIndex>,
|
||||||
pub height_to_first_txindex: IndexedVec<Height, Txindex>,
|
pub height_to_first_p2wshindex: IndexedVec<Height, P2WSHIndex>,
|
||||||
pub height_to_first_txinindex: IndexedVec<Height, Txinindex>,
|
pub height_to_first_txindex: IndexedVec<Height, TxIndex>,
|
||||||
pub height_to_first_txoutindex: IndexedVec<Height, Txoutindex>,
|
pub height_to_first_unknownoutputindex: IndexedVec<Height, UnknownOutputIndex>,
|
||||||
pub height_to_first_unknownindex: IndexedVec<Height, Unknownindex>,
|
/// Doesn't guarantee continuity due to possible reorgs
|
||||||
pub height_to_total_size: IndexedVec<Height, StoredUsize>,
|
|
||||||
pub height_to_timestamp: IndexedVec<Height, Timestamp>,
|
pub height_to_timestamp: IndexedVec<Height, Timestamp>,
|
||||||
|
pub height_to_total_size: IndexedVec<Height, StoredUsize>,
|
||||||
pub height_to_weight: IndexedVec<Height, Weight>,
|
pub height_to_weight: IndexedVec<Height, Weight>,
|
||||||
pub multisigindex_to_height: IndexedVec<Multisigindex, Height>,
|
/// If outputindex == Outputindex::MAX then it's coinbase
|
||||||
pub opreturnindex_to_height: IndexedVec<Opreturnindex, Height>,
|
pub inputindex_to_outputindex: IndexedVec<InputIndex, OutputIndex>,
|
||||||
pub p2pk33index_to_height: IndexedVec<P2PK33index, Height>,
|
pub opreturnindex_to_txindex: IndexedVec<OpReturnIndex, TxIndex>,
|
||||||
pub p2pk33index_to_p2pk33addressbytes: IndexedVec<P2PK33index, P2PK33AddressBytes>,
|
pub outputindex_to_outputtype: IndexedVec<OutputIndex, OutputType>,
|
||||||
pub p2pk65index_to_height: IndexedVec<P2PK65index, Height>,
|
pub outputindex_to_outputtypeindex: IndexedVec<OutputIndex, OutputTypeIndex>,
|
||||||
pub p2pk65index_to_p2pk65addressbytes: IndexedVec<P2PK65index, P2PK65AddressBytes>,
|
pub outputindex_to_value: IndexedVec<OutputIndex, Sats>,
|
||||||
pub p2pkhindex_to_height: IndexedVec<P2PKHindex, Height>,
|
pub p2aindex_to_p2abytes: IndexedVec<P2AIndex, P2ABytes>,
|
||||||
pub p2pkhindex_to_p2pkhaddressbytes: IndexedVec<P2PKHindex, P2PKHAddressBytes>,
|
pub p2msindex_to_txindex: IndexedVec<P2MSIndex, TxIndex>,
|
||||||
pub p2shindex_to_height: IndexedVec<P2SHindex, Height>,
|
pub p2pk33index_to_p2pk33bytes: IndexedVec<P2PK33Index, P2PK33Bytes>,
|
||||||
pub p2shindex_to_p2shaddressbytes: IndexedVec<P2SHindex, P2SHAddressBytes>,
|
pub p2pk65index_to_p2pk65bytes: IndexedVec<P2PK65Index, P2PK65Bytes>,
|
||||||
pub p2trindex_to_height: IndexedVec<P2TRindex, Height>,
|
pub p2pkhindex_to_p2pkhbytes: IndexedVec<P2PKHIndex, P2PKHBytes>,
|
||||||
pub p2trindex_to_p2traddressbytes: IndexedVec<P2TRindex, P2TRAddressBytes>,
|
pub p2shindex_to_p2shbytes: IndexedVec<P2SHIndex, P2SHBytes>,
|
||||||
pub p2wpkhindex_to_height: IndexedVec<P2WPKHindex, Height>,
|
pub p2trindex_to_p2trbytes: IndexedVec<P2TRIndex, P2TRBytes>,
|
||||||
pub p2wpkhindex_to_p2wpkhaddressbytes: IndexedVec<P2WPKHindex, P2WPKHAddressBytes>,
|
pub p2wpkhindex_to_p2wpkhbytes: IndexedVec<P2WPKHIndex, P2WPKHBytes>,
|
||||||
pub p2wshindex_to_height: IndexedVec<P2WSHindex, Height>,
|
pub p2wshindex_to_p2wshbytes: IndexedVec<P2WSHIndex, P2WSHBytes>,
|
||||||
pub p2wshindex_to_p2wshaddressbytes: IndexedVec<P2WSHindex, P2WSHAddressBytes>,
|
pub txindex_to_base_size: IndexedVec<TxIndex, StoredU32>,
|
||||||
pub pushonlyindex_to_height: IndexedVec<Pushonlyindex, Height>,
|
pub txindex_to_first_inputindex: IndexedVec<TxIndex, InputIndex>,
|
||||||
pub txindex_to_base_size: IndexedVec<Txindex, usize>,
|
pub txindex_to_first_outputindex: IndexedVec<TxIndex, OutputIndex>,
|
||||||
pub txindex_to_first_txinindex: IndexedVec<Txindex, Txinindex>,
|
pub txindex_to_is_explicitly_rbf: IndexedVec<TxIndex, bool>,
|
||||||
pub txindex_to_first_txoutindex: IndexedVec<Txindex, Txoutindex>,
|
pub txindex_to_rawlocktime: IndexedVec<TxIndex, RawLockTime>,
|
||||||
pub txindex_to_height: IndexedVec<Txindex, Height>,
|
pub txindex_to_total_size: IndexedVec<TxIndex, StoredU32>,
|
||||||
pub txindex_to_is_explicitly_rbf: IndexedVec<Txindex, bool>,
|
pub txindex_to_txid: IndexedVec<TxIndex, Txid>,
|
||||||
pub txindex_to_rawlocktime: IndexedVec<Txindex, RawLockTime>,
|
pub txindex_to_txversion: IndexedVec<TxIndex, TxVersion>,
|
||||||
pub txindex_to_total_size: IndexedVec<Txindex, usize>,
|
pub unknownoutputindex_to_txindex: IndexedVec<UnknownOutputIndex, TxIndex>,
|
||||||
pub txindex_to_txid: IndexedVec<Txindex, Txid>,
|
|
||||||
pub txindex_to_txversion: IndexedVec<Txindex, TxVersion>,
|
|
||||||
pub txinindex_to_height: IndexedVec<Txinindex, Height>,
|
|
||||||
/// If txoutindex == Txoutindex MAX then is it's coinbase
|
|
||||||
pub txinindex_to_txoutindex: IndexedVec<Txinindex, Txoutindex>,
|
|
||||||
pub txoutindex_to_addressindex: IndexedVec<Txoutindex, Addressindex>,
|
|
||||||
pub txoutindex_to_height: IndexedVec<Txoutindex, Height>,
|
|
||||||
pub txoutindex_to_value: IndexedVec<Txoutindex, Sats>,
|
|
||||||
pub unknownindex_to_height: IndexedVec<Unknownindex, Height>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -84,43 +71,28 @@ impl Vecs {
|
|||||||
fs::create_dir_all(path)?;
|
fs::create_dir_all(path)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
addressindex_to_addresstype: IndexedVec::forced_import(
|
emptyoutputindex_to_txindex: IndexedVec::forced_import(
|
||||||
&path.join("addressindex_to_addresstype"),
|
&path.join("emptyoutputindex_to_txindex"),
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
addressindex_to_addresstypeindex: IndexedVec::forced_import(
|
|
||||||
&path.join("addressindex_to_addresstypeindex"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
addressindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("addressindex_to_height"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_blockhash: IndexedVec::forced_import(
|
height_to_blockhash: IndexedVec::forced_import(
|
||||||
&path.join("height_to_blockhash"),
|
&path.join("height_to_blockhash"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
Compressed::NO,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_difficulty: IndexedVec::forced_import(
|
height_to_difficulty: IndexedVec::forced_import(
|
||||||
&path.join("height_to_difficulty"),
|
&path.join("height_to_difficulty"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_addressindex: IndexedVec::forced_import(
|
height_to_first_emptyoutputindex: IndexedVec::forced_import(
|
||||||
&path.join("height_to_first_addressindex"),
|
&path.join("height_to_first_emptyoutputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_emptyindex: IndexedVec::forced_import(
|
height_to_first_inputindex: IndexedVec::forced_import(
|
||||||
&path.join("height_to_first_emptyindex"),
|
&path.join("height_to_first_inputindex"),
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
height_to_first_multisigindex: IndexedVec::forced_import(
|
|
||||||
&path.join("height_to_first_multisigindex"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -129,28 +101,18 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_pushonlyindex: IndexedVec::forced_import(
|
height_to_first_outputindex: IndexedVec::forced_import(
|
||||||
&path.join("height_to_first_pushonlyindex"),
|
&path.join("height_to_first_outputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_txindex: IndexedVec::forced_import(
|
height_to_first_p2aindex: IndexedVec::forced_import(
|
||||||
&path.join("height_to_first_txindex"),
|
&path.join("height_to_first_p2aindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_first_txinindex: IndexedVec::forced_import(
|
height_to_first_p2msindex: IndexedVec::forced_import(
|
||||||
&path.join("height_to_first_txinindex"),
|
&path.join("height_to_first_p2msindex"),
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
height_to_first_txoutindex: IndexedVec::forced_import(
|
|
||||||
&path.join("height_to_first_txoutindex"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
height_to_first_unknownindex: IndexedVec::forced_import(
|
|
||||||
&path.join("height_to_first_unkownindex"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -189,8 +151,13 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
height_to_total_size: IndexedVec::forced_import(
|
height_to_first_txindex: IndexedVec::forced_import(
|
||||||
&path.join("height_to_total_size"),
|
&path.join("height_to_first_txindex"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
height_to_first_unknownoutputindex: IndexedVec::forced_import(
|
||||||
|
&path.join("height_to_first_unknownoutputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -199,78 +166,98 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
|
height_to_total_size: IndexedVec::forced_import(
|
||||||
|
&path.join("height_to_total_size"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
height_to_weight: IndexedVec::forced_import(
|
height_to_weight: IndexedVec::forced_import(
|
||||||
&path.join("height_to_weight"),
|
&path.join("height_to_weight"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
p2pk33index_to_p2pk33addressbytes: IndexedVec::forced_import(
|
inputindex_to_outputindex: IndexedVec::forced_import(
|
||||||
&path.join("p2pk33index_to_p2pk33addressbytes"),
|
&path.join("inputindex_to_outputindex"),
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
p2pk65index_to_p2pk65addressbytes: IndexedVec::forced_import(
|
|
||||||
&path.join("p2pk65index_to_p2pk65addressbytes"),
|
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
p2pkhindex_to_p2pkhaddressbytes: IndexedVec::forced_import(
|
|
||||||
&path.join("p2pkhindex_to_p2pkhaddressbytes"),
|
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
p2shindex_to_p2shaddressbytes: IndexedVec::forced_import(
|
|
||||||
&path.join("p2shindex_to_p2shaddressbytes"),
|
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
p2trindex_to_p2traddressbytes: IndexedVec::forced_import(
|
|
||||||
&path.join("p2trindex_to_p2traddressbytes"),
|
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
p2wpkhindex_to_p2wpkhaddressbytes: IndexedVec::forced_import(
|
|
||||||
&path.join("p2wpkhindex_to_p2wpkhaddressbytes"),
|
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
p2wshindex_to_p2wshaddressbytes: IndexedVec::forced_import(
|
|
||||||
&path.join("p2wshindex_to_p2wshaddressbytes"),
|
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
txindex_to_first_txinindex: IndexedVec::forced_import(
|
|
||||||
&path.join("txindex_to_first_txinindex"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_first_txoutindex: IndexedVec::forced_import(
|
opreturnindex_to_txindex: IndexedVec::forced_import(
|
||||||
&path.join("txindex_to_first_txoutindex"),
|
&path.join("opreturnindex_to_txindex"),
|
||||||
Version::ZERO,
|
|
||||||
Compressed::NO,
|
|
||||||
)?,
|
|
||||||
txindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("txindex_to_height"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_rawlocktime: IndexedVec::forced_import(
|
outputindex_to_outputtype: IndexedVec::forced_import(
|
||||||
&path.join("txindex_to_locktime"),
|
&path.join("outputindex_to_outputtype"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_txid: IndexedVec::forced_import(
|
outputindex_to_outputtypeindex: IndexedVec::forced_import(
|
||||||
&path.join("txindex_to_txid"),
|
&path.join("outputindex_to_outputtypeindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
Compressed::NO,
|
compressed,
|
||||||
|
)?,
|
||||||
|
outputindex_to_value: IndexedVec::forced_import(
|
||||||
|
&path.join("outputindex_to_value"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2aindex_to_p2abytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2aindex_to_p2abytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2msindex_to_txindex: IndexedVec::forced_import(
|
||||||
|
&path.join("p2msindex_to_txindex"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2pk33index_to_p2pk33bytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2pk33index_to_p2pk33bytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2pk65index_to_p2pk65bytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2pk65index_to_p2pk65bytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2pkhindex_to_p2pkhbytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2pkhindex_to_p2pkhbytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2shindex_to_p2shbytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2shindex_to_p2shbytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2trindex_to_p2trbytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2trindex_to_p2trbytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2wpkhindex_to_p2wpkhbytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2wpkhindex_to_p2wpkhbytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
p2wshindex_to_p2wshbytes: IndexedVec::forced_import(
|
||||||
|
&path.join("p2wshindex_to_p2wshbytes"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_base_size: IndexedVec::forced_import(
|
txindex_to_base_size: IndexedVec::forced_import(
|
||||||
&path.join("txindex_to_base_size"),
|
&path.join("txindex_to_base_size"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txindex_to_total_size: IndexedVec::forced_import(
|
txindex_to_first_inputindex: IndexedVec::forced_import(
|
||||||
&path.join("txindex_to_total_size"),
|
&path.join("txindex_to_first_inputindex"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
txindex_to_first_outputindex: IndexedVec::forced_import(
|
||||||
|
&path.join("txindex_to_first_outputindex"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -279,93 +266,28 @@ impl Vecs {
|
|||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
|
txindex_to_rawlocktime: IndexedVec::forced_import(
|
||||||
|
&path.join("txindex_to_rawlocktime"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
txindex_to_total_size: IndexedVec::forced_import(
|
||||||
|
&path.join("txindex_to_total_size"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
|
txindex_to_txid: IndexedVec::forced_import(
|
||||||
|
&path.join("txindex_to_txid"),
|
||||||
|
Version::ZERO,
|
||||||
|
compressed,
|
||||||
|
)?,
|
||||||
txindex_to_txversion: IndexedVec::forced_import(
|
txindex_to_txversion: IndexedVec::forced_import(
|
||||||
&path.join("txindex_to_txversion"),
|
&path.join("txindex_to_txversion"),
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
txinindex_to_txoutindex: IndexedVec::forced_import(
|
unknownoutputindex_to_txindex: IndexedVec::forced_import(
|
||||||
&path.join("txinindex_to_txoutindex"),
|
&path.join("unknownoutputindex_to_txindex"),
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
txoutindex_to_addressindex: IndexedVec::forced_import(
|
|
||||||
&path.join("txoutindex_to_addressindex"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
txoutindex_to_value: IndexedVec::forced_import(
|
|
||||||
&path.join("txoutindex_to_value"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
emptyindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("emptyindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
multisigindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("multisigindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
opreturnindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("opreturnindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
pushonlyindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("pushonlyindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
txinindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("txinindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
txoutindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("txoutindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
unknownindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("unknownindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2pk33index_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2pk33index_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2pk65index_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2pk65index_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2pkhindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2pkhindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2shindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2shindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2trindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2trindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2wpkhindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2wpkhindex_to_height"),
|
|
||||||
Version::ZERO,
|
|
||||||
compressed,
|
|
||||||
)?,
|
|
||||||
p2wshindex_to_height: IndexedVec::forced_import(
|
|
||||||
&path.join("p2wshindex_to_height"),
|
|
||||||
Version::ZERO,
|
Version::ZERO,
|
||||||
compressed,
|
compressed,
|
||||||
)?,
|
)?,
|
||||||
@@ -376,8 +298,13 @@ impl Vecs {
|
|||||||
let saved_height = starting_indexes.height.decremented().unwrap_or_default();
|
let saved_height = starting_indexes.height.decremented().unwrap_or_default();
|
||||||
|
|
||||||
let &Indexes {
|
let &Indexes {
|
||||||
addressindex,
|
emptyoutputindex,
|
||||||
height,
|
height,
|
||||||
|
inputindex,
|
||||||
|
opreturnindex,
|
||||||
|
outputindex,
|
||||||
|
p2aindex,
|
||||||
|
p2msindex,
|
||||||
p2pk33index,
|
p2pk33index,
|
||||||
p2pk65index,
|
p2pk65index,
|
||||||
p2pkhindex,
|
p2pkhindex,
|
||||||
@@ -386,23 +313,27 @@ impl Vecs {
|
|||||||
p2wpkhindex,
|
p2wpkhindex,
|
||||||
p2wshindex,
|
p2wshindex,
|
||||||
txindex,
|
txindex,
|
||||||
txinindex,
|
unknownoutputindex,
|
||||||
txoutindex,
|
|
||||||
unknownindex,
|
|
||||||
pushonlyindex,
|
|
||||||
opreturnindex,
|
|
||||||
multisigindex,
|
|
||||||
emptyindex,
|
|
||||||
} = starting_indexes;
|
} = starting_indexes;
|
||||||
|
|
||||||
self.height_to_first_addressindex
|
self.emptyoutputindex_to_txindex
|
||||||
|
.truncate_if_needed(emptyoutputindex, saved_height)?;
|
||||||
|
self.height_to_blockhash
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_emptyindex
|
self.height_to_difficulty
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_multisigindex
|
self.height_to_first_emptyoutputindex
|
||||||
|
.truncate_if_needed(height, saved_height)?;
|
||||||
|
self.height_to_first_inputindex
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_opreturnindex
|
self.height_to_first_opreturnindex
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
|
self.height_to_first_outputindex
|
||||||
|
.truncate_if_needed(height, saved_height)?;
|
||||||
|
self.height_to_first_p2aindex
|
||||||
|
.truncate_if_needed(height, saved_height)?;
|
||||||
|
self.height_to_first_p2msindex
|
||||||
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_p2pk33index
|
self.height_to_first_p2pk33index
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_p2pk65index
|
self.height_to_first_p2pk65index
|
||||||
@@ -417,180 +348,139 @@ impl Vecs {
|
|||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_p2wshindex
|
self.height_to_first_p2wshindex
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_pushonlyindex
|
|
||||||
.truncate_if_needed(height, saved_height)?;
|
|
||||||
self.height_to_first_txindex
|
self.height_to_first_txindex
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_first_txinindex
|
self.height_to_first_unknownoutputindex
|
||||||
.truncate_if_needed(height, saved_height)?;
|
|
||||||
self.height_to_first_txoutindex
|
|
||||||
.truncate_if_needed(height, saved_height)?;
|
|
||||||
self.height_to_first_unknownindex
|
|
||||||
.truncate_if_needed(height, saved_height)?;
|
|
||||||
|
|
||||||
self.height_to_blockhash
|
|
||||||
.truncate_if_needed(height, saved_height)?;
|
|
||||||
self.height_to_difficulty
|
|
||||||
.truncate_if_needed(height, saved_height)?;
|
|
||||||
self.height_to_total_size
|
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_timestamp
|
self.height_to_timestamp
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
|
self.height_to_total_size
|
||||||
|
.truncate_if_needed(height, saved_height)?;
|
||||||
self.height_to_weight
|
self.height_to_weight
|
||||||
.truncate_if_needed(height, saved_height)?;
|
.truncate_if_needed(height, saved_height)?;
|
||||||
|
self.inputindex_to_outputindex
|
||||||
self.addressindex_to_addresstype
|
.truncate_if_needed(inputindex, saved_height)?;
|
||||||
.truncate_if_needed(addressindex, saved_height)?;
|
self.opreturnindex_to_txindex
|
||||||
self.addressindex_to_addresstypeindex
|
.truncate_if_needed(opreturnindex, saved_height)?;
|
||||||
.truncate_if_needed(addressindex, saved_height)?;
|
self.outputindex_to_outputtype
|
||||||
self.addressindex_to_height
|
.truncate_if_needed(outputindex, saved_height)?;
|
||||||
.truncate_if_needed(addressindex, saved_height)?;
|
self.outputindex_to_outputtypeindex
|
||||||
|
.truncate_if_needed(outputindex, saved_height)?;
|
||||||
self.p2pk33index_to_p2pk33addressbytes
|
self.outputindex_to_value
|
||||||
|
.truncate_if_needed(outputindex, saved_height)?;
|
||||||
|
self.p2aindex_to_p2abytes
|
||||||
|
.truncate_if_needed(p2aindex, saved_height)?;
|
||||||
|
self.p2msindex_to_txindex
|
||||||
|
.truncate_if_needed(p2msindex, saved_height)?;
|
||||||
|
self.p2pk33index_to_p2pk33bytes
|
||||||
.truncate_if_needed(p2pk33index, saved_height)?;
|
.truncate_if_needed(p2pk33index, saved_height)?;
|
||||||
self.p2pk65index_to_p2pk65addressbytes
|
self.p2pk65index_to_p2pk65bytes
|
||||||
.truncate_if_needed(p2pk65index, saved_height)?;
|
.truncate_if_needed(p2pk65index, saved_height)?;
|
||||||
self.p2pkhindex_to_p2pkhaddressbytes
|
self.p2pkhindex_to_p2pkhbytes
|
||||||
.truncate_if_needed(p2pkhindex, saved_height)?;
|
.truncate_if_needed(p2pkhindex, saved_height)?;
|
||||||
self.p2shindex_to_p2shaddressbytes
|
self.p2shindex_to_p2shbytes
|
||||||
.truncate_if_needed(p2shindex, saved_height)?;
|
.truncate_if_needed(p2shindex, saved_height)?;
|
||||||
self.p2trindex_to_p2traddressbytes
|
self.p2trindex_to_p2trbytes
|
||||||
.truncate_if_needed(p2trindex, saved_height)?;
|
.truncate_if_needed(p2trindex, saved_height)?;
|
||||||
self.p2wpkhindex_to_p2wpkhaddressbytes
|
self.p2wpkhindex_to_p2wpkhbytes
|
||||||
.truncate_if_needed(p2wpkhindex, saved_height)?;
|
.truncate_if_needed(p2wpkhindex, saved_height)?;
|
||||||
self.p2wshindex_to_p2wshaddressbytes
|
self.p2wshindex_to_p2wshbytes
|
||||||
.truncate_if_needed(p2wshindex, saved_height)?;
|
.truncate_if_needed(p2wshindex, saved_height)?;
|
||||||
|
self.txindex_to_base_size
|
||||||
self.txindex_to_first_txinindex
|
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
self.txindex_to_first_txoutindex
|
self.txindex_to_first_inputindex
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
self.txindex_to_height
|
self.txindex_to_first_outputindex
|
||||||
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
|
self.txindex_to_is_explicitly_rbf
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
self.txindex_to_rawlocktime
|
self.txindex_to_rawlocktime
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
|
self.txindex_to_total_size
|
||||||
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
self.txindex_to_txid
|
self.txindex_to_txid
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
self.txindex_to_txversion
|
self.txindex_to_txversion
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(txindex, saved_height)?;
|
||||||
self.txindex_to_base_size
|
self.unknownoutputindex_to_txindex
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
.truncate_if_needed(unknownoutputindex, saved_height)?;
|
||||||
self.txindex_to_total_size
|
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
|
||||||
self.txindex_to_is_explicitly_rbf
|
|
||||||
.truncate_if_needed(txindex, saved_height)?;
|
|
||||||
|
|
||||||
self.txinindex_to_txoutindex
|
|
||||||
.truncate_if_needed(txinindex, saved_height)?;
|
|
||||||
|
|
||||||
self.txoutindex_to_addressindex
|
|
||||||
.truncate_if_needed(txoutindex, saved_height)?;
|
|
||||||
self.txoutindex_to_value
|
|
||||||
.truncate_if_needed(txoutindex, saved_height)?;
|
|
||||||
|
|
||||||
self.emptyindex_to_height
|
|
||||||
.truncate_if_needed(emptyindex, saved_height)?;
|
|
||||||
self.multisigindex_to_height
|
|
||||||
.truncate_if_needed(multisigindex, saved_height)?;
|
|
||||||
self.opreturnindex_to_height
|
|
||||||
.truncate_if_needed(opreturnindex, saved_height)?;
|
|
||||||
self.pushonlyindex_to_height
|
|
||||||
.truncate_if_needed(pushonlyindex, saved_height)?;
|
|
||||||
self.txinindex_to_height
|
|
||||||
.truncate_if_needed(txinindex, saved_height)?;
|
|
||||||
self.txoutindex_to_height
|
|
||||||
.truncate_if_needed(txoutindex, saved_height)?;
|
|
||||||
self.unknownindex_to_height
|
|
||||||
.truncate_if_needed(unknownindex, saved_height)?;
|
|
||||||
self.p2pk33index_to_height
|
|
||||||
.truncate_if_needed(p2pk33index, saved_height)?;
|
|
||||||
self.p2pk65index_to_height
|
|
||||||
.truncate_if_needed(p2pk65index, saved_height)?;
|
|
||||||
self.p2pkhindex_to_height
|
|
||||||
.truncate_if_needed(p2pkhindex, saved_height)?;
|
|
||||||
self.p2shindex_to_height
|
|
||||||
.truncate_if_needed(p2shindex, saved_height)?;
|
|
||||||
self.p2trindex_to_height
|
|
||||||
.truncate_if_needed(p2trindex, saved_height)?;
|
|
||||||
self.p2wpkhindex_to_height
|
|
||||||
.truncate_if_needed(p2wpkhindex, saved_height)?;
|
|
||||||
self.p2wshindex_to_height
|
|
||||||
.truncate_if_needed(p2wshindex, saved_height)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_addressbytes(
|
pub fn get_addressbytes(
|
||||||
&self,
|
&self,
|
||||||
addresstype: Addresstype,
|
outputtype: OutputType,
|
||||||
addresstypeindex: Addresstypeindex,
|
outputtypeindex: OutputTypeIndex,
|
||||||
) -> brk_vec::Result<Option<Addressbytes>> {
|
) -> brk_vec::Result<Option<AddressBytes>> {
|
||||||
Ok(match addresstype {
|
Ok(match outputtype {
|
||||||
Addresstype::P2PK65 => self
|
OutputType::P2PK65 => self
|
||||||
.p2pk65index_to_p2pk65addressbytes
|
.p2pk65index_to_p2pk65bytes
|
||||||
.get(addresstypeindex.into())?
|
.get(outputtypeindex.into())?
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
OutputType::P2PK33 => self
|
||||||
Addresstype::P2PK33 => self
|
.p2pk33index_to_p2pk33bytes
|
||||||
.p2pk33index_to_p2pk33addressbytes
|
.get(outputtypeindex.into())?
|
||||||
.get(addresstypeindex.into())?
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
OutputType::P2PKH => self
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
.p2pkhindex_to_p2pkhbytes
|
||||||
Addresstype::P2PKH => self
|
.get(outputtypeindex.into())?
|
||||||
.p2pkhindex_to_p2pkhaddressbytes
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
.get(addresstypeindex.into())?
|
OutputType::P2SH => self
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
.p2shindex_to_p2shbytes
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
.get(outputtypeindex.into())?
|
||||||
Addresstype::P2SH => self
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
.p2shindex_to_p2shaddressbytes
|
OutputType::P2WPKH => self
|
||||||
.get(addresstypeindex.into())?
|
.p2wpkhindex_to_p2wpkhbytes
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
.get(outputtypeindex.into())?
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
Addresstype::P2WPKH => self
|
OutputType::P2WSH => self
|
||||||
.p2wpkhindex_to_p2wpkhaddressbytes
|
.p2wshindex_to_p2wshbytes
|
||||||
.get(addresstypeindex.into())?
|
.get(outputtypeindex.into())?
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
OutputType::P2TR => self
|
||||||
Addresstype::P2WSH => self
|
.p2trindex_to_p2trbytes
|
||||||
.p2wshindex_to_p2wshaddressbytes
|
.get(outputtypeindex.into())?
|
||||||
.get(addresstypeindex.into())?
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
OutputType::P2A => self
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
.p2aindex_to_p2abytes
|
||||||
Addresstype::P2TR => self
|
.get(outputtypeindex.into())?
|
||||||
.p2trindex_to_p2traddressbytes
|
.map(|v| AddressBytes::from(v.into_inner())),
|
||||||
.get(addresstypeindex.into())?
|
OutputType::Empty | OutputType::OpReturn | OutputType::P2MS | OutputType::Unknown => {
|
||||||
// .map(|v| Addressbytes::from(v.clone())),
|
unreachable!()
|
||||||
.map(|v| Addressbytes::from(v.into_inner())),
|
}
|
||||||
_ => unreachable!(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_addressbytes_if_needed(
|
pub fn push_bytes_if_needed(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: Addresstypeindex,
|
index: OutputTypeIndex,
|
||||||
addressbytes: Addressbytes,
|
bytes: AddressBytes,
|
||||||
) -> brk_vec::Result<()> {
|
) -> brk_vec::Result<()> {
|
||||||
match addressbytes {
|
match bytes {
|
||||||
Addressbytes::P2PK65(bytes) => self
|
AddressBytes::P2PK65(bytes) => self
|
||||||
.p2pk65index_to_p2pk65addressbytes
|
.p2pk65index_to_p2pk65bytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
Addressbytes::P2PK33(bytes) => self
|
AddressBytes::P2PK33(bytes) => self
|
||||||
.p2pk33index_to_p2pk33addressbytes
|
.p2pk33index_to_p2pk33bytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
Addressbytes::P2PKH(bytes) => self
|
AddressBytes::P2PKH(bytes) => self
|
||||||
.p2pkhindex_to_p2pkhaddressbytes
|
.p2pkhindex_to_p2pkhbytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
Addressbytes::P2SH(bytes) => self
|
AddressBytes::P2SH(bytes) => self
|
||||||
.p2shindex_to_p2shaddressbytes
|
.p2shindex_to_p2shbytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
Addressbytes::P2WPKH(bytes) => self
|
AddressBytes::P2WPKH(bytes) => self
|
||||||
.p2wpkhindex_to_p2wpkhaddressbytes
|
.p2wpkhindex_to_p2wpkhbytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
Addressbytes::P2WSH(bytes) => self
|
AddressBytes::P2WSH(bytes) => self
|
||||||
.p2wshindex_to_p2wshaddressbytes
|
.p2wshindex_to_p2wshbytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
Addressbytes::P2TR(bytes) => self
|
AddressBytes::P2TR(bytes) => self
|
||||||
.p2trindex_to_p2traddressbytes
|
.p2trindex_to_p2trbytes
|
||||||
|
.push_if_needed(index.into(), bytes),
|
||||||
|
AddressBytes::P2A(bytes) => self
|
||||||
|
.p2aindex_to_p2abytes
|
||||||
.push_if_needed(index.into(), bytes),
|
.push_if_needed(index.into(), bytes),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -611,20 +501,15 @@ impl Vecs {
|
|||||||
|
|
||||||
pub fn as_any_vecs(&self) -> Vec<&dyn AnyStoredVec> {
|
pub fn as_any_vecs(&self) -> Vec<&dyn AnyStoredVec> {
|
||||||
vec![
|
vec![
|
||||||
self.addressindex_to_addresstype.any_vec(),
|
self.emptyoutputindex_to_txindex.any_vec(),
|
||||||
self.addressindex_to_addresstypeindex.any_vec(),
|
|
||||||
self.addressindex_to_height.any_vec(),
|
|
||||||
self.height_to_blockhash.any_vec(),
|
self.height_to_blockhash.any_vec(),
|
||||||
self.height_to_difficulty.any_vec(),
|
self.height_to_difficulty.any_vec(),
|
||||||
self.height_to_first_addressindex.any_vec(),
|
self.height_to_first_emptyoutputindex.any_vec(),
|
||||||
self.height_to_first_emptyindex.any_vec(),
|
self.height_to_first_inputindex.any_vec(),
|
||||||
self.height_to_first_multisigindex.any_vec(),
|
|
||||||
self.height_to_first_opreturnindex.any_vec(),
|
self.height_to_first_opreturnindex.any_vec(),
|
||||||
self.height_to_first_pushonlyindex.any_vec(),
|
self.height_to_first_outputindex.any_vec(),
|
||||||
self.height_to_first_txindex.any_vec(),
|
self.height_to_first_p2aindex.any_vec(),
|
||||||
self.height_to_first_txinindex.any_vec(),
|
self.height_to_first_p2msindex.any_vec(),
|
||||||
self.height_to_first_txoutindex.any_vec(),
|
|
||||||
self.height_to_first_unknownindex.any_vec(),
|
|
||||||
self.height_to_first_p2pk33index.any_vec(),
|
self.height_to_first_p2pk33index.any_vec(),
|
||||||
self.height_to_first_p2pk65index.any_vec(),
|
self.height_to_first_p2pk65index.any_vec(),
|
||||||
self.height_to_first_p2pkhindex.any_vec(),
|
self.height_to_first_p2pkhindex.any_vec(),
|
||||||
@@ -632,61 +517,48 @@ impl Vecs {
|
|||||||
self.height_to_first_p2trindex.any_vec(),
|
self.height_to_first_p2trindex.any_vec(),
|
||||||
self.height_to_first_p2wpkhindex.any_vec(),
|
self.height_to_first_p2wpkhindex.any_vec(),
|
||||||
self.height_to_first_p2wshindex.any_vec(),
|
self.height_to_first_p2wshindex.any_vec(),
|
||||||
self.height_to_total_size.any_vec(),
|
self.height_to_first_txindex.any_vec(),
|
||||||
|
self.height_to_first_unknownoutputindex.any_vec(),
|
||||||
self.height_to_timestamp.any_vec(),
|
self.height_to_timestamp.any_vec(),
|
||||||
|
self.height_to_total_size.any_vec(),
|
||||||
self.height_to_weight.any_vec(),
|
self.height_to_weight.any_vec(),
|
||||||
self.p2pk33index_to_p2pk33addressbytes.any_vec(),
|
self.inputindex_to_outputindex.any_vec(),
|
||||||
self.p2pk65index_to_p2pk65addressbytes.any_vec(),
|
self.opreturnindex_to_txindex.any_vec(),
|
||||||
self.p2pkhindex_to_p2pkhaddressbytes.any_vec(),
|
self.outputindex_to_outputtype.any_vec(),
|
||||||
self.p2shindex_to_p2shaddressbytes.any_vec(),
|
self.outputindex_to_outputtypeindex.any_vec(),
|
||||||
self.p2trindex_to_p2traddressbytes.any_vec(),
|
self.outputindex_to_value.any_vec(),
|
||||||
self.p2wpkhindex_to_p2wpkhaddressbytes.any_vec(),
|
self.p2aindex_to_p2abytes.any_vec(),
|
||||||
self.p2wshindex_to_p2wshaddressbytes.any_vec(),
|
self.p2msindex_to_txindex.any_vec(),
|
||||||
self.txindex_to_first_txinindex.any_vec(),
|
self.p2pk33index_to_p2pk33bytes.any_vec(),
|
||||||
self.txindex_to_first_txoutindex.any_vec(),
|
self.p2pk65index_to_p2pk65bytes.any_vec(),
|
||||||
self.txindex_to_height.any_vec(),
|
self.p2pkhindex_to_p2pkhbytes.any_vec(),
|
||||||
self.txindex_to_rawlocktime.any_vec(),
|
self.p2shindex_to_p2shbytes.any_vec(),
|
||||||
self.txindex_to_txid.any_vec(),
|
self.p2trindex_to_p2trbytes.any_vec(),
|
||||||
|
self.p2wpkhindex_to_p2wpkhbytes.any_vec(),
|
||||||
|
self.p2wshindex_to_p2wshbytes.any_vec(),
|
||||||
self.txindex_to_base_size.any_vec(),
|
self.txindex_to_base_size.any_vec(),
|
||||||
self.txindex_to_total_size.any_vec(),
|
self.txindex_to_first_inputindex.any_vec(),
|
||||||
|
self.txindex_to_first_outputindex.any_vec(),
|
||||||
self.txindex_to_is_explicitly_rbf.any_vec(),
|
self.txindex_to_is_explicitly_rbf.any_vec(),
|
||||||
|
self.txindex_to_rawlocktime.any_vec(),
|
||||||
|
self.txindex_to_total_size.any_vec(),
|
||||||
|
self.txindex_to_txid.any_vec(),
|
||||||
self.txindex_to_txversion.any_vec(),
|
self.txindex_to_txversion.any_vec(),
|
||||||
self.txinindex_to_txoutindex.any_vec(),
|
self.unknownoutputindex_to_txindex.any_vec(),
|
||||||
self.txoutindex_to_addressindex.any_vec(),
|
|
||||||
self.txoutindex_to_value.any_vec(),
|
|
||||||
self.emptyindex_to_height.any_vec(),
|
|
||||||
self.multisigindex_to_height.any_vec(),
|
|
||||||
self.opreturnindex_to_height.any_vec(),
|
|
||||||
self.pushonlyindex_to_height.any_vec(),
|
|
||||||
self.txinindex_to_height.any_vec(),
|
|
||||||
self.txoutindex_to_height.any_vec(),
|
|
||||||
self.unknownindex_to_height.any_vec(),
|
|
||||||
self.p2pk33index_to_height.any_vec(),
|
|
||||||
self.p2pk65index_to_height.any_vec(),
|
|
||||||
self.p2pkhindex_to_height.any_vec(),
|
|
||||||
self.p2shindex_to_height.any_vec(),
|
|
||||||
self.p2trindex_to_height.any_vec(),
|
|
||||||
self.p2wpkhindex_to_height.any_vec(),
|
|
||||||
self.p2wshindex_to_height.any_vec(),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_mut_any_vecs(&mut self) -> Vec<&mut dyn AnyIndexedVec> {
|
fn as_mut_any_vecs(&mut self) -> Vec<&mut dyn AnyIndexedVec> {
|
||||||
vec![
|
vec![
|
||||||
&mut self.addressindex_to_addresstype,
|
&mut self.emptyoutputindex_to_txindex,
|
||||||
&mut self.addressindex_to_addresstypeindex,
|
|
||||||
&mut self.addressindex_to_height,
|
|
||||||
&mut self.height_to_blockhash,
|
&mut self.height_to_blockhash,
|
||||||
&mut self.height_to_difficulty,
|
&mut self.height_to_difficulty,
|
||||||
&mut self.height_to_first_addressindex,
|
&mut self.height_to_first_emptyoutputindex,
|
||||||
&mut self.height_to_first_emptyindex,
|
&mut self.height_to_first_inputindex,
|
||||||
&mut self.height_to_first_multisigindex,
|
|
||||||
&mut self.height_to_first_opreturnindex,
|
&mut self.height_to_first_opreturnindex,
|
||||||
&mut self.height_to_first_pushonlyindex,
|
&mut self.height_to_first_outputindex,
|
||||||
&mut self.height_to_first_txindex,
|
&mut self.height_to_first_p2aindex,
|
||||||
&mut self.height_to_first_txinindex,
|
&mut self.height_to_first_p2msindex,
|
||||||
&mut self.height_to_first_txoutindex,
|
|
||||||
&mut self.height_to_first_unknownindex,
|
|
||||||
&mut self.height_to_first_p2pk33index,
|
&mut self.height_to_first_p2pk33index,
|
||||||
&mut self.height_to_first_p2pk65index,
|
&mut self.height_to_first_p2pk65index,
|
||||||
&mut self.height_to_first_p2pkhindex,
|
&mut self.height_to_first_p2pkhindex,
|
||||||
@@ -694,42 +566,34 @@ impl Vecs {
|
|||||||
&mut self.height_to_first_p2trindex,
|
&mut self.height_to_first_p2trindex,
|
||||||
&mut self.height_to_first_p2wpkhindex,
|
&mut self.height_to_first_p2wpkhindex,
|
||||||
&mut self.height_to_first_p2wshindex,
|
&mut self.height_to_first_p2wshindex,
|
||||||
&mut self.height_to_total_size,
|
&mut self.height_to_first_txindex,
|
||||||
|
&mut self.height_to_first_unknownoutputindex,
|
||||||
&mut self.height_to_timestamp,
|
&mut self.height_to_timestamp,
|
||||||
|
&mut self.height_to_total_size,
|
||||||
&mut self.height_to_weight,
|
&mut self.height_to_weight,
|
||||||
&mut self.p2pk33index_to_p2pk33addressbytes,
|
&mut self.inputindex_to_outputindex,
|
||||||
&mut self.p2pk65index_to_p2pk65addressbytes,
|
&mut self.opreturnindex_to_txindex,
|
||||||
&mut self.p2pkhindex_to_p2pkhaddressbytes,
|
&mut self.outputindex_to_outputtype,
|
||||||
&mut self.p2shindex_to_p2shaddressbytes,
|
&mut self.outputindex_to_outputtypeindex,
|
||||||
&mut self.p2trindex_to_p2traddressbytes,
|
&mut self.outputindex_to_value,
|
||||||
&mut self.p2wpkhindex_to_p2wpkhaddressbytes,
|
&mut self.p2aindex_to_p2abytes,
|
||||||
&mut self.p2wshindex_to_p2wshaddressbytes,
|
&mut self.p2msindex_to_txindex,
|
||||||
&mut self.txindex_to_first_txinindex,
|
&mut self.p2pk33index_to_p2pk33bytes,
|
||||||
&mut self.txindex_to_first_txoutindex,
|
&mut self.p2pk65index_to_p2pk65bytes,
|
||||||
&mut self.txindex_to_height,
|
&mut self.p2pkhindex_to_p2pkhbytes,
|
||||||
&mut self.txindex_to_rawlocktime,
|
&mut self.p2shindex_to_p2shbytes,
|
||||||
&mut self.txindex_to_txid,
|
&mut self.p2trindex_to_p2trbytes,
|
||||||
|
&mut self.p2wpkhindex_to_p2wpkhbytes,
|
||||||
|
&mut self.p2wshindex_to_p2wshbytes,
|
||||||
&mut self.txindex_to_base_size,
|
&mut self.txindex_to_base_size,
|
||||||
&mut self.txindex_to_total_size,
|
&mut self.txindex_to_first_inputindex,
|
||||||
|
&mut self.txindex_to_first_outputindex,
|
||||||
&mut self.txindex_to_is_explicitly_rbf,
|
&mut self.txindex_to_is_explicitly_rbf,
|
||||||
|
&mut self.txindex_to_rawlocktime,
|
||||||
|
&mut self.txindex_to_total_size,
|
||||||
|
&mut self.txindex_to_txid,
|
||||||
&mut self.txindex_to_txversion,
|
&mut self.txindex_to_txversion,
|
||||||
&mut self.txinindex_to_txoutindex,
|
&mut self.unknownoutputindex_to_txindex,
|
||||||
&mut self.txoutindex_to_addressindex,
|
|
||||||
&mut self.txoutindex_to_value,
|
|
||||||
&mut self.emptyindex_to_height,
|
|
||||||
&mut self.multisigindex_to_height,
|
|
||||||
&mut self.opreturnindex_to_height,
|
|
||||||
&mut self.pushonlyindex_to_height,
|
|
||||||
&mut self.txinindex_to_height,
|
|
||||||
&mut self.txoutindex_to_height,
|
|
||||||
&mut self.unknownindex_to_height,
|
|
||||||
&mut self.p2pk33index_to_height,
|
|
||||||
&mut self.p2pk65index_to_height,
|
|
||||||
&mut self.p2pkhindex_to_height,
|
|
||||||
&mut self.p2shindex_to_height,
|
|
||||||
&mut self.p2trindex_to_height,
|
|
||||||
&mut self.p2wpkhindex_to_height,
|
|
||||||
&mut self.p2wshindex_to_height,
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ pub enum Index {
|
|||||||
P2WPKHindex,
|
P2WPKHindex,
|
||||||
P2WSHindex,
|
P2WSHindex,
|
||||||
Txindex,
|
Txindex,
|
||||||
Txinindex,
|
Inputindex,
|
||||||
Txoutindex,
|
Outputindex,
|
||||||
Weekindex,
|
Weekindex,
|
||||||
Monthindex,
|
Monthindex,
|
||||||
Quarterindex,
|
Quarterindex,
|
||||||
@@ -25,7 +25,7 @@ pub enum Index {
|
|||||||
Difficultyepoch,
|
Difficultyepoch,
|
||||||
Halvingepoch,
|
Halvingepoch,
|
||||||
Emptyindex,
|
Emptyindex,
|
||||||
Multisigindex,
|
P2MSindex,
|
||||||
Opreturnindex,
|
Opreturnindex,
|
||||||
Pushonlyindex,
|
Pushonlyindex,
|
||||||
Unknownindex,
|
Unknownindex,
|
||||||
@@ -52,10 +52,10 @@ impl Index {
|
|||||||
Self::P2WPKHindex,
|
Self::P2WPKHindex,
|
||||||
Self::P2WSHindex,
|
Self::P2WSHindex,
|
||||||
Self::Txindex,
|
Self::Txindex,
|
||||||
Self::Txinindex,
|
Self::Inputindex,
|
||||||
Self::Txoutindex,
|
Self::Outputindex,
|
||||||
Self::Emptyindex,
|
Self::Emptyindex,
|
||||||
Self::Multisigindex,
|
Self::P2MSindex,
|
||||||
Self::Opreturnindex,
|
Self::Opreturnindex,
|
||||||
Self::Pushonlyindex,
|
Self::Pushonlyindex,
|
||||||
Self::Unknownindex,
|
Self::Unknownindex,
|
||||||
@@ -75,8 +75,8 @@ impl Index {
|
|||||||
Self::Decadeindex => &["decade", "decadeindex"],
|
Self::Decadeindex => &["decade", "decadeindex"],
|
||||||
Self::Halvingepoch => &["h", "halving", "halvingepoch"],
|
Self::Halvingepoch => &["h", "halving", "halvingepoch"],
|
||||||
Self::Txindex => &["tx", "txindex"],
|
Self::Txindex => &["tx", "txindex"],
|
||||||
Self::Txinindex => &["txin", "txinindex"],
|
Self::Inputindex => &["txin", "inputindex"],
|
||||||
Self::Txoutindex => &["txout", "txoutindex"],
|
Self::Outputindex => &["txout", "outputindex"],
|
||||||
Self::Addressindex => &["a", "address", "addressindex"],
|
Self::Addressindex => &["a", "address", "addressindex"],
|
||||||
Self::P2PK33index => &["p2pk33", "p2pk33index"],
|
Self::P2PK33index => &["p2pk33", "p2pk33index"],
|
||||||
Self::P2PK65index => &["p2pk65", "p2pk65index"],
|
Self::P2PK65index => &["p2pk65", "p2pk65index"],
|
||||||
@@ -85,11 +85,11 @@ impl Index {
|
|||||||
Self::P2TRindex => &["p2tr", "p2trindex"],
|
Self::P2TRindex => &["p2tr", "p2trindex"],
|
||||||
Self::P2WPKHindex => &["p2wpkh", "p2wpkhindex"],
|
Self::P2WPKHindex => &["p2wpkh", "p2wpkhindex"],
|
||||||
Self::P2WSHindex => &["p2wsh", "p2wshindex"],
|
Self::P2WSHindex => &["p2wsh", "p2wshindex"],
|
||||||
Self::Emptyindex => &["empty", "emptyindex"],
|
Self::Emptyindex => &["empty", "emptyoutputindex"],
|
||||||
Self::Multisigindex => &["multisig", "multisigindex"],
|
Self::P2MSindex => &["multisig", "p2msindex"],
|
||||||
Self::Opreturnindex => &["opreturn", "opreturnindex"],
|
Self::Opreturnindex => &["opreturn", "opreturnindex"],
|
||||||
Self::Pushonlyindex => &["pushonly", "pushonlyindex"],
|
Self::Pushonlyindex => &["pushonly", "pushonlyindex"],
|
||||||
Self::Unknownindex => &["unknown", "unknownindex"],
|
Self::Unknownindex => &["unknown", "unknownoutputindex"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ impl TryFrom<&str> for Index {
|
|||||||
v if (Self::Dateindex).possible_values().contains(&v) => Self::Dateindex,
|
v if (Self::Dateindex).possible_values().contains(&v) => Self::Dateindex,
|
||||||
v if (Self::Height).possible_values().contains(&v) => Self::Height,
|
v if (Self::Height).possible_values().contains(&v) => Self::Height,
|
||||||
v if (Self::Txindex).possible_values().contains(&v) => Self::Txindex,
|
v if (Self::Txindex).possible_values().contains(&v) => Self::Txindex,
|
||||||
v if (Self::Txinindex).possible_values().contains(&v) => Self::Txinindex,
|
v if (Self::Inputindex).possible_values().contains(&v) => Self::Inputindex,
|
||||||
v if (Self::Txoutindex).possible_values().contains(&v) => Self::Txoutindex,
|
v if (Self::Outputindex).possible_values().contains(&v) => Self::Outputindex,
|
||||||
v if (Self::Addressindex).possible_values().contains(&v) => Self::Addressindex,
|
v if (Self::Addressindex).possible_values().contains(&v) => Self::Addressindex,
|
||||||
v if (Self::P2PK33index).possible_values().contains(&v) => Self::P2PK33index,
|
v if (Self::P2PK33index).possible_values().contains(&v) => Self::P2PK33index,
|
||||||
v if (Self::P2PK65index).possible_values().contains(&v) => Self::P2PK65index,
|
v if (Self::P2PK65index).possible_values().contains(&v) => Self::P2PK65index,
|
||||||
@@ -139,7 +139,7 @@ impl TryFrom<&str> for Index {
|
|||||||
v if (Self::Quarterindex).possible_values().contains(&v) => Self::Quarterindex,
|
v if (Self::Quarterindex).possible_values().contains(&v) => Self::Quarterindex,
|
||||||
v if (Self::Quarterindex).possible_values().contains(&v) => Self::Quarterindex,
|
v if (Self::Quarterindex).possible_values().contains(&v) => Self::Quarterindex,
|
||||||
v if (Self::Emptyindex).possible_values().contains(&v) => Self::Emptyindex,
|
v if (Self::Emptyindex).possible_values().contains(&v) => Self::Emptyindex,
|
||||||
v if (Self::Multisigindex).possible_values().contains(&v) => Self::Multisigindex,
|
v if (Self::P2MSindex).possible_values().contains(&v) => Self::P2MSindex,
|
||||||
v if (Self::Opreturnindex).possible_values().contains(&v) => Self::Opreturnindex,
|
v if (Self::Opreturnindex).possible_values().contains(&v) => Self::Opreturnindex,
|
||||||
v if (Self::Pushonlyindex).possible_values().contains(&v) => Self::Pushonlyindex,
|
v if (Self::Pushonlyindex).possible_values().contains(&v) => Self::Pushonlyindex,
|
||||||
v if (Self::Unknownindex).possible_values().contains(&v) => Self::Unknownindex,
|
v if (Self::Unknownindex).possible_values().contains(&v) => Self::Unknownindex,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* @import {Signal, Signals} from "../packages/solid-signals/types";
|
* @import {Signal, Signals} from "../packages/solid-signals/types";
|
||||||
* @import { getOwner as GetOwner, onCleanup as OnCleanup, Owner } from "../packages/solid-signals/v0.2.4-treeshaked/types/core/owner"
|
* @import { getOwner as GetOwner, onCleanup as OnCleanup, Owner } from "../packages/solid-signals/v0.2.4-treeshaked/types/core/owner"
|
||||||
* @import { createEffect as CreateEffect, Accessor, Setter, createMemo as CreateMemo } from "../packages/solid-signals/v0.2.4-treeshaked/types/signals";
|
* @import { createEffect as CreateEffect, Accessor, Setter, createMemo as CreateMemo } from "../packages/solid-signals/v0.2.4-treeshaked/types/signals";
|
||||||
* @import {Addressindex, Dateindex, Decadeindex, Difficultyepoch, Index, Halvingepoch, Height, Monthindex, P2PK33index, P2PK65index, P2PKHindex, P2SHindex, P2TRindex, P2WPKHindex, P2WSHindex, Txindex, Txinindex, Txoutindex, VecId, Weekindex, Yearindex, VecIdToIndexes, Quarterindex, Emptyindex, Multisigindex, Opreturnindex, Pushonlyindex, Unknownindex} from "./vecid-to-indexes"
|
* @import {Addressindex, Dateindex, Decadeindex, Difficultyepoch, Index, Halvingepoch, Height, Monthindex, P2PK33index, P2PK65index, P2PKHindex, P2SHindex, P2TRindex, P2WPKHindex, P2WSHindex, Txindex, Inputindex, Outputindex, VecId, Weekindex, Yearindex, VecIdToIndexes, Quarterindex, Emptyindex, P2MSindex, Opreturnindex, Pushonlyindex, Unknownindex} from "./vecid-to-indexes"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1188,10 +1188,10 @@ function createUtils() {
|
|||||||
return "P2WSHindex";
|
return "P2WSHindex";
|
||||||
case /** @satisfies {Txindex} */ (17):
|
case /** @satisfies {Txindex} */ (17):
|
||||||
return "Txindex";
|
return "Txindex";
|
||||||
case /** @satisfies {Txinindex} */ (18):
|
case /** @satisfies {Inputindex} */ (18):
|
||||||
return "Txinindex";
|
return "Inputindex";
|
||||||
case /** @satisfies {Txoutindex} */ (19):
|
case /** @satisfies {Outputindex} */ (19):
|
||||||
return "Txoutindex";
|
return "Outputindex";
|
||||||
case /** @satisfies {Weekindex} */ (2):
|
case /** @satisfies {Weekindex} */ (2):
|
||||||
return "Weekindex";
|
return "Weekindex";
|
||||||
case /** @satisfies {Monthindex} */ (4):
|
case /** @satisfies {Monthindex} */ (4):
|
||||||
|
|||||||
@@ -414,13 +414,13 @@ function createSerializedIndexes() {
|
|||||||
/** @satisfies {VecId} */ ("p2wpkhindex"),
|
/** @satisfies {VecId} */ ("p2wpkhindex"),
|
||||||
/** @satisfies {VecId} */ ("p2wshindex"),
|
/** @satisfies {VecId} */ ("p2wshindex"),
|
||||||
/** @satisfies {VecId} */ ("txindex"),
|
/** @satisfies {VecId} */ ("txindex"),
|
||||||
/** @satisfies {VecId} */ ("txinindex"),
|
/** @satisfies {VecId} */ ("inputindex"),
|
||||||
/** @satisfies {VecId} */ ("txoutindex"),
|
/** @satisfies {VecId} */ ("outputindex"),
|
||||||
/** @satisfies {VecId} */ ("emptyindex"),
|
/** @satisfies {VecId} */ ("emptyoutputindex"),
|
||||||
/** @satisfies {VecId} */ ("multisigindex"),
|
/** @satisfies {VecId} */ ("p2msindex"),
|
||||||
/** @satisfies {VecId} */ ("opreturnindex"),
|
/** @satisfies {VecId} */ ("opreturnindex"),
|
||||||
/** @satisfies {VecId} */ ("pushonlyindex"),
|
/** @satisfies {VecId} */ ("pushonlyindex"),
|
||||||
/** @satisfies {VecId} */ ("unknownindex"),
|
/** @satisfies {VecId} */ ("unknownoutputindex"),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
/** @typedef {ReturnType<typeof createSerializedIndexes>} SerializedIndexes */
|
/** @typedef {ReturnType<typeof createSerializedIndexes>} SerializedIndexes */
|
||||||
@@ -468,19 +468,19 @@ function serializedIndexToIndex(serializedIndex) {
|
|||||||
return /** @satisfies {P2WSHindex} */ (16);
|
return /** @satisfies {P2WSHindex} */ (16);
|
||||||
case "txindex":
|
case "txindex":
|
||||||
return /** @satisfies {Txindex} */ (17);
|
return /** @satisfies {Txindex} */ (17);
|
||||||
case "txinindex":
|
case "inputindex":
|
||||||
return /** @satisfies {Txinindex} */ (18);
|
return /** @satisfies {Inputindex} */ (18);
|
||||||
case "txoutindex":
|
case "outputindex":
|
||||||
return /** @satisfies {Txoutindex} */ (19);
|
return /** @satisfies {Outputindex} */ (19);
|
||||||
case "emptyindex":
|
case "emptyoutputindex":
|
||||||
return /** @satisfies {Emptyindex} */ (20);
|
return /** @satisfies {Emptyindex} */ (20);
|
||||||
case "multisigindex":
|
case "p2msindex":
|
||||||
return /** @satisfies {Multisigindex} */ (21);
|
return /** @satisfies {P2MSindex} */ (21);
|
||||||
case "opreturnindex":
|
case "opreturnindex":
|
||||||
return /** @satisfies {Opreturnindex} */ (22);
|
return /** @satisfies {Opreturnindex} */ (22);
|
||||||
case "pushonlyindex":
|
case "pushonlyindex":
|
||||||
return /** @satisfies {Pushonlyindex} */ (23);
|
return /** @satisfies {Pushonlyindex} */ (23);
|
||||||
case "unknownindex":
|
case "unknownoutputindex":
|
||||||
return /** @satisfies {Unknownindex} */ (24);
|
return /** @satisfies {Unknownindex} */ (24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user