mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-27 10:48:11 -07:00
computer: simplified a bunch of things
This commit is contained in:
@@ -57,8 +57,7 @@ impl BlockProcessor<'_> {
|
||||
|
||||
let addr_hash_stores = &mut self.stores.addresstype_to_addresshash_to_addressindex;
|
||||
let addr_txindex_stores = &mut self.stores.addresstype_to_addressindex_and_txindex;
|
||||
let addr_outpoint_stores =
|
||||
&mut self.stores.addresstype_to_addressindex_and_unspentoutpoint;
|
||||
let addr_outpoint_stores = &mut self.stores.addresstype_to_addressindex_and_unspentoutpoint;
|
||||
let txidprefix_store = &mut self.stores.txidprefix_to_txindex;
|
||||
|
||||
let (finalize_result, metadata_result) = rayon::join(
|
||||
|
||||
@@ -135,10 +135,16 @@ impl<'a> BlockProcessor<'a> {
|
||||
out: &mut FxHashSet<OutPoint>,
|
||||
) {
|
||||
out.clear();
|
||||
out.extend(txins.iter().filter_map(|(_, input_source)| match input_source {
|
||||
InputSource::SameBlock { outpoint, .. } if !outpoint.is_coinbase() => Some(*outpoint),
|
||||
_ => None,
|
||||
}));
|
||||
out.extend(
|
||||
txins
|
||||
.iter()
|
||||
.filter_map(|(_, input_source)| match input_source {
|
||||
InputSource::SameBlock { outpoint, .. } if !outpoint.is_coinbase() => {
|
||||
Some(*outpoint)
|
||||
}
|
||||
_ => None,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,13 +171,23 @@ pub(super) fn finalize_inputs(
|
||||
outpoint,
|
||||
} => {
|
||||
if outpoint.is_coinbase() {
|
||||
(vin, txindex, outpoint, OutputType::Unknown, TypeIndex::COINBASE)
|
||||
(
|
||||
vin,
|
||||
txindex,
|
||||
outpoint,
|
||||
OutputType::Unknown,
|
||||
TypeIndex::COINBASE,
|
||||
)
|
||||
} else {
|
||||
let info = same_block_output_info
|
||||
.remove(&outpoint)
|
||||
.ok_or(Error::Internal("Same-block output not found"))
|
||||
.inspect_err(|_| {
|
||||
error!(?outpoint, remaining = same_block_output_info.len(), "Same-block output not found");
|
||||
error!(
|
||||
?outpoint,
|
||||
remaining = same_block_output_info.len(),
|
||||
"Same-block output not found"
|
||||
);
|
||||
})?;
|
||||
(vin, txindex, outpoint, info.outputtype, info.typeindex)
|
||||
}
|
||||
@@ -195,10 +211,7 @@ pub(super) fn finalize_inputs(
|
||||
|
||||
addr_txindex_stores
|
||||
.get_mut_unwrap(addresstype)
|
||||
.insert(
|
||||
AddressIndexTxIndex::from((addressindex, txindex)),
|
||||
Unit,
|
||||
);
|
||||
.insert(AddressIndexTxIndex::from((addressindex, txindex)), Unit);
|
||||
|
||||
addr_outpoint_stores
|
||||
.get_mut_unwrap(addresstype)
|
||||
|
||||
@@ -6,8 +6,8 @@ use brk_types::{
|
||||
Sats, TxIndex, TxOutIndex, TypeIndex, Unit, Vout,
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use tracing::error;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use tracing::error;
|
||||
use vecdb::{BytesVec, WritableVec};
|
||||
|
||||
use super::{BlockProcessor, ProcessedOutput, SameBlockOutputInfo};
|
||||
@@ -68,17 +68,21 @@ impl<'a> BlockProcessor<'a> {
|
||||
});
|
||||
|
||||
if check_collisions && let Some(typeindex) = existing_typeindex {
|
||||
let prev_addressbytes = self.vecs.addresses.get_bytes_by_type(
|
||||
addresstype,
|
||||
typeindex,
|
||||
&self.readers.addressbytes,
|
||||
)
|
||||
.ok_or(Error::Internal("Missing addressbytes"))?;
|
||||
let prev_addressbytes = self
|
||||
.vecs
|
||||
.addresses
|
||||
.get_bytes_by_type(addresstype, typeindex, &self.readers.addressbytes)
|
||||
.ok_or(Error::Internal("Missing addressbytes"))?;
|
||||
|
||||
if prev_addressbytes != address_bytes {
|
||||
error!(
|
||||
?height, ?vout, ?block_txindex, ?addresstype,
|
||||
?prev_addressbytes, ?address_bytes, ?typeindex,
|
||||
?height,
|
||||
?vout,
|
||||
?block_txindex,
|
||||
?addresstype,
|
||||
?prev_addressbytes,
|
||||
?address_bytes,
|
||||
?typeindex,
|
||||
"Address hash collision"
|
||||
);
|
||||
return Err(Error::Internal("Address hash collision"));
|
||||
@@ -202,10 +206,7 @@ pub(super) fn finalize_outputs(
|
||||
|
||||
addr_txindex_stores
|
||||
.get_mut_unwrap(addresstype)
|
||||
.insert(
|
||||
AddressIndexTxIndex::from((addressindex, txindex)),
|
||||
Unit,
|
||||
);
|
||||
.insert(AddressIndexTxIndex::from((addressindex, txindex)), Unit);
|
||||
}
|
||||
|
||||
let outpoint = OutPoint::new(txindex, vout);
|
||||
@@ -224,10 +225,7 @@ pub(super) fn finalize_outputs(
|
||||
|
||||
addr_outpoint_stores
|
||||
.get_mut_unwrap(addresstype)
|
||||
.insert(
|
||||
AddressIndexOutPoint::from((addressindex, outpoint)),
|
||||
Unit,
|
||||
);
|
||||
.insert(AddressIndexOutPoint::from((addressindex, outpoint)), Unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user