Skip to content

Commit edf0279

Browse files
committed
Merge #1993: keychain_txout: apply_changeset restores spk cache before last revealed
6ddecc9 refactor(keychain_txout): `apply_changeset` restores spk cache before last revealed (valued mammal) Pull request description: This patch improves readability and maintains logical consistency with the use of `spk_cache` throughout the `keychain_txout` module. While it might offer a performance benefit, the results are mostly comparable with the current benchmarks as far as I can tell. At least there's no indication that it would negatively impact performance. fixes #1975 ### Changelog notice ### Checklists #### All Submissions: * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) ACKs for top commit: LagginTimes: ACK 6ddecc9 Tree-SHA512: 4c11d049f94f332c88c63687d5147d25cc372d65b5f1d9d9c8784e1310e0f03e9aee479b684c255dbebb1510a7922331ad07cbcbdf47d534cf28ea8ee0e1be66
2 parents d9c2b95 + 6ddecc9 commit edf0279

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/chain/src/indexer/keychain_txout.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,16 +938,16 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
938938

939939
/// Applies the `ChangeSet<K>` to the [`KeychainTxOutIndex<K>`]
940940
pub fn apply_changeset(&mut self, changeset: ChangeSet) {
941-
for (did, index) in changeset.last_revealed {
942-
let v = self.last_revealed.entry(did).or_default();
943-
*v = index.max(*v);
944-
self.replenish_inner_index_did(did, self.lookahead);
945-
}
946941
if self.persist_spks {
947942
for (did, spks) in changeset.spk_cache {
948943
self.spk_cache.entry(did).or_default().extend(spks);
949944
}
950945
}
946+
for (did, index) in changeset.last_revealed {
947+
let v = self.last_revealed.entry(did).or_default();
948+
*v = index.max(*v);
949+
self.replenish_inner_index_did(did, self.lookahead);
950+
}
951951
}
952952
}
953953

0 commit comments

Comments
 (0)