mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
snapshot
This commit is contained in:
@@ -10,8 +10,8 @@ use brk_types::{
|
||||
TxVersion, Version, WeekIndex, Weight, YearIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
AnyVec, Database, EagerVec, Exit, GenericStoredVec, IterableCloneableVec, IterableVec,
|
||||
LazyVecFrom1, LazyVecFrom2, PAGE_SIZE, TypedVecIterator, VecIndex, unlikely,
|
||||
Database, EagerVec, Exit, GenericStoredVec, IterableCloneableVec, IterableVec, LazyVecFrom1,
|
||||
LazyVecFrom2, PAGE_SIZE, TypedVecIterator, VecIndex, unlikely,
|
||||
};
|
||||
|
||||
use crate::grouped::{
|
||||
@@ -1311,20 +1311,6 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Debug: verify the computed txinindex_to_value
|
||||
dbg!("txinindex_to_value first 20:");
|
||||
for i in 0..20.min(self.txinindex_to_value.len()) {
|
||||
let val = self.txinindex_to_value.read_at_unwrap_once(i);
|
||||
dbg!((TxInIndex::from(i), val));
|
||||
}
|
||||
|
||||
// Debug: verify the computed txindex_to_input_count
|
||||
dbg!("txindex_to_input_count first 20:");
|
||||
for i in 0..20.min(indexes.txindex_to_input_count.len()) {
|
||||
let val = indexes.txindex_to_input_count.read_at_unwrap_once(i);
|
||||
dbg!((TxInIndex::from(i), val));
|
||||
}
|
||||
|
||||
self.txindex_to_input_value.compute_sum_from_indexes(
|
||||
starting_indexes.txindex,
|
||||
&indexer.vecs.txindex_to_first_txinindex,
|
||||
@@ -1333,12 +1319,6 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Debug: verify the computed input values
|
||||
for i in 0..10.min(self.txindex_to_input_value.len()) {
|
||||
let val = self.txindex_to_input_value.read_at_unwrap_once(i);
|
||||
dbg!((TxIndex::from(i), "input_value", val));
|
||||
}
|
||||
|
||||
self.txindex_to_output_value.compute_sum_from_indexes(
|
||||
starting_indexes.txindex,
|
||||
&indexer.vecs.txindex_to_first_txoutindex,
|
||||
@@ -1347,26 +1327,17 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Debug: verify the computed output values
|
||||
for i in 0..10.min(self.txindex_to_output_value.len()) {
|
||||
let val = self.txindex_to_output_value.read_at_unwrap_once(i);
|
||||
dbg!((TxIndex::from(i), "output_value", val));
|
||||
}
|
||||
|
||||
self.txindex_to_fee.compute_transform2(
|
||||
starting_indexes.txindex,
|
||||
&self.txindex_to_input_value,
|
||||
&self.txindex_to_output_value,
|
||||
|(i, input, output, ..)| {
|
||||
(
|
||||
i,
|
||||
if unlikely(input.is_max()) {
|
||||
Sats::ZERO
|
||||
} else {
|
||||
dbg!((i, input, output));
|
||||
input.checked_sub(output).unwrap()
|
||||
},
|
||||
)
|
||||
let fee = if unlikely(input.is_max()) {
|
||||
Sats::ZERO
|
||||
} else {
|
||||
input - output
|
||||
};
|
||||
(i, fee)
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
@@ -1381,11 +1352,12 @@ impl Vecs {
|
||||
|
||||
self.indexes_to_sent
|
||||
.compute_all(indexes, price, starting_indexes, exit, |v| {
|
||||
v.compute_sum_from_indexes(
|
||||
v.compute_filtered_sum_from_indexes(
|
||||
starting_indexes.height,
|
||||
&indexer.vecs.height_to_first_txindex,
|
||||
&indexes.height_to_txindex_count,
|
||||
&self.txindex_to_input_value,
|
||||
|sats| !sats.is_max(),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
@@ -1472,6 +1444,8 @@ impl Vecs {
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
drop(height_to_coinbase_iter);
|
||||
|
||||
if let Some(mut height_to_coinbase_iter) = self
|
||||
.indexes_to_coinbase
|
||||
.dollars
|
||||
@@ -1493,18 +1467,20 @@ impl Vecs {
|
||||
)?;
|
||||
}
|
||||
|
||||
drop(height_to_coinbase_iter);
|
||||
|
||||
self.indexes_to_subsidy
|
||||
.compute_all(indexes, price, starting_indexes, exit, |vec| {
|
||||
let mut indexes_to_fee_sum_iter =
|
||||
self.indexes_to_fee.sats.height.unwrap_sum().iter();
|
||||
vec.compute_transform(
|
||||
vec.compute_transform2(
|
||||
starting_indexes.height,
|
||||
self.indexes_to_coinbase.sats.height.as_ref().unwrap(),
|
||||
|(height, coinbase, ..)| {
|
||||
let fees = indexes_to_fee_sum_iter.get_unwrap(height);
|
||||
(height, coinbase.checked_sub(fees).unwrap())
|
||||
self.indexes_to_fee.sats.height.unwrap_sum(),
|
||||
|(height, coinbase, fees, ..)| {
|
||||
(
|
||||
height,
|
||||
coinbase.checked_sub(fees).unwrap_or_else(|| {
|
||||
dbg!(height, coinbase, fees);
|
||||
panic!()
|
||||
}),
|
||||
)
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -235,21 +235,17 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn compute<I2>(
|
||||
pub fn compute<A>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
source: &impl IterableVec<I2, T>,
|
||||
first_indexes: &impl IterableVec<I, I2>,
|
||||
source: &impl IterableVec<A, T>,
|
||||
first_indexes: &impl IterableVec<I, A>,
|
||||
count_indexes: &impl IterableVec<I, StoredU64>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
I2: VecIndex + VecValue + CheckedSub<I2>,
|
||||
A: VecIndex + VecValue + CheckedSub<A>,
|
||||
{
|
||||
dbg!(source.len());
|
||||
dbg!(first_indexes.len());
|
||||
dbg!(count_indexes.len());
|
||||
|
||||
self.validate_computed_version_or_reset(
|
||||
source.version() + first_indexes.version() + count_indexes.version(),
|
||||
)?;
|
||||
@@ -399,16 +395,16 @@ where
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
pub fn from_aligned<I2>(
|
||||
pub fn from_aligned<A>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
source: &EagerVecsBuilder<I2, T>,
|
||||
first_indexes: &impl IterableVec<I, I2>,
|
||||
source: &EagerVecsBuilder<A, T>,
|
||||
first_indexes: &impl IterableVec<I, A>,
|
||||
count_indexes: &impl IterableVec<I, StoredU64>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
I2: VecIndex + VecValue + CheckedSub<I2>,
|
||||
A: VecIndex + VecValue + CheckedSub<A>,
|
||||
{
|
||||
if self.pct90.is_some()
|
||||
|| self.pct75.is_some()
|
||||
|
||||
@@ -438,9 +438,9 @@ impl Vecs {
|
||||
starting_indexes: brk_indexer::Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<Indexes> {
|
||||
let idxs = self.compute_(indexer, starting_indexes, exit)?;
|
||||
let indexes = self.compute_(indexer, starting_indexes, exit)?;
|
||||
self.db.compact()?;
|
||||
Ok(idxs)
|
||||
Ok(indexes)
|
||||
}
|
||||
|
||||
fn compute_(
|
||||
@@ -460,13 +460,12 @@ impl Vecs {
|
||||
&indexer.vecs.txinindex_to_outpoint,
|
||||
|(txinindex, outpoint, ..)| {
|
||||
if unlikely(outpoint.is_coinbase()) {
|
||||
(txinindex, TxOutIndex::COINBASE)
|
||||
} else {
|
||||
let txoutindex = txindex_to_first_txoutindex
|
||||
.read_unwrap(outpoint.txindex(), &txindex_to_first_txoutindex_reader)
|
||||
+ outpoint.vout();
|
||||
(txinindex, txoutindex)
|
||||
return (txinindex, TxOutIndex::COINBASE);
|
||||
}
|
||||
let txoutindex = txindex_to_first_txoutindex
|
||||
.read_unwrap(outpoint.txindex(), &txindex_to_first_txoutindex_reader)
|
||||
+ outpoint.vout();
|
||||
(txinindex, txoutindex)
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -157,8 +157,6 @@ impl Computer {
|
||||
info!("Computing indexes...");
|
||||
let mut starting_indexes = self.indexes.compute(indexer, starting_indexes, exit)?;
|
||||
|
||||
return Ok(());
|
||||
|
||||
if let Some(fetched) = self.fetched.as_mut() {
|
||||
info!("Computing fetched...");
|
||||
fetched.compute(indexer, &self.indexes, &starting_indexes, exit)?;
|
||||
@@ -201,6 +199,8 @@ impl Computer {
|
||||
self.market.compute(price, &starting_indexes, exit)?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
||||
// constants.join().unwrap()?;
|
||||
// chain.join().unwrap()?;
|
||||
// Ok(())
|
||||
|
||||
Reference in New Issue
Block a user