global: add sent volume

This commit is contained in:
nym21
2025-09-12 12:00:03 +02:00
parent 504d6eaa9f
commit a5951c58f3
4 changed files with 49 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ use brk_structs::{
YearIndex,
};
use vecdb::{
AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Database, EagerVec, Exit,
AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, AnyVec, Database, EagerVec, Exit,
LazyVecFrom1, LazyVecFrom2, LazyVecFrom3, PAGE_SIZE, StoredIndex, VecIterator,
};
@@ -74,6 +74,7 @@ pub struct Vecs {
/// Value == 0 when Coinbase
pub txindex_to_input_value:
LazyVecFrom3<TxIndex, Sats, TxIndex, InputIndex, TxIndex, StoredU64, InputIndex, Sats>,
pub indexes_to_sent: ComputedValueVecsFromHeight,
// pub indexes_to_input_value: ComputedVecsFromTxindex<Sats>,
pub indexes_to_opreturn_count: ComputedVecsFromHeight<StoredU64>,
pub txindex_to_output_value:
@@ -605,6 +606,15 @@ impl Vecs {
indexes,
VecBuilderOptions::default().add_sum().add_cumulative(),
)?,
indexes_to_sent: ComputedValueVecsFromHeight::forced_import(
&db,
"sent",
Source::Compute,
version + VERSION + Version::ZERO,
VecBuilderOptions::default().add_sum(),
compute_dollars,
indexes,
)?,
indexes_to_fee: ComputedValueVecsFromTxindex::forced_import(
&db,
"fee",
@@ -1398,6 +1408,20 @@ impl Vecs {
exit,
)?;
self.indexes_to_sent
.compute_all(indexes, price, starting_indexes, exit, |v| {
dbg!(v.len());
v.compute_sum_from_indexes(
starting_indexes.height,
&indexer.vecs.height_to_first_txindex,
&indexes.height_to_txindex_count,
&self.txindex_to_input_value,
exit,
)?;
dbg!(v.len());
Ok(())
})?;
self.indexes_to_fee.compute_rest(
indexer,
indexes,
@@ -2147,6 +2171,7 @@ impl Vecs {
.iter_any_collectable(),
),
);
iter = Box::new(iter.chain(self.indexes_to_sent.iter_any_collectable()));
iter = Box::new(iter.chain(self.indexes_to_hash_price_ths.iter_any_collectable()));
iter = Box::new(iter.chain(self.indexes_to_hash_price_phs.iter_any_collectable()));
iter = Box::new(iter.chain(self.indexes_to_hash_value_ths.iter_any_collectable()));

View File

@@ -143,9 +143,10 @@ function createChartElement({
}),
);
// ichart.priceScale("right").applyOptions({
// minimumWidth: 80,
// });
// Takes a bit more space sometimes but it's better UX than having the scale being resized on option change
ichart.priceScale("right").applyOptions({
minimumWidth: 80,
});
ichart.panes().at(0)?.setStretchFactor(1);

View File

@@ -745,6 +745,7 @@ function createUtils() {
(id.includes("in_sats") ||
(id.endsWith("supply") &&
!(id.endsWith("circulating_supply") || id.endsWith("_own_supply"))) ||
id === "sent" ||
id.endsWith("supply_half") ||
id.endsWith("supply_breakeven") ||
id.endsWith("supply_in_profit") ||

View File

@@ -3519,6 +3519,24 @@ function createPartialOptions({ env, colors, vecIdToIndexes, pools }) {
},
),
},
{
name: "Volume",
title: "Transaction Volume",
bottom: [
createBaseSeries({
key: "sent",
name: "Sent",
}),
createBaseSeries({
key: "sent_in_btc",
name: "Sent",
}),
createBaseSeries({
key: "sent_in_usd",
name: "Sent",
}),
],
},
{
name: "Size",
title: "Transaction Size",