aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-04-10 16:56:12 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-04-10 16:56:12 +0100
commitc33ffc8e9420e1f530f84d44af611cd21e954e30 (patch)
treec1a7db4b61a26e7fdc258f1a4dcb915f36817be7 /src
parentMerge pull request #799 (diff)
downloadmonero-c33ffc8e9420e1f530f84d44af611cd21e954e30.tar.xz
simplewallet: save fixes in RPC mode
^C when in RPC mode would not save the wallet while it was still refreshing after starting up. Also, save the wallet out of the signal handler. We don't want to call complex stuff in a signal handler.
Diffstat (limited to 'src')
-rw-r--r--src/simplewallet/simplewallet.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index aa571755f..8c445dc21 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -2963,12 +2963,25 @@ int main(int argc, char* argv[])
}
tools::wallet2 wal(testnet,restricted);
+ bool quit = false;
+ tools::signal_handler::install([&wal, &quit](int) {
+ quit = true;
+ wal.stop();
+ });
try
{
LOG_PRINT_L0(sw::tr("Loading wallet..."));
wal.load(wallet_file, password);
wal.init(daemon_address);
wal.refresh();
+ // if we ^C during potentially length load/refresh, there's no server loop yet
+ if (quit)
+ {
+ LOG_PRINT_L0(sw::tr("Storing wallet..."));
+ wal.store();
+ LOG_PRINT_GREEN(sw::tr("Stored ok"), LOG_LEVEL_0);
+ return 1;
+ }
LOG_PRINT_GREEN(sw::tr("Loaded ok"), LOG_LEVEL_0);
}
catch (const std::exception& e)
@@ -2979,10 +2992,8 @@ int main(int argc, char* argv[])
tools::wallet_rpc_server wrpc(wal);
bool r = wrpc.init(vm);
CHECK_AND_ASSERT_MES(r, 1, sw::tr("Failed to initialize wallet rpc server"));
-
tools::signal_handler::install([&wrpc, &wal](int) {
wrpc.send_stop_signal();
- wal.store();
});
LOG_PRINT_L0(sw::tr("Starting wallet rpc server"));
wrpc.run();