mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-29 20:59:27 -07:00
global: fmt
This commit is contained in:
@@ -17,8 +17,7 @@ impl Query {
|
||||
match time_period {
|
||||
// Per-block, exact rewards
|
||||
TimePeriod::Day | TimePeriod::ThreeDays => {
|
||||
let rewards: Vec<Sats> =
|
||||
coinbase_vec.collect_range_at(start, current_height + 1);
|
||||
let rewards: Vec<Sats> = coinbase_vec.collect_range_at(start, current_height + 1);
|
||||
let timestamps: Vec<brk_types::Timestamp> =
|
||||
timestamp_vec.collect_range_at(start, current_height + 1);
|
||||
|
||||
@@ -45,8 +44,7 @@ impl Query {
|
||||
.collect_one(Height::from(current_height))
|
||||
.unwrap_or_default();
|
||||
|
||||
let total_days =
|
||||
end_di.to_usize().saturating_sub(start_di.to_usize()) + 1;
|
||||
let total_days = end_di.to_usize().saturating_sub(start_di.to_usize()) + 1;
|
||||
let step = (total_days / 200).max(1);
|
||||
|
||||
let mut entries = Vec::with_capacity(total_days / step + 1);
|
||||
@@ -63,12 +61,9 @@ impl Query {
|
||||
|
||||
let block_count = next_h.to_usize() - first_h.to_usize();
|
||||
if block_count > 0 {
|
||||
let sum = coinbase_vec.fold_range(
|
||||
first_h,
|
||||
next_h,
|
||||
Sats::ZERO,
|
||||
|acc, v| acc + v,
|
||||
);
|
||||
let sum =
|
||||
coinbase_vec
|
||||
.fold_range(first_h, next_h, Sats::ZERO, |acc, v| acc + v);
|
||||
let avg = *sum / block_count as u64;
|
||||
|
||||
if let Some(ts) = timestamp_vec.collect_one(first_h) {
|
||||
|
||||
@@ -30,7 +30,8 @@ impl Query {
|
||||
let current_hashrate = *computer
|
||||
.mining
|
||||
.hashrate
|
||||
.rate.base
|
||||
.rate
|
||||
.base
|
||||
.day1
|
||||
.collect_one_flat(current_day1)
|
||||
.unwrap_or_default() as u128;
|
||||
|
||||
@@ -4,9 +4,9 @@ use brk_error::{Error, Result};
|
||||
use brk_traversable::TreeNode;
|
||||
use brk_types::{
|
||||
Date, DetailedSeriesCount, Epoch, Etag, Format, Halving, Height, Index, IndexInfo, LegacyValue,
|
||||
Limit, SeriesName, SeriesData, SeriesInfo, SeriesOutput, SeriesOutputLegacy, SeriesSelection,
|
||||
Output, OutputLegacy, PaginatedSeries, Pagination, PaginationIndex, RangeIndex, RangeMap,
|
||||
SearchQuery, Timestamp, Version,
|
||||
Limit, Output, OutputLegacy, PaginatedSeries, Pagination, PaginationIndex, RangeIndex,
|
||||
RangeMap, SearchQuery, SeriesData, SeriesInfo, SeriesName, SeriesOutput, SeriesOutputLegacy,
|
||||
SeriesSelection, Timestamp, Version,
|
||||
};
|
||||
use parking_lot::RwLock;
|
||||
use vecdb::{AnyExportableVec, ReadableVec};
|
||||
@@ -46,7 +46,8 @@ impl Query {
|
||||
|
||||
// Series doesn't exist, suggest alternatives
|
||||
let matches = self
|
||||
.vecs().matches(series, Limit::DEFAULT)
|
||||
.vecs()
|
||||
.matches(series, Limit::DEFAULT)
|
||||
.into_iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
@@ -261,7 +262,12 @@ impl Query {
|
||||
}
|
||||
|
||||
let ResolvedQuery {
|
||||
vecs, version, total, start, end, ..
|
||||
vecs,
|
||||
version,
|
||||
total,
|
||||
start,
|
||||
end,
|
||||
..
|
||||
} = resolved;
|
||||
|
||||
let count = end.saturating_sub(start);
|
||||
@@ -309,7 +315,10 @@ impl Query {
|
||||
}
|
||||
|
||||
pub fn series_info(&self, series: &SeriesName) -> Option<SeriesInfo> {
|
||||
let index_to_vec = self.vecs().series_to_index_to_vec.get(series.replace("-", "_").as_str())?;
|
||||
let index_to_vec = self
|
||||
.vecs()
|
||||
.series_to_index_to_vec
|
||||
.get(series.replace("-", "_").as_str())?;
|
||||
let value_type = index_to_vec.values().next()?.value_type_to_string();
|
||||
let indexes = index_to_vec.keys().copied().collect();
|
||||
Some(SeriesInfo {
|
||||
|
||||
@@ -359,7 +359,12 @@ impl Query {
|
||||
let indexer = self.indexer();
|
||||
|
||||
// Look up spending tx_index directly
|
||||
let spending_tx_index = indexer.vecs.inputs.tx_index.collect_one(txin_index).unwrap();
|
||||
let spending_tx_index = indexer
|
||||
.vecs
|
||||
.inputs
|
||||
.tx_index
|
||||
.collect_one(txin_index)
|
||||
.unwrap();
|
||||
|
||||
// Calculate vin
|
||||
let spending_first_txin_index = indexer
|
||||
@@ -371,7 +376,11 @@ impl Query {
|
||||
let vin = Vin::from(usize::from(txin_index) - usize::from(spending_first_txin_index));
|
||||
|
||||
// Get spending tx details
|
||||
let spending_txid = indexer.vecs.transactions.txid.read_once(spending_tx_index)?;
|
||||
let spending_txid = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
.txid
|
||||
.read_once(spending_tx_index)?;
|
||||
let spending_height = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
|
||||
@@ -4,7 +4,7 @@ use brk_computer::Computer;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_traversable::{Traversable, TreeNode};
|
||||
use brk_types::{
|
||||
Index, IndexInfo, Limit, PaginatedSeries, Pagination, PaginationIndex, SeriesName, SeriesCount,
|
||||
Index, IndexInfo, Limit, PaginatedSeries, Pagination, PaginationIndex, SeriesCount, SeriesName,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use quickmatch::{QuickMatch, QuickMatchConfig};
|
||||
|
||||
Reference in New Issue
Block a user