From 30dc695741a019ca2494b2bb5201aef3e6ad08a5 Mon Sep 17 00:00:00 2001 From: nym21 Date: Wed, 26 Nov 2025 22:46:58 +0100 Subject: [PATCH] global: fixes --- crates/brk_indexer/src/lib.rs | 2 +- crates/brk_indexer/src/stores_v2.rs | 22 +++++++++++++--------- crates/brk_types/src/blockhashprefix.rs | 4 +++- crates/brk_types/src/txidprefix.rs | 11 +++-------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/crates/brk_indexer/src/lib.rs b/crates/brk_indexer/src/lib.rs index f75bfe851..a9e67b31c 100644 --- a/crates/brk_indexer/src/lib.rs +++ b/crates/brk_indexer/src/lib.rs @@ -30,7 +30,7 @@ pub use vecs::*; // Increment on **change _OR_ addition** const VERSION: Version = Version::new(23); const SNAPSHOT_BLOCK_RANGE: usize = 1_000; -const COLLISIONS_CHECKED_UP_TO: Height = Height::new(920_000); +const COLLISIONS_CHECKED_UP_TO: Height = Height::new(0); #[derive(Clone)] pub struct Indexer { diff --git a/crates/brk_indexer/src/stores_v2.rs b/crates/brk_indexer/src/stores_v2.rs index 3fa2771dc..9a6499e84 100644 --- a/crates/brk_indexer/src/stores_v2.rs +++ b/crates/brk_indexer/src/stores_v2.rs @@ -1,12 +1,12 @@ -use std::{fs, path::Path}; +use std::{fs, path::Path, str::FromStr}; use brk_error::Result; use brk_grouper::ByAddressType; use brk_store::{AnyStore, Mode, StoreFjallV2 as Store, Type}; use brk_types::{ AddressBytes, AddressHash, AddressIndexOutPoint, AddressIndexTxIndex, BlockHashPrefix, Height, - OutPoint, OutputType, StoredString, TxIndex, TxOutIndex, TxidPrefix, TypeIndex, Unit, Version, - Vout, + OutPoint, OutputType, StoredString, TxIndex, TxOutIndex, Txid, TxidPrefix, TypeIndex, Unit, + Version, Vout, }; use fjall2::{CompressionType as Compression, PersistMode, TransactionalKeyspace}; use rayon::prelude::*; @@ -366,6 +366,12 @@ impl Stores { } if starting_indexes.txindex != TxIndex::ZERO { + let txidprefix_dup1 = TxidPrefix::from(Txid::from(bitcoin::Txid::from_str( + "d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599", + )?)); + let txidprefix_dup2 = TxidPrefix::from(Txid::from(bitcoin::Txid::from_str( + "e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468", + )?)); vecs.txindex_to_txid .iter()? .enumerate() @@ -375,13 +381,11 @@ impl Stores { let txidprefix = TxidPrefix::from(&txid); - // "d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599" - let is_not_first_dup = txindex != TxIndex::new(142783) - || txidprefix != TxidPrefix::from([153, 133, 216, 41, 84, 225, 15, 34]); + let is_not_first_dup = + txindex != TxIndex::new(142783) || txidprefix != txidprefix_dup1; - // "e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468" - let is_not_second_dup = txindex != TxIndex::new(142841) - || txidprefix != TxidPrefix::from([104, 180, 95, 88, 182, 116, 233, 78]); + let is_not_second_dup = + txindex != TxIndex::new(142841) || txidprefix != txidprefix_dup2; if is_not_first_dup && is_not_second_dup { self.txidprefix_to_txindex.remove(txidprefix); diff --git a/crates/brk_types/src/blockhashprefix.rs b/crates/brk_types/src/blockhashprefix.rs index 5fb6c42ce..32eba13d0 100644 --- a/crates/brk_types/src/blockhashprefix.rs +++ b/crates/brk_types/src/blockhashprefix.rs @@ -16,7 +16,9 @@ impl From for BlockHashPrefix { impl From<&BlockHash> for BlockHashPrefix { #[inline] fn from(value: &BlockHash) -> Self { - Self(u64::from_ne_bytes(value.as_slice().try_into().unwrap())) + Self(u64::from_ne_bytes( + value.as_slice()[0..8].try_into().unwrap(), + )) } } diff --git a/crates/brk_types/src/txidprefix.rs b/crates/brk_types/src/txidprefix.rs index 8d58354a2..d47892448 100644 --- a/crates/brk_types/src/txidprefix.rs +++ b/crates/brk_types/src/txidprefix.rs @@ -16,7 +16,9 @@ impl From for TxidPrefix { impl From<&Txid> for TxidPrefix { #[inline] fn from(value: &Txid) -> Self { - Self(u64::from_ne_bytes(value.as_slice().try_into().unwrap())) + Self(u64::from_ne_bytes( + value.as_slice()[0..8].try_into().unwrap(), + )) } } @@ -40,10 +42,3 @@ impl From<&TxidPrefix> for ByteView { Self::from(value.to_be_bytes()) } } - -impl From<[u8; 8]> for TxidPrefix { - #[inline] - fn from(value: [u8; 8]) -> Self { - Self(u64::from_ne_bytes(value)) - } -}