diff --git a/src/index.rs b/src/index.rs index 641ce9085b..ff794afb59 100644 --- a/src/index.rs +++ b/src/index.rs @@ -50,7 +50,7 @@ mod utxo_entry; #[cfg(test)] pub(crate) mod testing; -const SCHEMA_VERSION: u64 = 30; +const SCHEMA_VERSION: u64 = 31; define_multimap_table! { SAT_TO_SEQUENCE_NUMBER, u64, u32 } define_multimap_table! { SEQUENCE_NUMBER_TO_CHILDREN, u32, u32 } diff --git a/src/index/updater.rs b/src/index/updater.rs index 5eb2c0abc7..44f18081be 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -574,9 +574,7 @@ impl Updater<'_> { let mut entry = UtxoEntryBuf::new(); entry.push_value(txout.value.to_sat(), self.index); - if self.index.index_addresses { - entry.push_script_pubkey(txout.script_pubkey.as_bytes(), self.index); - } + entry.push_script_pubkey(txout.script_pubkey.as_bytes(), self.index); entry }; @@ -632,9 +630,7 @@ impl Updater<'_> { } } - if self.index.index_addresses { - self.index_transaction_output_script_pubkeys(tx, &mut output_utxo_entries); - } + self.index_transaction_output_script_pubkeys(tx, &mut output_utxo_entries); if index_inscriptions { inscription_updater.index_inscriptions( @@ -685,9 +681,7 @@ impl Updater<'_> { let mut new_utxo_entry = UtxoEntryBuf::new(); new_utxo_entry.push_sat_ranges(&lost_sat_ranges, self.index); - if self.index.index_addresses { - new_utxo_entry.push_script_pubkey(&[], self.index); - } + new_utxo_entry.push_script_pubkey(&[], self.index); *utxo_entry = UtxoEntryBuf::merged(utxo_entry, &new_utxo_entry, self.index); } diff --git a/src/index/utxo_entry.rs b/src/index/utxo_entry.rs index e80437da2a..b49914faa1 100644 --- a/src/index/utxo_entry.rs +++ b/src/index/utxo_entry.rs @@ -21,13 +21,12 @@ enum Sats<'a> { /// by that many 11-byte sat range entries, otherwise the total output value /// stored as a varint. /// -/// If `--index-addresses`, the script pubkey stored as a varint followed by -/// that many bytes of data. -/// /// If `--index-inscriptions`, the list of inscriptions stored as /// `(sequence_number, offset)`, with the sequence number stored as a u32 and /// the offset as a varint. /// +/// The script pubkey stored as a varint followed by that many bytes of data. +/// /// Note that the list of inscriptions doesn't need an explicit length, it /// continues until the end of the array. /// @@ -43,7 +42,7 @@ pub struct UtxoEntry { impl UtxoEntry { pub fn parse(&self, index: &Index) -> ParsedUtxoEntry { let sats; - let mut script_pubkey = None; + let script_pubkey; let mut inscriptions = None; let mut offset = 0; @@ -61,14 +60,12 @@ impl UtxoEntry { offset += varint_len; }; - if index.index_addresses { - let (script_pubkey_len, varint_len) = varint::decode(&self.bytes[offset..]).unwrap(); - offset += varint_len; + let (script_pubkey_len, varint_len) = varint::decode(&self.bytes[offset..]).unwrap(); + offset += varint_len; - let script_pubkey_len: usize = script_pubkey_len.try_into().unwrap(); - script_pubkey = Some(&self.bytes[offset..offset + script_pubkey_len]); - offset += script_pubkey_len; - } + let script_pubkey_len: usize = script_pubkey_len.try_into().unwrap(); + script_pubkey = Some(&self.bytes[offset..offset + script_pubkey_len]); + offset += script_pubkey_len; if index.index_inscriptions { inscriptions = Some(&self.bytes[offset..self.bytes.len()]); @@ -229,7 +226,6 @@ impl UtxoEntryBuf { } pub fn push_script_pubkey(&mut self, script_pubkey: &[u8], index: &Index) { - assert!(index.index_addresses); varint::encode_to_vec(script_pubkey.len().try_into().unwrap(), &mut self.vec); self.vec.extend(script_pubkey); @@ -255,13 +251,9 @@ impl UtxoEntryBuf { } #[cfg(debug_assertions)] - fn advance_state(&mut self, expected_state: State, new_state: State, index: &Index) { + fn advance_state(&mut self, expected_state: State, new_state: State, _index: &Index) { assert!(self.state == expected_state); self.state = new_state; - - if self.state == State::NeedScriptPubkey && !index.index_addresses { - self.state = State::Valid; - } } pub fn merged(a: &UtxoEntry, b: &UtxoEntry, index: &Index) -> Self { @@ -278,11 +270,9 @@ impl UtxoEntryBuf { merged.push_value(0, index); } - if index.index_addresses { - assert!(a_parsed.script_pubkey().is_empty()); - assert!(b_parsed.script_pubkey().is_empty()); - merged.push_script_pubkey(&[], index); - } + assert!(a_parsed.script_pubkey().is_empty()); + assert!(b_parsed.script_pubkey().is_empty()); + merged.push_script_pubkey(&[], index); if index.index_inscriptions { merged.push_inscriptions(a_parsed.inscriptions(), index); @@ -301,9 +291,7 @@ impl UtxoEntryBuf { utxo_entry.push_value(0, index); } - if index.index_addresses { - utxo_entry.push_script_pubkey(&[], index); - } + utxo_entry.push_script_pubkey(&[], index); utxo_entry }