Skip to content

Commit bfc323a

Browse files
committed
populate tx cache with mempool txs
1 parent 18fad46 commit bfc323a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/new_index/mempool.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ impl Mempool {
309309
txids.push(txid);
310310
self.txstore.insert(txid, tx);
311311
}
312+
313+
// Populate tx cache
314+
let txid_misses = self.chain.txs_cache_miss(&txids);
315+
let mut tx_misses = vec![];
316+
for txid in txid_misses {
317+
if let Some(tx) = self.txstore.get(&txid) {
318+
let bytes = serialize(tx);
319+
tx_misses.push((txid, bytes));
320+
}
321+
}
322+
self.chain.add_txs_to_cache(&tx_misses);
323+
312324
// Phase 2: index history and spend edges (can fail if some txos cannot be found)
313325
let txos = match self.lookup_txos(self.get_prevouts(&txids)) {
314326
Ok(txos) => txos,

0 commit comments

Comments
 (0)