mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -3382,18 +3382,18 @@ impl SeriesTree_Transactions_Versions {
|
||||
/// Series tree node.
|
||||
pub struct SeriesTree_Transactions_Volume {
|
||||
pub transfer_volume: BaseCumulativeSumPattern4,
|
||||
pub tx_per_sec: SeriesPattern1<StoredF32>,
|
||||
pub outputs_per_sec: SeriesPattern1<StoredF32>,
|
||||
pub inputs_per_sec: SeriesPattern1<StoredF32>,
|
||||
pub tx_per_sec: _1m1w1y24hPattern<StoredF32>,
|
||||
pub outputs_per_sec: _1m1w1y24hPattern<StoredF32>,
|
||||
pub inputs_per_sec: _1m1w1y24hPattern<StoredF32>,
|
||||
}
|
||||
|
||||
impl SeriesTree_Transactions_Volume {
|
||||
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
|
||||
Self {
|
||||
transfer_volume: BaseCumulativeSumPattern4::new(client.clone(), "transfer_volume_bis".to_string()),
|
||||
tx_per_sec: SeriesPattern1::new(client.clone(), "tx_per_sec".to_string()),
|
||||
outputs_per_sec: SeriesPattern1::new(client.clone(), "outputs_per_sec".to_string()),
|
||||
inputs_per_sec: SeriesPattern1::new(client.clone(), "inputs_per_sec".to_string()),
|
||||
tx_per_sec: _1m1w1y24hPattern::new(client.clone(), "tx_per_sec".to_string()),
|
||||
outputs_per_sec: _1m1w1y24hPattern::new(client.clone(), "outputs_per_sec".to_string()),
|
||||
inputs_per_sec: _1m1w1y24hPattern::new(client.clone(), "inputs_per_sec".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_types::{Indexes, Timestamp};
|
||||
use brk_types::{Indexes, StoredF32};
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::transactions::{count, fees};
|
||||
use crate::{blocks, indexes, inputs, internal::PerSec, outputs, prices};
|
||||
use crate::{blocks, indexes, inputs, outputs, prices};
|
||||
|
||||
const WINDOW_SECS: [f64; 4] = [
|
||||
86400.0,
|
||||
7.0 * 86400.0,
|
||||
30.0 * 86400.0,
|
||||
365.0 * 86400.0,
|
||||
];
|
||||
|
||||
impl Vecs {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -38,30 +45,37 @@ impl Vecs {
|
||||
},
|
||||
)?;
|
||||
|
||||
self.tx_per_sec
|
||||
.height
|
||||
.compute_binary::<_, Timestamp, PerSec>(
|
||||
starting_indexes.height,
|
||||
&count_vecs.total.base.height,
|
||||
&blocks.interval.base,
|
||||
exit,
|
||||
)?;
|
||||
self.inputs_per_sec
|
||||
.height
|
||||
.compute_binary::<_, Timestamp, PerSec>(
|
||||
starting_indexes.height,
|
||||
&inputs_count.sum.height,
|
||||
&blocks.interval.base,
|
||||
exit,
|
||||
)?;
|
||||
self.outputs_per_sec
|
||||
.height
|
||||
.compute_binary::<_, Timestamp, PerSec>(
|
||||
starting_indexes.height,
|
||||
&outputs_count.total.sum.height,
|
||||
&blocks.interval.base,
|
||||
exit,
|
||||
)?;
|
||||
let h = starting_indexes.height;
|
||||
let tx_sums = count_vecs.total.rolling.sum.0.as_array();
|
||||
let input_sums = inputs_count.rolling.sum.0.as_array();
|
||||
let output_sums = outputs_count.total.rolling.sum.0.as_array();
|
||||
|
||||
for (i, &secs) in WINDOW_SECS.iter().enumerate() {
|
||||
self.tx_per_sec.as_mut_array()[i]
|
||||
.height
|
||||
.compute_transform(
|
||||
h,
|
||||
&tx_sums[i].height,
|
||||
|(h, sum, ..)| (h, StoredF32::from(*sum as f64 / secs)),
|
||||
exit,
|
||||
)?;
|
||||
self.inputs_per_sec.as_mut_array()[i]
|
||||
.height
|
||||
.compute_transform(
|
||||
h,
|
||||
&input_sums[i].height,
|
||||
|(h, sum, ..)| (h, StoredF32::from(*sum as f64 / secs)),
|
||||
exit,
|
||||
)?;
|
||||
self.outputs_per_sec.as_mut_array()[i]
|
||||
.height
|
||||
.compute_transform(
|
||||
h,
|
||||
&output_sums[i].height,
|
||||
|(h, sum, ..)| (h, StoredF32::from(*sum as f64 / secs)),
|
||||
exit,
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{AmountPerBlockCumulativeWithSums, CachedWindowStarts, PerBlock},
|
||||
internal::{AmountPerBlockCumulativeWithSums, CachedWindowStarts, PerBlock, Windows},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -15,7 +15,7 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
) -> Result<Self> {
|
||||
let v2 = Version::TWO;
|
||||
let v = version + Version::TWO;
|
||||
Ok(Self {
|
||||
transfer_volume: AmountPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
@@ -24,19 +24,15 @@ impl Vecs {
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
tx_per_sec: PerBlock::forced_import(db, "tx_per_sec", version + v2, indexes)?,
|
||||
outputs_per_sec: PerBlock::forced_import(
|
||||
db,
|
||||
"outputs_per_sec",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?,
|
||||
inputs_per_sec: PerBlock::forced_import(
|
||||
db,
|
||||
"inputs_per_sec",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?,
|
||||
tx_per_sec: Windows::try_from_fn(|suffix| {
|
||||
PerBlock::forced_import(db, &format!("tx_per_sec_{suffix}"), v, indexes)
|
||||
})?,
|
||||
outputs_per_sec: Windows::try_from_fn(|suffix| {
|
||||
PerBlock::forced_import(db, &format!("outputs_per_sec_{suffix}"), v, indexes)
|
||||
})?,
|
||||
inputs_per_sec: Windows::try_from_fn(|suffix| {
|
||||
PerBlock::forced_import(db, &format!("inputs_per_sec_{suffix}"), v, indexes)
|
||||
})?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use brk_traversable::Traversable;
|
||||
use brk_types::StoredF32;
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{AmountPerBlockCumulativeWithSums, PerBlock};
|
||||
use crate::internal::{AmountPerBlockCumulativeWithSums, PerBlock, Windows};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub transfer_volume: AmountPerBlockCumulativeWithSums<M>,
|
||||
pub tx_per_sec: PerBlock<StoredF32, M>,
|
||||
pub outputs_per_sec: PerBlock<StoredF32, M>,
|
||||
pub inputs_per_sec: PerBlock<StoredF32, M>,
|
||||
pub tx_per_sec: Windows<PerBlock<StoredF32, M>>,
|
||||
pub outputs_per_sec: Windows<PerBlock<StoredF32, M>>,
|
||||
pub inputs_per_sec: Windows<PerBlock<StoredF32, M>>,
|
||||
}
|
||||
|
||||
@@ -4100,9 +4100,9 @@ function createUnspentPattern(client, acc) {
|
||||
/**
|
||||
* @typedef {Object} SeriesTree_Transactions_Volume
|
||||
* @property {BaseCumulativeSumPattern4} transferVolume
|
||||
* @property {SeriesPattern1<StoredF32>} txPerSec
|
||||
* @property {SeriesPattern1<StoredF32>} outputsPerSec
|
||||
* @property {SeriesPattern1<StoredF32>} inputsPerSec
|
||||
* @property {_1m1w1y24hPattern<StoredF32>} txPerSec
|
||||
* @property {_1m1w1y24hPattern<StoredF32>} outputsPerSec
|
||||
* @property {_1m1w1y24hPattern<StoredF32>} inputsPerSec
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -7612,9 +7612,9 @@ class BrkClient extends BrkClientBase {
|
||||
},
|
||||
volume: {
|
||||
transferVolume: createBaseCumulativeSumPattern4(this, 'transfer_volume_bis'),
|
||||
txPerSec: createSeriesPattern1(this, 'tx_per_sec'),
|
||||
outputsPerSec: createSeriesPattern1(this, 'outputs_per_sec'),
|
||||
inputsPerSec: createSeriesPattern1(this, 'inputs_per_sec'),
|
||||
txPerSec: create_1m1w1y24hPattern(this, 'tx_per_sec'),
|
||||
outputsPerSec: create_1m1w1y24hPattern(this, 'outputs_per_sec'),
|
||||
inputsPerSec: create_1m1w1y24hPattern(this, 'inputs_per_sec'),
|
||||
},
|
||||
},
|
||||
inputs: {
|
||||
|
||||
@@ -3323,9 +3323,9 @@ class SeriesTree_Transactions_Volume:
|
||||
|
||||
def __init__(self, client: BrkClientBase, base_path: str = ''):
|
||||
self.transfer_volume: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'transfer_volume_bis')
|
||||
self.tx_per_sec: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'tx_per_sec')
|
||||
self.outputs_per_sec: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'outputs_per_sec')
|
||||
self.inputs_per_sec: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'inputs_per_sec')
|
||||
self.tx_per_sec: _1m1w1y24hPattern[StoredF32] = _1m1w1y24hPattern(client, 'tx_per_sec')
|
||||
self.outputs_per_sec: _1m1w1y24hPattern[StoredF32] = _1m1w1y24hPattern(client, 'outputs_per_sec')
|
||||
self.inputs_per_sec: _1m1w1y24hPattern[StoredF32] = _1m1w1y24hPattern(client, 'inputs_per_sec')
|
||||
|
||||
class SeriesTree_Transactions:
|
||||
"""Series tree node."""
|
||||
|
||||
@@ -779,27 +779,30 @@ export function createNetworkSection() {
|
||||
},
|
||||
{
|
||||
name: "Activity Rate",
|
||||
title: "Activity Rate",
|
||||
bottom: [
|
||||
dots({
|
||||
series: transactions.volume.txPerSec,
|
||||
name: "TX/sec",
|
||||
color: colors.entity.tx,
|
||||
unit: Unit.perSec,
|
||||
}),
|
||||
dots({
|
||||
series: transactions.volume.inputsPerSec,
|
||||
name: "Inputs/sec",
|
||||
color: colors.entity.input,
|
||||
unit: Unit.perSec,
|
||||
}),
|
||||
dots({
|
||||
series: transactions.volume.outputsPerSec,
|
||||
name: "Outputs/sec",
|
||||
color: colors.entity.output,
|
||||
unit: Unit.perSec,
|
||||
}),
|
||||
],
|
||||
tree: ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `Activity Rate (${w.name})`,
|
||||
bottom: [
|
||||
line({
|
||||
series: transactions.volume.txPerSec[w.key],
|
||||
name: "TX/sec",
|
||||
color: colors.entity.tx,
|
||||
unit: Unit.perSec,
|
||||
}),
|
||||
line({
|
||||
series: transactions.volume.inputsPerSec[w.key],
|
||||
name: "Inputs/sec",
|
||||
color: colors.entity.input,
|
||||
unit: Unit.perSec,
|
||||
}),
|
||||
line({
|
||||
series: transactions.volume.outputsPerSec[w.key],
|
||||
name: "Outputs/sec",
|
||||
color: colors.entity.output,
|
||||
unit: Unit.perSec,
|
||||
}),
|
||||
],
|
||||
})),
|
||||
},
|
||||
|
||||
// Addresses
|
||||
|
||||
Reference in New Issue
Block a user