Skip to content

Commit

Permalink
Requested changes and use ErrorMsg instead of Msg in qt side
Browse files Browse the repository at this point in the history
  • Loading branch information
iFoggz committed Apr 4, 2021
1 parent a692352 commit 10be804
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 18 deletions.
22 changes: 10 additions & 12 deletions src/gridcoin/upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ bool Upgrade::CheckForLatestUpdate(std::string& client_message_out, bool ui_dial

catch (const std::runtime_error& e)
{
LogPrintf("%s: Exception occurred while checking for latest update. (%s)", UpdateCheckType, e.what());

return false;
return error("%s: Exception occurred while checking for latest update. (%s)", __func__, e.what());
}

if (VersionResponse.empty())
{
LogPrintf("%s: No Response from github", UpdateCheckType);
LogPrintf("%s: No Response from github", __func__);

return false;
}
Expand All @@ -99,7 +97,7 @@ bool Upgrade::CheckForLatestUpdate(std::string& client_message_out, bool ui_dial

catch (std::exception& ex)
{
LogPrintf("%s: Exception occurred while parsing json response (%s)", UpdateCheckType, ex.what());
LogPrintf("%s: Exception occurred while parsing json response (%s)", __func__, ex.what());

return false;
}
Expand All @@ -126,7 +124,7 @@ bool Upgrade::CheckForLatestUpdate(std::string& client_message_out, bool ui_dial

if (GithubVersion.size() != 4)
{
LogPrintf("%s: Got malformed version (%s)", UpdateCheckType, GithubReleaseData);
LogPrintf("%s: Got malformed version (%s)", __func__, GithubReleaseData);

return false;
}
Expand All @@ -152,7 +150,7 @@ bool Upgrade::CheckForLatestUpdate(std::string& client_message_out, bool ui_dial
}
catch (std::exception& ex)
{
LogPrintf("%s: Exception occurred checking client version against github version (%s)", UpdateCheckType, ToString(ex.what()));
LogPrintf("%s: Exception occurred checking client version against github version (%s)", __func__, ToString(ex.what()));

return false;
}
Expand Down Expand Up @@ -190,11 +188,11 @@ void Upgrade::SnapshotMain()

if (CheckForLatestUpdate(VersionResponse, false, true))
{
std::cout << _("Unable to perform a Snapshot download as the wallet has detected that a new mandatory version is available for download.") << std::endl;
std::cout << _("Unable to download a snapshot, as the wallet has detected that a new mandatory version is available for install. The mandatory upgrade must be installed before the snapshot can be downloaded and applied.") << std::endl;
std::cout << _("Latest Version github data response:") << std::endl;
std::cout << VersionResponse << std::endl;

throw std::runtime_error("Failed to download snapshot as mandatory client is available for download.");
throw std::runtime_error(_("Failed to download snapshot as mandatory client is available for download."));
}

// Create a thread for snapshot to be downloaded
Expand Down Expand Up @@ -365,7 +363,7 @@ bool Upgrade::VerifySHA256SUM()
}
}

bool Upgrade::CleanupBlockchainData(bool snapshotreq)
bool Upgrade::CleanupBlockchainData()
{
fs::path CleanupPath = GetDataDir();

Expand Down Expand Up @@ -420,7 +418,7 @@ bool Upgrade::CleanupBlockchainData(bool snapshotreq)

catch (fs::filesystem_error &ex)
{
LogPrintf("%s: Exception occurred: %s", snapshotreq ? "Snapshot (CleanupBlockchainData)" : "SyncFromZero (CleanupBlockchainData)", ex.what());
LogPrintf("%s: Exception occurred: %s", __func__, ex.what());

return false;
}
Expand Down Expand Up @@ -594,5 +592,5 @@ void Upgrade::DeleteSnapshot()

bool Upgrade::SyncFromZero()
{
return CleanupBlockchainData(false);
return CleanupBlockchainData();
}
2 changes: 1 addition & 1 deletion src/gridcoin/upgrade.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Upgrade
//!
//! \return Bool on the success of cleanup
//!
static bool CleanupBlockchainData(bool snapshotreq = true);
static bool CleanupBlockchainData();

//!
//! \brief Extracts the snapshot zip file
Expand Down
22 changes: 21 additions & 1 deletion src/gridcoinresearchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool AppInit(int argc, char* argv[])
snapshot.DeleteSnapshot();
}

// Check to see if the user requested to sync from 0 -- We allow on testnet.
// Check to see if the user requested to sync from 0 -- We allow sync from zero on testnet, but not a snapshot download.
if (mapArgs.count("-syncfromzero"))
{
GRC::Upgrade syncfromzero;
Expand All @@ -164,6 +164,26 @@ bool AppInit(int argc, char* argv[])
{
LogPrintf("Syncfromzero: Failed to clean up blockchain data");

std::string inftext = "";
// Little more work then needed but we should be translation friendly imo
inftext.append(_("Sync from zero: Blockchain data removal was a Failure"));
inftext.append("\r\n\r\n");
inftext.append(_("Datadir: "));
inftext.append(GetDataDir().string());
inftext.append("\r\n\r\n");
inftext.append(_("Due to the failure to delete the blockchain data you will be required to manually delete the data before starting your wallet."));
inftext.append("\r\n");
inftext.append(_("Failure to do so will result in undefined behaviour or failure to start wallet."));
inftext.append("\r\n\r\n");
inftext.append(_("You will need to delete the following."));
inftext.append("\r\n\r\n");
inftext.append(_("Files:"));
inftext.append("\r\nblk000*.dat\r\n\r\n");
inftext.append(_("Directories:"));
inftext.append("\r\ntxleveldb\r\naccrual\r\n");

fprintf(stderr, "%s", inftext.c_str());

exit(1);
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,27 @@ int main(int argc, char *argv[])
{
LogPrintf("Syncfromzero: Failed to clean up blockchain data");

std::string inftext = "";
// Little more work then needed but we should be translation friendly imo
inftext.append(_("Sync from zero: Blockchain data removal was a Failure"));
inftext.append("\r\n\r\n");
inftext.append(_("Datadir: "));
inftext.append(GetDataDir().string());
inftext.append("\r\n\r\n");
inftext.append(_("Due to the failure to delete the blockchain data you will be required to manually delete the data before starting your wallet."));
inftext.append("\r\n");
inftext.append(_("Failure to do so will result in undefined behaviour or failure to start wallet."));
inftext.append("\r\n\r\n");
inftext.append(_("You will need to delete the following."));
inftext.append("\r\n\r\n");
inftext.append(_("Files:"));
inftext.append("\r\nblk000*.dat\r\n\r\n");
inftext.append(_("Directories:"));
inftext.append("\r\ntxleveldb\r\naccrual\r\n");

ThreadSafeMessageBox(inftext, _("Gridcoin"), CClientUIInterface::OK | CClientUIInterface::MODAL);
QMessageBox::critical(nullptr, PACKAGE_NAME, QString::fromStdString(inftext));

return EXIT_FAILURE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ void BitcoinGUI::syncfromzeroClicked()

Msg.setIcon(QMessageBox::Question);
Msg.setText(tr("Do you wish to remove blockchain data and sync from zero."));
Msg.setInformativeText(tr("Warning: Once removing blockchain data has been completed you will have to sync from 0 or use snapshot feature."));
Msg.setInformativeText(tr("Warning: After the blockchain data is deleted the wallet will shutdown and when restarted will begin syncing from zero. After restart you may continue syncing from zero or use the snapshot download to download the latest snapshot. Your balance will temporarily show as 0 GRC while syncing."));
Msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
Msg.setDefaultButton(QMessageBox::No);

Expand Down
28 changes: 25 additions & 3 deletions src/qt/upgradeqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
QMessageBox Msg;

Msg.setIcon(QMessageBox::Critical);
Msg.setText(ToQString(_("Unable to perform a Snapshot download as the wallet has detected that a new mandatory version is available for download.")));
Msg.setText(ToQString(_("Unable to download a snapshot, as the wallet has detected that a new mandatory version is available for install. The mandatory upgrade must be installed before the snapshot can be downloaded and applied.")));
Msg.setInformativeText(ToQString(_("Latest Version github data response:\r\n") + VersionResponse));
Msg.setStandardButtons(QMessageBox::Ok);

Expand Down Expand Up @@ -366,9 +366,31 @@ bool UpgradeQt::SyncFromZero(QApplication& SyncfromzeroApp)

Upgrade syncfromzero;

bool fSuccess = syncfromzero.CleanupBlockchainData(false);
bool fSuccess = syncfromzero.CleanupBlockchainData();

Msg(_("Sync from zero: Blockchain data removal was a ") + (fSuccess ? _("Success") : _("Failure")), _("The wallet will now shutdown."), false);
if (fSuccess)
Msg(_("Sync from zero: Blockchain data removal was a Success"), _("The wallet will now shutdown. Please start your wallet to begin sync from zero"), false);

else
{
std::string inftext = "";
// Little more work then needed but we should be translation friendly imo
inftext.append(_("Datadir: "));
inftext.append(GetDataDir().string());
inftext.append("\r\n\r\n");
inftext.append(_("Due to the failure to delete the blockchain data you will be required to manually delete the data before starting your wallet."));
inftext.append("\r\n");
inftext.append(_("Failure to do so will result in undefined behaviour or failure to start wallet."));
inftext.append("\r\n\r\n");
inftext.append(_("You will need to delete the following."));
inftext.append("\r\n\r\n");
inftext.append(_("Files:"));
inftext.append("\r\nblk000*.dat\r\n\r\n");
inftext.append(_("Directories:"));
inftext.append("\r\ntxleveldb\r\naccrual");

ErrorMsg(_("Sync from zero: Blockchain data removal was a Failure"), inftext);
}

return fSuccess;
}

0 comments on commit 10be804

Please sign in to comment.