mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
computer: simplified a bunch of things
This commit is contained in:
@@ -15,7 +15,7 @@ impl Query {
|
||||
|
||||
let iter = Day1Iter::new(computer, start, current_height.to_usize());
|
||||
|
||||
let cumulative = &computer.transactions.fees.fee.sum_cum.cumulative;
|
||||
let cumulative = &computer.transactions.fees.fee.sum_cumulative.cumulative;
|
||||
let first_height = &computer.indexes.day1.first_height;
|
||||
|
||||
Ok(iter.collect(|di, ts, h| {
|
||||
@@ -28,13 +28,13 @@ impl Query {
|
||||
return None;
|
||||
}
|
||||
|
||||
let cum_end = cumulative.collect_one_at(h_end.to_usize() - 1)?;
|
||||
let cum_start = if h_start.to_usize() > 0 {
|
||||
let cumulative_end = cumulative.collect_one_at(h_end.to_usize() - 1)?;
|
||||
let cumulative_start = if h_start.to_usize() > 0 {
|
||||
cumulative.collect_one_at(h_start.to_usize() - 1).unwrap_or(Sats::ZERO)
|
||||
} else {
|
||||
Sats::ZERO
|
||||
};
|
||||
let daily_sum = cum_end - cum_start;
|
||||
let daily_sum = cumulative_end - cumulative_start;
|
||||
let avg_fees = Sats::from(*daily_sum / block_count as u64);
|
||||
|
||||
Some(BlockFeesEntry {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{BlockRewardsEntry, TimePeriod};
|
||||
use vecdb::{ReadableVec, VecIndex};
|
||||
use vecdb::{ReadableOptionVec, VecIndex};
|
||||
|
||||
use super::day1_iter::Day1Iter;
|
||||
use crate::Query;
|
||||
@@ -20,11 +20,14 @@ impl Query {
|
||||
.rewards
|
||||
.coinbase
|
||||
.sats
|
||||
.day1
|
||||
.average;
|
||||
.rolling
|
||||
.distribution
|
||||
.average
|
||||
._24h
|
||||
.day1;
|
||||
|
||||
Ok(iter.collect(|di, ts, h| {
|
||||
rewards_vec.collect_one(di).map(|reward| BlockRewardsEntry {
|
||||
rewards_vec.collect_one_flat(di).map(|reward| BlockRewardsEntry {
|
||||
avg_height: h.into(),
|
||||
timestamp: *ts,
|
||||
avg_rewards: *reward,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{BlockSizeEntry, BlockSizesWeights, BlockWeightEntry, TimePeriod};
|
||||
use vecdb::{ReadableVec, VecIndex};
|
||||
use vecdb::{ReadableOptionVec, VecIndex};
|
||||
|
||||
use super::day1_iter::Day1Iter;
|
||||
use crate::Query;
|
||||
@@ -36,8 +36,8 @@ impl Query {
|
||||
.day1;
|
||||
|
||||
let entries: Vec<_> = iter.collect(|di, ts, h| {
|
||||
let size: Option<u64> = sizes_vec.collect_one(di).map(|s| *s);
|
||||
let weight: Option<u64> = weights_vec.collect_one(di).map(|w| *w);
|
||||
let size: Option<u64> = sizes_vec.collect_one_flat(di).map(|s| *s);
|
||||
let weight: Option<u64> = weights_vec.collect_one_flat(di).map(|w| *w);
|
||||
Some((u32::from(h), (*ts), size, weight))
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{Day1, DifficultyEntry, HashrateEntry, HashrateSummary, Height, TimePeriod};
|
||||
use vecdb::{ReadableVec, VecIndex};
|
||||
use vecdb::{ReadableOptionVec, ReadableVec, VecIndex};
|
||||
|
||||
use super::epochs::iter_difficulty_epochs;
|
||||
use crate::Query;
|
||||
@@ -27,8 +27,8 @@ impl Query {
|
||||
.hashrate
|
||||
.hash_rate
|
||||
.day1
|
||||
.collect_one(current_day1)
|
||||
.unwrap() as u128;
|
||||
.collect_one_flat(current_day1)
|
||||
.unwrap_or_default() as u128;
|
||||
|
||||
// Calculate start height based on time period
|
||||
let end = current_height.to_usize();
|
||||
@@ -61,11 +61,11 @@ impl Query {
|
||||
while di <= end_day1.to_usize() {
|
||||
let day1 = Day1::from(di);
|
||||
if let (Some(hr), Some(timestamp)) =
|
||||
(hashrate_vec.collect_one(day1), timestamp_vec.collect_one(day1))
|
||||
(hashrate_vec.collect_one_flat(day1), timestamp_vec.collect_one(day1))
|
||||
{
|
||||
hashrates.push(HashrateEntry {
|
||||
timestamp,
|
||||
avg_hashrate: (*hr) as u128,
|
||||
avg_hashrate: *hr as u128,
|
||||
});
|
||||
}
|
||||
di += step;
|
||||
|
||||
@@ -32,7 +32,7 @@ impl Query {
|
||||
for (pool_id, pool_vecs) in &computer.pools.vecs {
|
||||
let cumulative = &pool_vecs
|
||||
.blocks_mined
|
||||
.height_cumulative;
|
||||
.cumulative.height;
|
||||
|
||||
let count_at_end: u32 = *cumulative.collect_one(current_height).unwrap_or_default();
|
||||
|
||||
@@ -100,7 +100,7 @@ impl Query {
|
||||
|
||||
let cumulative = &pool_vecs
|
||||
.blocks_mined
|
||||
.height_cumulative;
|
||||
.cumulative.height;
|
||||
|
||||
// Get total blocks (all time)
|
||||
let total_all: u32 = *cumulative.collect_one(current_height).unwrap_or_default();
|
||||
|
||||
@@ -13,7 +13,7 @@ impl Query {
|
||||
let start_block = Height::from(current_height.to_usize().saturating_sub(block_count - 1));
|
||||
|
||||
let coinbase_vec = &computer.mining.rewards.coinbase.sats.height;
|
||||
let fee_vec = &computer.transactions.fees.fee.sum_cum.sum.0;
|
||||
let fee_vec = &computer.transactions.fees.fee.sum_cumulative.sum.0;
|
||||
let tx_count_vec = &computer.transactions.count.tx_count.height;
|
||||
|
||||
let start = start_block.to_usize();
|
||||
|
||||
Reference in New Issue
Block a user