Skip to content

Commit

Permalink
Don't do parallel stuff when deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
junderw committed Dec 26, 2024
1 parent 737d725 commit 1ca1cc0
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/new_index/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,11 @@ impl Indexer {
debug!("Indexing ({}) {} blocks with Indexer", op, blocks.len());
let previous_txos_map = {
let _timer = self.start_timer("index_lookup");
lookup_txos(&self.store.txstore_db, &get_previous_txos(blocks), false)
if matches!(op, Operation::AddBlocks) {
lookup_txos(&self.store.txstore_db, &get_previous_txos(blocks), false)
} else {
lookup_txos_sequential(&self.store.txstore_db, &get_previous_txos(blocks), false)
}
};
let rows = {
let _timer = self.start_timer("index_process");
Expand Down Expand Up @@ -1433,6 +1437,7 @@ fn lookup_txos(
}
};
pool.install(|| {
// Should match lookup_txos_sequential
outpoints
.par_iter()
.filter_map(|outpoint| {
Expand All @@ -1449,6 +1454,27 @@ fn lookup_txos(
})
}

fn lookup_txos_sequential(
txstore_db: &DB,
outpoints: &BTreeSet<OutPoint>,
allow_missing: bool,
) -> HashMap<OutPoint, TxOut> {
// Should match lookup_txos
outpoints
.iter()
.filter_map(|outpoint| {
lookup_txo(txstore_db, outpoint)
.or_else(|| {
if !allow_missing {
panic!("missing txo {} in {:?}", outpoint, txstore_db);
}
None
})
.map(|txo| (*outpoint, txo))
})
.collect()
}

fn lookup_txo(txstore_db: &DB, outpoint: &OutPoint) -> Option<TxOut> {
txstore_db
.get(&TxOutRow::key(outpoint))
Expand Down

0 comments on commit 1ca1cc0

Please sign in to comment.