chore: make TxCache.save_txs can order independent

This commit is contained in:
bodymindarts 2022-11-30 15:17:49 +01:00 committed by Steve Myers
parent 99930af12e
commit d72aa7ebc0
No known key found for this signature in database
GPG Key ID: 8105A46B22C2D051

View File

@ -281,9 +281,11 @@ impl<'a, 'b, D: Database> TxCache<'a, 'b, D> {
.client
.batch_transaction_get(need_fetch.clone())
.map_err(Error::Electrum)?;
for (tx, _txid) in txs.into_iter().zip(need_fetch) {
debug_assert_eq!(*_txid, tx.txid());
self.cache.insert(tx.txid(), tx);
let mut txs: HashMap<_, _> = txs.into_iter().map(|tx| (tx.txid(), tx)).collect();
for txid in need_fetch {
if let Some(tx) = txs.remove(txid) {
self.cache.insert(*txid, tx);
}
}
}