global: snap

This commit is contained in:
nym21
2026-04-12 18:00:02 +02:00
parent 18d9c166d8
commit c3cef71aa3
36 changed files with 2366 additions and 371 deletions
+5 -1
View File
@@ -417,7 +417,11 @@ impl Query {
first_seen: None,
};
blocks.push(BlockInfoV1 { info, extras });
blocks.push(BlockInfoV1 {
info,
stale: false,
extras,
});
}
Ok(blocks)
+7 -7
View File
@@ -3,10 +3,10 @@ use std::{collections::BTreeMap, sync::LazyLock};
use brk_error::{Error, Result};
use brk_traversable::TreeNode;
use brk_types::{
Date, DetailedSeriesCount, Epoch, Etag, Format, Halving, Height, Index, IndexInfo, LegacyValue,
Limit, Output, OutputLegacy, PaginatedSeries, Pagination, PaginationIndex, RangeIndex,
RangeMap, SearchQuery, SeriesData, SeriesInfo, SeriesName, SeriesOutput, SeriesOutputLegacy,
SeriesSelection, Timestamp, Version,
BlockHashPrefix, Date, DetailedSeriesCount, Epoch, Etag, Format, Halving, Height, Index,
IndexInfo, LegacyValue, 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};
@@ -204,7 +204,7 @@ impl Query {
total,
start,
end,
height: *self.height(),
hash_prefix: self.tip_hash_prefix(),
})
}
@@ -458,12 +458,12 @@ pub struct ResolvedQuery {
pub total: usize,
pub start: usize,
pub end: usize,
pub height: u32,
pub hash_prefix: BlockHashPrefix,
}
impl ResolvedQuery {
pub fn etag(&self) -> Etag {
Etag::from_series(self.version, self.total, self.start, self.end, self.height)
Etag::from_series(self.version, self.total, self.end, self.hash_prefix)
}
pub fn format(&self) -> Format {
+14 -1
View File
@@ -4,7 +4,7 @@ use brk_types::{
BlockHash, Height, MerkleProof, Timestamp, Transaction, TxInIndex, TxIndex, TxOutIndex,
TxOutspend, TxStatus, Txid, TxidPrefix, Vin, Vout,
};
use vecdb::{ReadableVec, VecIndex};
use vecdb::{AnyVec, ReadableVec, VecIndex};
use crate::Query;
@@ -23,6 +23,19 @@ impl Query {
.ok_or(Error::UnknownTxid)
}
pub fn txid_by_index(&self, index: TxIndex) -> Result<Txid> {
let len = self.indexer().vecs.transactions.txid.len();
if index.to_usize() >= len {
return Err(Error::OutOfRange("Transaction index out of range".into()));
}
self.indexer()
.vecs
.transactions
.txid
.collect_one(index)
.ok_or_else(|| Error::OutOfRange("Transaction index out of range".into()))
}
/// Resolve a txid to (TxIndex, Height).
pub fn resolve_tx(&self, txid: &Txid) -> Result<(TxIndex, Height)> {
let tx_index = self.resolve_tx_index(txid)?;