From 80470f4113b1bf796579ec3ceee7c8401fd3c6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 12 Jun 2024 19:10:52 +0800 Subject: [PATCH] refactor(chain): `KeychainTxOutIndex` use `HashMap` for fields Instead of `BTreeMap` which is less performant. --- crates/chain/src/keychain/txout_index.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index f60b401bbf..7df1056334 100644 --- a/crates/chain/src/keychain/txout_index.rs +++ b/crates/chain/src/keychain/txout_index.rs @@ -123,12 +123,12 @@ pub struct KeychainTxOutIndex { /// keychain -> (descriptor id) map keychains_to_descriptor_ids: BTreeMap, /// descriptor id -> keychain map - descriptor_ids_to_keychains: BTreeMap, + descriptor_ids_to_keychains: HashMap, /// 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>, + descriptor_ids_to_descriptors: HashMap>, /// last revealed indices for each descriptor. last_revealed: HashMap, /// lookahead setting @@ -201,8 +201,8 @@ impl KeychainTxOutIndex { 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,