mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-11 19:18:14 -07:00
global: snapshot
This commit is contained in:
@@ -2,6 +2,7 @@ use brk_error::{Error, Result};
|
||||
use brk_store::Store;
|
||||
use brk_types::{Height, StoredBool, TxIndex, Txid, TxidPrefix};
|
||||
use rayon::prelude::*;
|
||||
use tracing::error;
|
||||
use vecdb::{AnyVec, WritableVec, likely};
|
||||
|
||||
use crate::TxMetadataVecs;
|
||||
@@ -69,13 +70,17 @@ impl<'a> BlockProcessor<'a> {
|
||||
.get_pushed_or_read(prev_txindex, &self.readers.txid)
|
||||
.ok_or(Error::Internal("Missing txid for txindex"))
|
||||
.inspect_err(|_| {
|
||||
dbg!(ct.txindex, len);
|
||||
error!(txindex = ?ct.txindex, len, "Missing txid for txindex");
|
||||
})?;
|
||||
|
||||
let is_dup = DUPLICATE_TXIDS.contains(&prev_txid);
|
||||
|
||||
if !is_dup {
|
||||
dbg!(self.height, ct.txindex, prev_txid, prev_txindex);
|
||||
error!(
|
||||
height = ?self.height, txindex = ?ct.txindex,
|
||||
?prev_txid, ?prev_txindex,
|
||||
"Unexpected TXID collision"
|
||||
);
|
||||
return Err(Error::Internal("Unexpected TXID collision"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use brk_types::{
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use tracing::error;
|
||||
use vecdb::{PcoVec, WritableVec};
|
||||
|
||||
use super::{BlockProcessor, ComputedTx, InputSource, SameBlockOutputInfo};
|
||||
@@ -80,7 +81,7 @@ impl<'a> BlockProcessor<'a> {
|
||||
let prev_txindex = match store_result {
|
||||
Some(txindex) if txindex < self.indexes.txindex => txindex,
|
||||
_ => {
|
||||
tracing::error!(
|
||||
error!(
|
||||
"UnknownTxid: txid={}, prefix={:?}, store_result={:?}, current_txindex={:?}",
|
||||
txid, txid_prefix, store_result, self.indexes.txindex
|
||||
);
|
||||
@@ -170,7 +171,7 @@ pub(super) fn finalize_inputs(
|
||||
.remove(&outpoint)
|
||||
.ok_or(Error::Internal("Same-block output not found"))
|
||||
.inspect_err(|_| {
|
||||
dbg!(&same_block_output_info, outpoint);
|
||||
error!(?outpoint, remaining = same_block_output_info.len(), "Same-block output not found");
|
||||
})?;
|
||||
(vin, txindex, outpoint, info.outputtype, info.typeindex)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use brk_types::{
|
||||
Sats, TxIndex, TxOutIndex, TypeIndex, Unit, Vout,
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use tracing::error;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use vecdb::{BytesVec, WritableVec};
|
||||
|
||||
@@ -24,7 +25,7 @@ impl<'a> BlockProcessor<'a> {
|
||||
let mut items = Vec::with_capacity(total_outputs);
|
||||
for (index, tx) in self.block.txdata.iter().enumerate() {
|
||||
for (vout, txout) in tx.output.iter().enumerate() {
|
||||
items.push((TxIndex::from(index), Vout::from(vout), txout, tx));
|
||||
items.push((TxIndex::from(index), Vout::from(vout), txout));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ impl<'a> BlockProcessor<'a> {
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.map(
|
||||
|(block_txoutindex, (block_txindex, vout, txout, tx))| -> Result<ProcessedOutput> {
|
||||
|(block_txoutindex, (block_txindex, vout, txout))| -> Result<ProcessedOutput> {
|
||||
let txindex = base_txindex + block_txindex;
|
||||
let txoutindex = base_txoutindex + TxOutIndex::from(block_txoutindex);
|
||||
|
||||
@@ -67,7 +68,7 @@ impl<'a> BlockProcessor<'a> {
|
||||
});
|
||||
|
||||
if check_collisions && let Some(typeindex) = existing_typeindex {
|
||||
let prev_addressbytes = self.vecs.get_addressbytes_by_type(
|
||||
let prev_addressbytes = self.vecs.addresses.get_bytes_by_type(
|
||||
addresstype,
|
||||
typeindex,
|
||||
&self.readers.addressbytes,
|
||||
@@ -75,21 +76,12 @@ impl<'a> BlockProcessor<'a> {
|
||||
.ok_or(Error::Internal("Missing addressbytes"))?;
|
||||
|
||||
if prev_addressbytes != address_bytes {
|
||||
let txid = tx.compute_txid();
|
||||
dbg!(
|
||||
height,
|
||||
txid,
|
||||
vout,
|
||||
block_txindex,
|
||||
addresstype,
|
||||
prev_addressbytes,
|
||||
&address_bytes,
|
||||
&self.indexes,
|
||||
typeindex,
|
||||
txout,
|
||||
AddressHash::from(&address_bytes),
|
||||
error!(
|
||||
?height, ?vout, ?block_txindex, ?addresstype,
|
||||
?prev_addressbytes, ?address_bytes, ?typeindex,
|
||||
"Address hash collision"
|
||||
);
|
||||
panic!()
|
||||
return Err(Error::Internal("Address hash collision"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user