mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
global: snapshot
This commit is contained in:
@@ -20,7 +20,11 @@ impl Query {
|
||||
return Err(Error::OutOfRange("Block height out of range".into()));
|
||||
}
|
||||
|
||||
let position = computer.positions.block_position.collect_one(height).unwrap();
|
||||
let position = computer
|
||||
.positions
|
||||
.block_position
|
||||
.collect_one(height)
|
||||
.unwrap();
|
||||
let size = indexer.vecs.blocks.total_size.collect_one(height).unwrap();
|
||||
|
||||
reader.read_raw_bytes(position, *size as usize)
|
||||
|
||||
@@ -13,14 +13,7 @@ impl Query {
|
||||
fn block_status_by_height(&self, height: Height) -> Result<BlockStatus> {
|
||||
let indexer = self.indexer();
|
||||
|
||||
let max_height = Height::from(
|
||||
indexer
|
||||
.vecs
|
||||
.blocks
|
||||
.blockhash
|
||||
.len()
|
||||
.saturating_sub(1),
|
||||
);
|
||||
let max_height = Height::from(indexer.vecs.blocks.blockhash.len().saturating_sub(1));
|
||||
|
||||
if height > max_height {
|
||||
return Ok(BlockStatus::not_in_best_chain());
|
||||
|
||||
@@ -57,7 +57,12 @@ impl Query {
|
||||
}
|
||||
|
||||
let height = Height::from(best_height);
|
||||
let blockhash = indexer.vecs.blocks.blockhash.reader().get(usize::from(height));
|
||||
let blockhash = indexer
|
||||
.vecs
|
||||
.blocks
|
||||
.blockhash
|
||||
.reader()
|
||||
.get(usize::from(height));
|
||||
|
||||
// Convert timestamp to ISO 8601 format
|
||||
let ts_secs: i64 = (*best_ts).into();
|
||||
|
||||
@@ -31,7 +31,12 @@ impl Query {
|
||||
return Err(Error::OutOfRange("Block height out of range".into()));
|
||||
}
|
||||
|
||||
let first_txindex = indexer.vecs.transactions.first_txindex.collect_one(height).unwrap();
|
||||
let first_txindex = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
.first_txindex
|
||||
.collect_one(height)
|
||||
.unwrap();
|
||||
let next_first_txindex = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
@@ -42,20 +47,12 @@ impl Query {
|
||||
let first: usize = first_txindex.into();
|
||||
let next: usize = next_first_txindex.into();
|
||||
|
||||
let txids: Vec<Txid> = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
.txid
|
||||
.collect_range_at(first, next);
|
||||
let txids: Vec<Txid> = indexer.vecs.transactions.txid.collect_range_at(first, next);
|
||||
|
||||
Ok(txids)
|
||||
}
|
||||
|
||||
fn block_txs_by_height(
|
||||
&self,
|
||||
height: Height,
|
||||
start_index: usize,
|
||||
) -> Result<Vec<Transaction>> {
|
||||
fn block_txs_by_height(&self, height: Height, start_index: usize) -> Result<Vec<Transaction>> {
|
||||
let indexer = self.indexer();
|
||||
|
||||
let max_height = self.height();
|
||||
@@ -63,7 +60,12 @@ impl Query {
|
||||
return Err(Error::OutOfRange("Block height out of range".into()));
|
||||
}
|
||||
|
||||
let first_txindex = indexer.vecs.transactions.first_txindex.collect_one(height).unwrap();
|
||||
let first_txindex = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
.first_txindex
|
||||
.collect_one(height)
|
||||
.unwrap();
|
||||
let next_first_txindex = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
@@ -100,7 +102,12 @@ impl Query {
|
||||
return Err(Error::OutOfRange("Block height out of range".into()));
|
||||
}
|
||||
|
||||
let first_txindex = indexer.vecs.transactions.first_txindex.collect_one(height).unwrap();
|
||||
let first_txindex = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
.first_txindex
|
||||
.collect_one(height)
|
||||
.unwrap();
|
||||
let next_first_txindex = indexer
|
||||
.vecs
|
||||
.transactions
|
||||
|
||||
Reference in New Issue
Block a user