File tree Expand file tree Collapse file tree 7 files changed +48
-0
lines changed
nym-vpn-core/crates/nym-vpn-account-controller/src Expand file tree Collapse file tree 7 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,17 @@ impl AccountControllerCommander {
128
128
. map_err ( RequestZkNymError :: internal) ?;
129
129
rx. await . map_err ( RequestZkNymError :: internal) ?
130
130
}
131
+
132
+ pub async fn reset_vpn_api_client (
133
+ & self ,
134
+ vpn_api_client : nym_vpn_api_client:: VpnApiClient ,
135
+ ) -> Result < ( ) , AccountCommandError > {
136
+ let ( tx, rx) = ReturnSender :: new ( ) ;
137
+ self . command_tx
138
+ . send ( AccountCommand :: ResetVpnApiClient ( tx, vpn_api_client) )
139
+ . map_err ( AccountCommandError :: internal) ?;
140
+ rx. await . map_err ( AccountCommandError :: internal) ?
141
+ }
131
142
}
132
143
133
144
// Set of commands used to ensure that the account controller is in the correct state before
Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ pub enum AccountCommand {
98
98
GetZkNymById ( String ) ,
99
99
ConfirmZkNymIdDownloaded ( String ) ,
100
100
GetAvailableTickets ( ReturnSender < AvailableTicketbooks , AccountCommandError > ) ,
101
+ ResetVpnApiClient (
102
+ ReturnSender < ( ) , AccountCommandError > ,
103
+ nym_vpn_api_client:: VpnApiClient ,
104
+ ) ,
101
105
}
102
106
103
107
impl AccountCommand {
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ impl CachedData {
27
27
}
28
28
}
29
29
30
+ pub fn update_vpn_api_client ( & mut self , vpn_api_client : VpnApiClient ) {
31
+ self . vpn_api_client = vpn_api_client;
32
+ }
33
+
30
34
pub async fn get_partial_verification_keys (
31
35
& self ,
32
36
epoch_id : u64 ,
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ impl WaitingRequestZkNymCommandHandler {
85
85
pub ( crate ) async fn max_fails_reached ( & self ) -> bool {
86
86
self . zk_nym_fails_in_a_row . load ( Ordering :: Relaxed ) >= ZK_NYM_MAX_FAILS
87
87
}
88
+
89
+ pub ( crate ) fn update_vpn_api_client ( & mut self , vpn_api_client : VpnApiClient ) {
90
+ self . vpn_api_client = vpn_api_client. clone ( ) ;
91
+ self . cached_data . update_vpn_api_client ( vpn_api_client) ;
92
+ }
88
93
}
89
94
90
95
pub ( crate ) struct RequestZkNymCommandHandler {
Original file line number Diff line number Diff line change @@ -46,6 +46,13 @@ impl WaitingSyncAccountCommandHandler {
46
46
previous_account_summary_response : self . previous_account_summary_response . clone ( ) ,
47
47
}
48
48
}
49
+
50
+ pub ( crate ) fn update_vpn_api_client (
51
+ & mut self ,
52
+ vpn_api_client : nym_vpn_api_client:: VpnApiClient ,
53
+ ) {
54
+ self . vpn_api_client = vpn_api_client;
55
+ }
49
56
}
50
57
51
58
pub ( crate ) struct SyncStateCommandHandler {
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ impl WaitingSyncDeviceCommandHandler {
51
51
previous_devices_response : self . previous_devices_response . clone ( ) ,
52
52
}
53
53
}
54
+
55
+ pub ( crate ) fn update_vpn_api_client (
56
+ & mut self ,
57
+ vpn_api_client : nym_vpn_api_client:: VpnApiClient ,
58
+ ) {
59
+ self . vpn_api_client = vpn_api_client;
60
+ }
54
61
}
55
62
56
63
pub ( crate ) struct SyncDeviceStateCommandHandler {
Original file line number Diff line number Diff line change @@ -734,6 +734,16 @@ where
734
734
let result = self . handle_get_available_tickets ( ) . await ;
735
735
result_tx. send ( result) ;
736
736
}
737
+ AccountCommand :: ResetVpnApiClient ( result_tx, vpn_api_client) => {
738
+ self . vpn_api_client = vpn_api_client. clone ( ) ;
739
+ self . waiting_sync_account_command_handler
740
+ . update_vpn_api_client ( vpn_api_client. clone ( ) ) ;
741
+ self . waiting_sync_device_command_handler
742
+ . update_vpn_api_client ( vpn_api_client. clone ( ) ) ;
743
+ self . waiting_request_zknym_command_handler
744
+ . update_vpn_api_client ( vpn_api_client) ;
745
+ result_tx. send ( Ok ( ( ) ) ) ;
746
+ }
737
747
} ;
738
748
}
739
749
You can’t perform that action at this time.
0 commit comments