Skip to content

Commit

Permalink
refactor(chain): KeychainTxOutIndex use HashMap for fields
Browse files Browse the repository at this point in the history
Instead of `BTreeMap` which is less performant.
  • Loading branch information
evanlinjin committed Jun 12, 2024
1 parent f456a04 commit 80470f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/chain/src/keychain/txout_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ pub struct KeychainTxOutIndex<K> {
/// keychain -> (descriptor id) map
keychains_to_descriptor_ids: BTreeMap<K, DescriptorId>,
/// descriptor id -> keychain map
descriptor_ids_to_keychains: BTreeMap<DescriptorId, K>,
descriptor_ids_to_keychains: HashMap<DescriptorId, K>,
/// descriptor_id -> descriptor map
/// This is a "monotone" map, meaning that its size keeps growing, i.e., we never delete
/// descriptors from it. This is useful for revealing spks for descriptors that don't have
/// keychains associated.
descriptor_ids_to_descriptors: BTreeMap<DescriptorId, Descriptor<DescriptorPublicKey>>,
descriptor_ids_to_descriptors: HashMap<DescriptorId, Descriptor<DescriptorPublicKey>>,
/// last revealed indices for each descriptor.
last_revealed: HashMap<DescriptorId, u32>,
/// lookahead setting
Expand Down Expand Up @@ -201,8 +201,8 @@ impl<K> KeychainTxOutIndex<K> {
pub fn new(lookahead: u32) -> Self {
Self {
inner: SpkTxOutIndex::default(),
keychains_to_descriptor_ids: BTreeMap::new(),
descriptor_ids_to_descriptors: BTreeMap::new(),
keychains_to_descriptor_ids: Default::default(),
descriptor_ids_to_descriptors: Default::default(),
descriptor_ids_to_keychains: Default::default(),
last_revealed: Default::default(),
lookahead,
Expand Down

0 comments on commit 80470f4

Please sign in to comment.