@@ -38,7 +38,7 @@ pub enum AccountsAction {
38
38
pub struct AccountRelayData {
39
39
filter : Filter ,
40
40
subrmtid : Option < RmtId > ,
41
- local : BTreeSet < RelaySpec > , // used locally but not advertised
41
+ _local : BTreeSet < RelaySpec > , // used locally but not advertised
42
42
advertised : Arc < Mutex < BTreeSet < RelaySpec > > > , // advertised via NIP-65
43
43
}
44
44
@@ -82,7 +82,7 @@ impl AccountRelayData {
82
82
AccountRelayData {
83
83
filter,
84
84
subrmtid : None ,
85
- local : BTreeSet :: new ( ) ,
85
+ _local : BTreeSet :: new ( ) ,
86
86
advertised : Arc :: new ( Mutex :: new ( relays. into_iter ( ) . collect ( ) ) ) ,
87
87
}
88
88
}
@@ -343,13 +343,13 @@ pub struct Accounts {
343
343
accounts : Vec < UserAccount > ,
344
344
key_store : KeyStorageType ,
345
345
account_data : BTreeMap < [ u8 ; 32 ] , AccountData > ,
346
- forced_relays : BTreeSet < RelaySpec > ,
346
+ _forced_relays : BTreeSet < RelaySpec > ,
347
347
bootstrap_relays : BTreeSet < RelaySpec > ,
348
348
needs_relay_config : bool ,
349
349
}
350
350
351
351
impl Accounts {
352
- pub fn new ( key_store : KeyStorageType , forced_relays : Vec < String > ) -> Self {
352
+ pub fn new ( key_store : KeyStorageType , _forced_relays : Vec < String > ) -> Self {
353
353
let accounts = if let KeyStorageResponse :: ReceivedResult ( res) = key_store. get_keys ( ) {
354
354
res. unwrap_or_default ( )
355
355
} else {
@@ -358,7 +358,7 @@ impl Accounts {
358
358
359
359
let currently_selected_account = get_selected_index ( & accounts, & key_store) ;
360
360
let account_data = BTreeMap :: new ( ) ;
361
- let forced_relays : BTreeSet < RelaySpec > = forced_relays
361
+ let _forced_relays : BTreeSet < RelaySpec > = _forced_relays
362
362
. into_iter ( )
363
363
. map ( |u| RelaySpec :: new ( AccountRelayData :: canonicalize_url ( & u) , false , false ) )
364
364
. collect ( ) ;
@@ -379,7 +379,7 @@ impl Accounts {
379
379
accounts,
380
380
key_store,
381
381
account_data,
382
- forced_relays ,
382
+ _forced_relays ,
383
383
bootstrap_relays,
384
384
needs_relay_config : true ,
385
385
}
@@ -592,61 +592,6 @@ impl Accounts {
592
592
self . account_data . remove ( pubkey) ;
593
593
}
594
594
595
- fn update_relay_configuration (
596
- & mut self ,
597
- pool : & mut RelayPool ,
598
- wakeup : impl Fn ( ) + Send + Sync + Clone + ' static ,
599
- ) {
600
- debug ! (
601
- "updating relay configuration for currently selected {:?}" ,
602
- self . currently_selected_account
603
- . map( |i| hex:: encode( self . accounts. get( i) . unwrap( ) . pubkey. bytes( ) ) )
604
- ) ;
605
-
606
- // If forced relays are set use them only
607
- let mut desired_relays = self . forced_relays . clone ( ) ;
608
-
609
- // Compose the desired relay lists from the selected account
610
- if desired_relays. is_empty ( ) {
611
- if let Some ( data) = self . get_selected_account_data ( ) {
612
- desired_relays. extend ( data. relay . local . iter ( ) . cloned ( ) ) ;
613
- desired_relays. extend ( data. relay . advertised . lock ( ) . unwrap ( ) . iter ( ) . cloned ( ) ) ;
614
- }
615
- }
616
-
617
- // If no relays are specified at this point use the bootstrap list
618
- if desired_relays. is_empty ( ) {
619
- desired_relays = self . bootstrap_relays . clone ( ) ;
620
- }
621
-
622
- debug ! ( "current relays: {:?}" , pool. urls( ) ) ;
623
- debug ! ( "desired relays: {:?}" , desired_relays) ;
624
-
625
- let pool_specs = pool
626
- . urls ( )
627
- . iter ( )
628
- . map ( |url| RelaySpec :: new ( url. clone ( ) , false , false ) )
629
- . collect ( ) ;
630
- let add: BTreeSet < RelaySpec > = desired_relays. difference ( & pool_specs) . cloned ( ) . collect ( ) ;
631
- let mut sub: BTreeSet < RelaySpec > =
632
- pool_specs. difference ( & desired_relays) . cloned ( ) . collect ( ) ;
633
- if !add. is_empty ( ) {
634
- debug ! ( "configuring added relays: {:?}" , add) ;
635
- let _ = pool. add_urls ( add. iter ( ) . map ( |r| r. url . clone ( ) ) . collect ( ) , wakeup) ;
636
- }
637
- if !sub. is_empty ( ) {
638
- // certain relays are persistent like the multicast relay,
639
- // although we should probably have a way to explicitly
640
- // disable it
641
- sub. remove ( & RelaySpec :: new ( "multicast" , false , false ) ) ;
642
-
643
- debug ! ( "removing unwanted relays: {:?}" , sub) ;
644
- pool. remove_urls ( & sub. iter ( ) . map ( |r| r. url . clone ( ) ) . collect ( ) ) ;
645
- }
646
-
647
- debug ! ( "current relays: {:?}" , pool. urls( ) ) ;
648
- }
649
-
650
595
fn get_combined_relays (
651
596
& self ,
652
597
data_option : Option < & AccountData > ,
@@ -688,18 +633,10 @@ impl Accounts {
688
633
self . get_combined_relays ( self . get_selected_account_data ( ) , |_| true )
689
634
}
690
635
691
- pub fn update ( & mut self , subman : & mut SubMan , ctx : & egui:: Context ) {
636
+ pub fn update ( & mut self , subman : & mut SubMan , _ctx : & egui:: Context ) {
692
637
// IMPORTANT - This function is called in the UI update loop,
693
638
// make sure it is fast when idle
694
639
695
- // On the initial update the relays need config even if nothing changes below
696
- let mut need_reconfig = self . needs_relay_config ;
697
-
698
- let ctx2 = ctx. clone ( ) ;
699
- let wakeup = move || {
700
- ctx2. request_repaint ( ) ;
701
- } ;
702
-
703
640
// Do we need to deactivate any existing account subs?
704
641
for ( ndx, account) in self . accounts . iter ( ) . enumerate ( ) {
705
642
if Some ( ndx) != self . currently_selected_account {
@@ -718,23 +655,14 @@ impl Accounts {
718
655
}
719
656
720
657
let ndb = subman. ndb ( ) . clone ( ) ;
721
- let pool = subman. pool ( ) ;
722
658
723
659
// Were any accounts added or removed?
724
660
let ( added, removed) = self . delta_accounts ( ) ;
725
661
for pk in added {
726
662
self . handle_added_account ( & ndb, & pk) ;
727
- need_reconfig = true ;
728
663
}
729
664
for pk in removed {
730
665
self . handle_removed_account ( & pk) ;
731
- need_reconfig = true ;
732
- }
733
-
734
- // If needed, update the relay configuration
735
- if need_reconfig {
736
- self . update_relay_configuration ( pool, wakeup) ;
737
- self . needs_relay_config = false ;
738
666
}
739
667
740
668
// Do we need to activate account subs?
0 commit comments