Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(restart): optional stopping miners for restart application #1060

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,15 @@ async fn set_monerod_config(

#[tauri::command]
async fn restart_application(
should_stop_miners: bool,
_window: tauri::Window,
_state: tauri::State<'_, UniverseAppState>,
state: tauri::State<'_, UniverseAppState>,
app: tauri::AppHandle,
) -> Result<(), String> {
// This restart doesn't need to shutdown all the miners
if should_stop_miners {
stop_all_miners(state.inner().clone(), 5).await?;
}

app.restart();
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialogs/RestartDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function RestartDialog() {
const handleRestart = useCallback(async () => {
try {
console.info('Restarting application.');
await invoke('restart_application');
await invoke('restart_application', { shouldStopMiners: true });
} catch (error) {
Sentry.captureException(error);
console.error('Restart error: ', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const ExternalDependenciesDialog = () => {
const handleRestart = useCallback(async () => {
try {
setIsRestarting(true);
await invoke('restart_application');
await invoke('restart_application', { shouldStopMiners: true });
} catch (e) {
Sentry.captureException(e);
console.error('Error restarting application:', e);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useUpdateStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const useHandleUpdate = () => {
console.info('Installing latest version of Tari Universe');
try {
console.info('Restarting application after update');
await invoke('restart_application');
await invoke('restart_application', { shouldStopMiners: false });
} catch (e) {
Sentry.captureException(e);
console.error('Relaunch error', e);
Expand Down
2 changes: 1 addition & 1 deletion src/types/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ declare module '@tauri-apps/api/tauri' {
): Promise<void>;
function invoke(param: 'set_cpu_mining_enabled', payload: { enabled: boolean }): Promise<void>;
function invoke(param: 'exit_application'): Promise<string>;
function invoke(param: 'restart_application'): Promise<string>;
function invoke(param: 'restart_application', payload: { shouldStopMiners: boolean }): Promise<string>;
function invoke(param: 'set_use_tor', payload: { useTor: boolean }): Promise<void>;
function invoke(param: 'get_transaction_history'): Promise<TransactionInfo[]>;
function invoke(param: 'import_seed_words', payload: { seedWords: string[] }): Promise<void>;
Expand Down
Loading