Skip to content

Commit

Permalink
Add option --index-transfers to have the index track which inscript…
Browse files Browse the repository at this point in the history
…ions are transferred in each block. Previously this was already enabled, using up space in the index whether it was needed or not.
  • Loading branch information
gmart7t2 committed Dec 11, 2023
1 parent 5bc9230 commit b6f85bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub(crate) struct Index {
genesis_block_coinbase_txid: Txid,
height_limit: Option<u64>,
index_runes: bool,
index_transfers: bool,
index_sats: bool,
no_progress_bar: bool,
options: Options,
Expand Down Expand Up @@ -326,6 +327,7 @@ impl Index {
first_inscription_height: options.first_inscription_height(),
genesis_block_coinbase_transaction,
height_limit: options.height_limit,
index_transfers: options.index_transfers,
no_progress_bar: options.no_progress_bar,
options: options.clone(),
index_runes,
Expand Down
6 changes: 5 additions & 1 deletion src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,11 @@ impl<'index> Updater<'_> {
}

let mut height_to_block_hash = wtx.open_table(HEIGHT_TO_BLOCK_HASH)?;
let mut height_to_inscription_id = wtx.open_multimap_table(HEIGHT_TO_INSCRIPTION_ID)?;
let mut height_to_inscription_id = if index.index_transfers {
Some(wtx.open_multimap_table(HEIGHT_TO_INSCRIPTION_ID)?)
} else {
None
};
let mut height_to_last_sequence_number = wtx.open_table(HEIGHT_TO_LAST_SEQUENCE_NUMBER)?;
let mut inscription_id_to_inscription_entry =
wtx.open_table(INSCRIPTION_ID_TO_INSCRIPTION_ENTRY)?;
Expand Down
10 changes: 5 additions & 5 deletions src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum Origin {
pub(super) struct InscriptionUpdater<'a, 'db, 'tx> {
flotsam: Vec<Flotsam>,
height: u64,
height_to_inscription_id: &'a mut MultimapTable<'db, 'tx, u64, &'static InscriptionIdValue>,
height_to_inscription_id: &'a mut Option<MultimapTable<'db, 'tx, u64, &'static InscriptionIdValue>>,
id_to_children:
&'a mut MultimapTable<'db, 'tx, &'static InscriptionIdValue, &'static InscriptionIdValue>,
id_to_satpoint: &'a mut Table<'db, 'tx, &'static InscriptionIdValue, &'static SatPointValue>,
Expand All @@ -50,7 +50,7 @@ pub(super) struct InscriptionUpdater<'a, 'db, 'tx> {
impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> {
pub(super) fn new(
height: u64,
height_to_inscription_id: &'a mut MultimapTable<'db, 'tx, u64, &'static InscriptionIdValue>,
height_to_inscription_id: &'a mut Option<MultimapTable<'db, 'tx, u64, &'static InscriptionIdValue>>,
id_to_children: &'a mut MultimapTable<
'db,
'tx,
Expand Down Expand Up @@ -443,9 +443,9 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> {
let inscription_id = flotsam.inscription_id.store();
let unbound = match flotsam.origin {
Origin::Old { old_satpoint } => {
self
.height_to_inscription_id
.insert(&self.height, &inscription_id)?;
if let Some(height_to_inscription_id) = &mut self.height_to_inscription_id {
height_to_inscription_id.insert(&self.height, &inscription_id)?;
}
self.satpoint_to_id.remove_all(&old_satpoint.store())?;

false
Expand Down
2 changes: 2 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub(crate) struct Options {
pub(crate) index_runes_pre_alpha_i_agree_to_get_rekt: bool,
#[arg(long, help = "Track location of all satoshis.")]
pub(crate) index_sats: bool,
#[clap(long, help = "Track transfers of inscriptions.")]
pub(crate) index_transfers: bool,
#[arg(long, help = "Inhibit the display of the progress bar while updating the index.")]
pub(crate) no_progress_bar: bool,
#[arg(long, short, help = "Use regtest. Equivalent to `--chain regtest`.")]
Expand Down

0 comments on commit b6f85bb

Please sign in to comment.