mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-01 18:53:38 -07:00
global: snap
This commit is contained in:
@@ -417,7 +417,11 @@ impl Query {
|
||||
first_seen: None,
|
||||
};
|
||||
|
||||
blocks.push(BlockInfoV1 { info, extras });
|
||||
blocks.push(BlockInfoV1 {
|
||||
info,
|
||||
stale: false,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(blocks)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user