global: snapshot

This commit is contained in:
nym21
2025-10-26 22:30:41 +01:00
parent 7d01e9e91e
commit 82e59d409e
34 changed files with 2192 additions and 1090 deletions

View File

@@ -1,4 +1,5 @@
use brk_traversable::Traversable;
use rayon::prelude::*;
use crate::Filtered;
@@ -23,6 +24,13 @@ impl<T> AddressGroups<T> {
self.amount_range.iter_mut()
}
pub fn par_iter_separate_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
{
self.amount_range.par_iter_mut()
}
pub fn iter_overlapping_mut(&mut self) -> impl Iterator<Item = &mut T> {
self.lt_amount.iter_mut().chain(self.ge_amount.iter_mut())
}

View File

@@ -62,10 +62,12 @@ impl<T> ByAddressType<T> {
})
}
#[inline]
pub fn get_unwrap(&self, address_type: OutputType) -> &T {
self.get(address_type).unwrap()
}
#[inline]
pub fn get(&self, address_type: OutputType) -> Option<&T> {
match address_type {
OutputType::P2PK65 => Some(&self.p2pk65),
@@ -80,10 +82,12 @@ impl<T> ByAddressType<T> {
}
}
#[inline]
pub fn get_mut_unwrap(&mut self, address_type: OutputType) -> &mut T {
self.get_mut(address_type).unwrap()
}
#[inline]
pub fn get_mut(&mut self, address_type: OutputType) -> Option<&mut T> {
match address_type {
OutputType::P2PK65 => Some(&mut self.p2pk65),
@@ -98,6 +102,7 @@ impl<T> ByAddressType<T> {
}
}
#[inline]
pub fn iter(&self) -> impl Iterator<Item = &T> {
[
&self.p2pk65,
@@ -112,6 +117,7 @@ impl<T> ByAddressType<T> {
.into_iter()
}
#[inline]
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
[
&mut self.p2pk65,
@@ -126,6 +132,7 @@ impl<T> ByAddressType<T> {
.into_iter()
}
#[inline]
pub fn par_iter(&mut self) -> impl ParallelIterator<Item = &T>
where
T: Send + Sync,
@@ -143,6 +150,7 @@ impl<T> ByAddressType<T> {
.into_par_iter()
}
#[inline]
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
@@ -160,6 +168,7 @@ impl<T> ByAddressType<T> {
.into_par_iter()
}
#[inline]
pub fn iter_typed(&self) -> impl Iterator<Item = (OutputType, &T)> {
[
(OutputType::P2PK65, &self.p2pk65),
@@ -174,6 +183,7 @@ impl<T> ByAddressType<T> {
.into_iter()
}
#[inline]
pub fn into_iter_typed(self) -> impl Iterator<Item = (OutputType, T)> {
[
(OutputType::P2PK65, self.p2pk65),
@@ -188,6 +198,7 @@ impl<T> ByAddressType<T> {
.into_iter()
}
#[inline]
pub fn iter_typed_mut(&mut self) -> impl Iterator<Item = (OutputType, &mut T)> {
[
(OutputType::P2PK65, &mut self.p2pk65),

View File

@@ -1,4 +1,5 @@
use brk_traversable::Traversable;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use crate::Filtered;
@@ -107,6 +108,35 @@ impl<T> ByAgeRange<T> {
]
.into_iter()
}
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
{
[
&mut self.up_to_1d,
&mut self._1d_to_1w,
&mut self._1w_to_1m,
&mut self._1m_to_2m,
&mut self._2m_to_3m,
&mut self._3m_to_4m,
&mut self._4m_to_5m,
&mut self._5m_to_6m,
&mut self._6m_to_1y,
&mut self._1y_to_2y,
&mut self._2y_to_3y,
&mut self._3y_to_4y,
&mut self._4y_to_5y,
&mut self._5y_to_6y,
&mut self._6y_to_7y,
&mut self._7y_to_8y,
&mut self._8y_to_10y,
&mut self._10y_to_12y,
&mut self._12y_to_15y,
&mut self.from_15y,
]
.into_par_iter()
}
}
impl<T> ByAgeRange<Filtered<T>> {

View File

@@ -2,6 +2,7 @@ use std::ops::{Add, AddAssign};
use brk_traversable::Traversable;
use brk_types::Sats;
use rayon::prelude::*;
use super::{Filter, Filtered};
@@ -201,6 +202,30 @@ impl<T> ByAmountRange<T> {
]
.into_iter()
}
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
{
[
&mut self._0sats,
&mut self._1sat_to_10sats,
&mut self._10sats_to_100sats,
&mut self._100sats_to_1k_sats,
&mut self._1k_sats_to_10k_sats,
&mut self._10k_sats_to_100k_sats,
&mut self._100k_sats_to_1m_sats,
&mut self._1m_sats_to_10m_sats,
&mut self._10m_sats_to_1btc,
&mut self._1btc_to_10btc,
&mut self._10btc_to_100btc,
&mut self._100btc_to_1k_btc,
&mut self._1k_btc_to_10k_btc,
&mut self._10k_btc_to_100k_btc,
&mut self._100k_btc_or_more,
]
.into_par_iter()
}
}
impl<T> ByAmountRange<Filtered<T>> {

View File

@@ -1,5 +1,6 @@
use brk_traversable::Traversable;
use brk_types::{HalvingEpoch, Height};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use super::{Filter, Filtered};
@@ -36,6 +37,20 @@ impl<T> ByEpoch<T> {
.into_iter()
}
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
{
[
&mut self._0,
&mut self._1,
&mut self._2,
&mut self._3,
&mut self._4,
]
.into_par_iter()
}
pub fn mut_vec_from_height(&mut self, height: Height) -> &mut T {
let epoch = HalvingEpoch::from(height);
if epoch == HalvingEpoch::new(0) {

View File

@@ -2,6 +2,7 @@ use std::ops::{Add, AddAssign};
use brk_traversable::Traversable;
use brk_types::OutputType;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use super::{Filter, Filtered};
@@ -55,6 +56,26 @@ impl<T> BySpendableType<T> {
.into_iter()
}
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
{
[
&mut self.p2pk65,
&mut self.p2pk33,
&mut self.p2pkh,
&mut self.p2ms,
&mut self.p2sh,
&mut self.p2wpkh,
&mut self.p2wsh,
&mut self.p2tr,
&mut self.p2a,
&mut self.unknown,
&mut self.empty,
]
.into_par_iter()
}
pub fn iter_typed(&self) -> impl Iterator<Item = (OutputType, &T)> {
[
(OutputType::P2PK65, &self.p2pk65),

View File

@@ -1,4 +1,5 @@
use brk_traversable::Traversable;
use rayon::prelude::*;
use crate::{
ByAgeRange, ByAmountRange, ByEpoch, ByGreatEqualAmount, ByLowerThanAmount, ByMaxAge, ByMinAge,
@@ -42,6 +43,17 @@ impl<T> UTXOGroups<T> {
.chain(self._type.iter_mut())
}
pub fn par_iter_separate_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where
T: Send + Sync,
{
self.age_range
.par_iter_mut()
.chain(self.epoch.par_iter_mut())
.chain(self.amount_range.par_iter_mut())
.chain(self._type.par_iter_mut())
}
pub fn iter_overlapping_mut(&mut self) -> impl Iterator<Item = &mut T> {
[&mut self.all]
.into_iter()