mirror of
https://github.com/monero-project/monero-gui
synced 2024-12-24 02:23:45 +01:00
support pruning of new databases
This commit is contained in:
parent
1f0f21a8e5
commit
6b0cb8dadb
3
main.qml
3
main.qml
@ -724,7 +724,7 @@ ApplicationWindow {
|
|||||||
|
|
||||||
const noSync = appWindow.walletMode === 0;
|
const noSync = appWindow.walletMode === 0;
|
||||||
const bootstrapNodeAddress = persistentSettings.walletMode < 2 ? "auto" : persistentSettings.bootstrapNodeAddress
|
const bootstrapNodeAddress = persistentSettings.walletMode < 2 ? "auto" : persistentSettings.bootstrapNodeAddress
|
||||||
daemonManager.start(flags, persistentSettings.nettype, persistentSettings.blockchainDataDir, bootstrapNodeAddress, noSync);
|
daemonManager.start(flags, persistentSettings.nettype, persistentSettings.blockchainDataDir, bootstrapNodeAddress, noSync, persistentSettings.pruneBlockchain);
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopDaemon(callback, splash){
|
function stopDaemon(callback, splash){
|
||||||
@ -1410,6 +1410,7 @@ ApplicationWindow {
|
|||||||
property bool checkForUpdates: true
|
property bool checkForUpdates: true
|
||||||
property bool autosave: true
|
property bool autosave: true
|
||||||
property int autosaveMinutes: 10
|
property int autosaveMinutes: 10
|
||||||
|
property bool pruneBlockchain: false
|
||||||
|
|
||||||
property bool fiatPriceEnabled: false
|
property bool fiatPriceEnabled: false
|
||||||
property bool fiatPriceToggle: false
|
property bool fiatPriceToggle: false
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "DaemonManager.h"
|
#include "DaemonManager.h"
|
||||||
|
#include "common/util.h"
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
@ -47,7 +48,7 @@ namespace {
|
|||||||
static const int DAEMON_START_TIMEOUT_SECONDS = 120;
|
static const int DAEMON_START_TIMEOUT_SECONDS = 120;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const QString &dataDir, const QString &bootstrapNodeAddress, bool noSync /* = false*/)
|
bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const QString &dataDir, const QString &bootstrapNodeAddress, bool noSync /* = false*/, bool pruneBlockchain /* = false*/)
|
||||||
{
|
{
|
||||||
if (!QFileInfo(m_monerod).isFile())
|
if (!QFileInfo(m_monerod).isFile())
|
||||||
{
|
{
|
||||||
@ -85,6 +86,12 @@ bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const
|
|||||||
arguments << "--bootstrap-daemon-address" << bootstrapNodeAddress;
|
arguments << "--bootstrap-daemon-address" << bootstrapNodeAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pruneBlockchain) {
|
||||||
|
if (!checkLmdbExists(dataDir)) { // check that DB has not already been created
|
||||||
|
arguments << "--prune-blockchain";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (noSync) {
|
if (noSync) {
|
||||||
arguments << "--no-sync";
|
arguments << "--no-sync";
|
||||||
}
|
}
|
||||||
@ -322,6 +329,13 @@ QVariantMap DaemonManager::validateDataDir(const QString &dataDir) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DaemonManager::checkLmdbExists(QString datadir) {
|
||||||
|
if (datadir.isEmpty() || datadir.isNull()) {
|
||||||
|
datadir = QString::fromStdString(tools::get_default_data_dir());
|
||||||
|
}
|
||||||
|
return validateDataDir(datadir).value("lmdbExists").value<bool>();
|
||||||
|
}
|
||||||
|
|
||||||
DaemonManager::DaemonManager(QObject *parent)
|
DaemonManager::DaemonManager(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_scheduler(this)
|
, m_scheduler(this)
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
explicit DaemonManager(QObject *parent = 0);
|
explicit DaemonManager(QObject *parent = 0);
|
||||||
~DaemonManager();
|
~DaemonManager();
|
||||||
|
|
||||||
Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "", bool noSync = false);
|
Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "", bool noSync = false, bool pruneBlockchain = false);
|
||||||
Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback);
|
Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback);
|
||||||
|
|
||||||
Q_INVOKABLE bool noSync() const noexcept;
|
Q_INVOKABLE bool noSync() const noexcept;
|
||||||
@ -57,6 +57,7 @@ public:
|
|||||||
Q_INVOKABLE void sendCommandAsync(const QStringList &cmd, NetworkType::Type nettype, const QJSValue& callback) const;
|
Q_INVOKABLE void sendCommandAsync(const QStringList &cmd, NetworkType::Type nettype, const QJSValue& callback) const;
|
||||||
Q_INVOKABLE void exit();
|
Q_INVOKABLE void exit();
|
||||||
Q_INVOKABLE QVariantMap validateDataDir(const QString &dataDir) const;
|
Q_INVOKABLE QVariantMap validateDataDir(const QString &dataDir) const;
|
||||||
|
Q_INVOKABLE bool checkLmdbExists(QString datadir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -94,6 +94,28 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: pruningOptionRow
|
||||||
|
MoneroComponents.CheckBox {
|
||||||
|
id: pruneBlockchainCheckBox
|
||||||
|
checked: !existingDbWarning.visible ? persistentSettings.pruneBlockchain : false
|
||||||
|
enabled: !existingDbWarning.visible
|
||||||
|
onClicked: {
|
||||||
|
persistentSettings.pruneBlockchain = !persistentSettings.pruneBlockchain
|
||||||
|
this.checked = persistentSettings.pruneBlockchain
|
||||||
|
}
|
||||||
|
text: qsTr("Prune blockchain") + translationManager.emptyString
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: existingDbWarning
|
||||||
|
text: "A blockchain database already exists here. Select a new location to start a pruned node"
|
||||||
|
visible: daemonManager ? daemonManager.checkLmdbExists(blockchainFolder.text) : false
|
||||||
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
|
font.family: MoneroComponents.Style.fontRegular.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
@ -119,6 +119,7 @@ Rectangle {
|
|||||||
|
|
||||||
onMenuClicked: {
|
onMenuClicked: {
|
||||||
if(appWindow.persistentSettings.nettype == 0){
|
if(appWindow.persistentSettings.nettype == 0){
|
||||||
|
appWindow.persistentSettings.pruneBlockchain = true;
|
||||||
applyWalletMode(1, 'wizardModeBootstrap');
|
applyWalletMode(1, 'wizardModeBootstrap');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,6 +140,7 @@ Rectangle {
|
|||||||
imageIcon: "qrc:///images/local-node-full.png"
|
imageIcon: "qrc:///images/local-node-full.png"
|
||||||
|
|
||||||
onMenuClicked: {
|
onMenuClicked: {
|
||||||
|
appWindow.persistentSettings.pruneBlockchain = false; // can be toggled on next page
|
||||||
applyWalletMode(2, 'wizardHome');
|
applyWalletMode(2, 'wizardHome');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user