global: snapshot

This commit is contained in:
nym21
2026-02-12 22:52:57 +01:00
parent 3bc20a0a46
commit b779edc0d6
60 changed files with 8720 additions and 1504 deletions

View File

@@ -5,6 +5,7 @@ mod mempool;
mod metrics;
mod metrics_legacy;
mod mining;
mod price;
mod transaction;
pub use block::BLOCK_TXS_PAGE_SIZE;

View File

@@ -0,0 +1,29 @@
use brk_error::{Error, Result};
use brk_types::Dollars;
use crate::Query;
impl Query {
pub fn live_price(&self) -> Result<Dollars> {
let oracle_vecs = &self
.computer()
.price
.as_ref()
.ok_or_else(|| Error::OutOfRange("Oracle prices not computed yet".into()))?
.oracle;
let mut oracle = oracle_vecs.live_oracle(self.indexer())?;
if let Some(mempool) = self.mempool() {
let txs = mempool.get_txs();
let mempool_outputs: Vec<_> = txs
.values()
.flat_map(|tx| &tx.tx().output)
.map(|txout| (txout.value, txout.type_()))
.collect();
oracle.process_outputs(mempool_outputs.into_iter());
}
Ok(oracle.price_dollars())
}
}