From: bodymindarts Date: Wed, 30 Nov 2022 14:17:49 +0000 (+0100) Subject: chore: make TxCache.save_txs can order independent X-Git-Tag: v0.26.0-rc.1~7^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CodeLengthError.html?a=commitdiff_plain;h=d72aa7ebc071cb418ce53efa8da7447bac8161f7;p=bdk chore: make TxCache.save_txs can order independent --- diff --git a/src/blockchain/electrum.rs b/src/blockchain/electrum.rs index 54381241..23c7500e 100644 --- a/src/blockchain/electrum.rs +++ b/src/blockchain/electrum.rs @@ -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); + } } }