@@ -219,12 +219,12 @@ pub struct KeychainTxOutIndex<K> {
219
219
// a keychain, we return it with the highest-ranked keychain with it. We rank keychains by
220
220
// `Ord`, therefore the keychain set is a `BTreeSet`. The earliest keychain variant (according
221
221
// to `Ord`) has precedence.
222
- descriptor_ids_to_keychains : HashMap < DescriptorId , BTreeSet < K > > ,
222
+ keychains : HashMap < DescriptorId , BTreeSet < K > > ,
223
223
// descriptor_id -> descriptor map
224
224
// This is a "monotone" map, meaning that its size keeps growing, i.e., we never delete
225
225
// descriptors from it. This is useful for revealing spks for descriptors that don't have
226
226
// keychains associated.
227
- descriptor_ids_to_descriptors : BTreeMap < DescriptorId , Descriptor < DescriptorPublicKey > > ,
227
+ descriptors : BTreeMap < DescriptorId , Descriptor < DescriptorPublicKey > > ,
228
228
// last revealed indexes
229
229
last_revealed : BTreeMap < DescriptorId , u32 > ,
230
230
// lookahead settings for each keychain
@@ -246,7 +246,7 @@ impl<K: Clone + Ord + Debug> Indexer for KeychainTxOutIndex<K> {
246
246
// We want to reveal spks for descriptors that aren't tracked by any keychain, and
247
247
// so we call reveal with descriptor_id
248
248
let desc = self
249
- . descriptor_ids_to_descriptors
249
+ . descriptors
250
250
. get ( & descriptor_id)
251
251
. cloned ( )
252
252
. expect ( "descriptors are added monotonically, scanned txout descriptor ids must have associated descriptors" ) ;
@@ -299,8 +299,8 @@ impl<K> KeychainTxOutIndex<K> {
299
299
Self {
300
300
inner : SpkTxOutIndex :: default ( ) ,
301
301
keychains_to_descriptor_ids : BTreeMap :: new ( ) ,
302
- descriptor_ids_to_keychains : HashMap :: new ( ) ,
303
- descriptor_ids_to_descriptors : BTreeMap :: new ( ) ,
302
+ keychains : HashMap :: new ( ) ,
303
+ descriptors : BTreeMap :: new ( ) ,
304
304
last_revealed : BTreeMap :: new ( ) ,
305
305
lookahead,
306
306
}
@@ -311,7 +311,7 @@ impl<K> KeychainTxOutIndex<K> {
311
311
impl < K : Clone + Ord + Debug > KeychainTxOutIndex < K > {
312
312
/// Get the highest-ranked keychain that is currently associated with the given `desc_id`.
313
313
fn keychain_of_desc_id ( & self , desc_id : & DescriptorId ) -> Option < & K > {
314
- let keychains = self . descriptor_ids_to_keychains . get ( desc_id) ?;
314
+ let keychains = self . keychains . get ( desc_id) ?;
315
315
keychains. iter ( ) . next ( )
316
316
}
317
317
@@ -473,7 +473,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
473
473
{
474
474
self . keychains_to_descriptor_ids . iter ( ) . map ( |( k, desc_id) | {
475
475
let descriptor = self
476
- . descriptor_ids_to_descriptors
476
+ . descriptors
477
477
. get ( desc_id)
478
478
. expect ( "descriptor id cannot be associated with keychain without descriptor" ) ;
479
479
( k, descriptor)
@@ -510,19 +510,18 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
510
510
// is designed to track one descriptor per keychain (however different keychains can
511
511
// share the same descriptor)
512
512
let _is_keychain_removed = self
513
- . descriptor_ids_to_keychains
513
+ . keychains
514
514
. get_mut ( & old_desc_id)
515
515
. expect ( "we must have already inserted this descriptor" )
516
516
. remove ( & keychain) ;
517
517
debug_assert ! ( _is_keychain_removed) ;
518
518
}
519
519
520
- self . descriptor_ids_to_keychains
520
+ self . keychains
521
521
. entry ( desc_id)
522
522
. or_default ( )
523
523
. insert ( keychain. clone ( ) ) ;
524
- self . descriptor_ids_to_descriptors
525
- . insert ( desc_id, descriptor. clone ( ) ) ;
524
+ self . descriptors . insert ( desc_id, descriptor. clone ( ) ) ;
526
525
self . replenish_lookahead ( & keychain, self . lookahead ) ;
527
526
528
527
changeset
@@ -537,7 +536,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
537
536
self . keychains_to_descriptor_ids
538
537
. get ( keychain)
539
538
. map ( |desc_id| {
540
- self . descriptor_ids_to_descriptors
539
+ self . descriptors
541
540
. get ( desc_id)
542
541
. expect ( "descriptor id cannot be associated with keychain without descriptor" )
543
542
} )
@@ -571,7 +570,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
571
570
let descriptor_id = self . keychains_to_descriptor_ids . get ( keychain) . copied ( ) ;
572
571
if let Some ( descriptor_id) = descriptor_id {
573
572
let descriptor = self
574
- . descriptor_ids_to_descriptors
573
+ . descriptors
575
574
. get ( & descriptor_id)
576
575
. expect ( "descriptor id cannot be associated with keychain without descriptor" ) ;
577
576
@@ -606,7 +605,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
606
605
) -> Option < SpkIterator < Descriptor < DescriptorPublicKey > > > {
607
606
let desc_id = self . keychains_to_descriptor_ids . get ( keychain) ?;
608
607
let desc = self
609
- . descriptor_ids_to_descriptors
608
+ . descriptors
610
609
. get ( desc_id)
611
610
. cloned ( )
612
611
. expect ( "descriptor id cannot be associated with keychain without descriptor" ) ;
@@ -620,11 +619,10 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
620
619
self . keychains_to_descriptor_ids
621
620
. iter ( )
622
621
. map ( |( k, desc_id) | {
623
- let desc = self
624
- . descriptor_ids_to_descriptors
625
- . get ( desc_id)
626
- . cloned ( )
627
- . expect ( "descriptor id cannot be associated with keychain without descriptor" ) ;
622
+ let desc =
623
+ self . descriptors . get ( desc_id) . cloned ( ) . expect (
624
+ "descriptor id cannot be associated with keychain without descriptor" ,
625
+ ) ;
628
626
( k. clone ( ) , SpkIterator :: new ( desc) )
629
627
} )
630
628
. collect ( )
@@ -712,7 +710,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
712
710
pub fn next_index ( & self , keychain : & K ) -> Option < ( u32 , bool ) > {
713
711
let descriptor_id = self . keychains_to_descriptor_ids . get ( keychain) ?;
714
712
let descriptor = self
715
- . descriptor_ids_to_descriptors
713
+ . descriptors
716
714
. get ( descriptor_id)
717
715
. expect ( "descriptor id cannot be associated with keychain without descriptor" ) ;
718
716
Some ( self . next_index_with_descriptor ( descriptor) )
@@ -872,7 +870,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
872
870
None => return ( None , ChangeSet :: default ( ) ) ,
873
871
} ;
874
872
let desc = self
875
- . descriptor_ids_to_descriptors
873
+ . descriptors
876
874
. get ( descriptor_id)
877
875
. cloned ( )
878
876
. expect ( "descriptors are added monotonically, scanned txout descriptor ids must have associated descriptors" ) ;
@@ -901,7 +899,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
901
899
}
902
900
} ;
903
901
let descriptor = self
904
- . descriptor_ids_to_descriptors
902
+ . descriptors
905
903
. get ( & descriptor_id)
906
904
. expect ( "descriptor id cannot be associated with keychain without descriptor" ) ;
907
905
let ( next_index, _) = self . next_index_with_descriptor ( descriptor) ;
0 commit comments