From fd1f4bf628129e2dfce3de6dbdfc135ad4cadffa Mon Sep 17 00:00:00 2001 From: stoffu Date: Mon, 22 Jan 2018 18:43:39 +0900 Subject: [PATCH] Bootstrap daemon (requires #3165) --- main.qml | 3 ++- pages/Settings.qml | 23 +++++++++++++++++++++++ src/daemon/DaemonManager.cpp | 7 ++++++- src/daemon/DaemonManager.h | 2 +- wizard/WizardDaemonSettings.qml | 14 ++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/main.qml b/main.qml index 9ce7d58e..150a3a16 100644 --- a/main.qml +++ b/main.qml @@ -478,7 +478,7 @@ ApplicationWindow { currentWallet.pauseRefresh(); appWindow.showProcessingSplash(qsTr("Waiting for daemon to start...")) - daemonManager.start(flags, persistentSettings.testnet, persistentSettings.blockchainDataDir); + daemonManager.start(flags, persistentSettings.testnet, persistentSettings.blockchainDataDir, persistentSettings.bootstrapNodeAddress); persistentSettings.daemonFlags = flags } @@ -1006,6 +1006,7 @@ ApplicationWindow { property string blockchainDataDir: "" property bool useRemoteNode: false property string remoteNodeAddress: "" + property string bootstrapNodeAddress: "" } // Information dialog diff --git a/pages/Settings.qml b/pages/Settings.qml index c4df7288..3f933760 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -260,6 +260,9 @@ Rectangle { releasedColor: "#FF6C3C" pressedColor: "#FF4304" onClicked: { + // Update bootstrap daemon address + persistentSettings.bootstrapNodeAddress = bootstrapNodeEdit.daemonAddrText ? bootstrapNodeEdit.getAddress() : ""; + // Set current daemon address to local appWindow.currentDaemonAddress = appWindow.localDaemonAddress appWindow.startDaemon(daemonFlags.text) @@ -374,6 +377,26 @@ Rectangle { } } + RowLayout { + visible: persistentSettings.startLocalNode + ColumnLayout { + Label { + color: "#4A4949" + text: qsTr("Bootstrap node (leave blank if not wanted)") + translationManager.emptyString + } + RemoteNodeEdit { + id: bootstrapNodeEdit + Layout.minimumWidth: 100 * scaleRatio + daemonAddrText: persistentSettings.bootstrapNodeAddress.split(":")[0].trim() + daemonPortText: (persistentSettings.bootstrapNodeAddress.split(":")[1].trim() == "") ? "18081" : persistentSettings.bootstrapNodeAddress.split(":")[1] + onEditingFinished: { + persistentSettings.bootstrapNodeAddress = daemonAddrText ? bootstrapNodeEdit.getAddress() : ""; + console.log("setting bootstrap node to " + persistentSettings.bootstrapNodeAddress) + } + } + } + } + RowLayout { visible: persistentSettings.useRemoteNode ColumnLayout { diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 58002014..93e7a9a8 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -32,7 +32,7 @@ DaemonManager *DaemonManager::instance(const QStringList *args) return m_instance; } -bool DaemonManager::start(const QString &flags, bool testnet, const QString &dataDir) +bool DaemonManager::start(const QString &flags, bool testnet, const QString &dataDir, const QString &bootstrapNodeAddress) { // prepare command line arguments and pass to monerod QStringList arguments; @@ -67,6 +67,11 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat arguments << dataDir; } + // Bootstrap node address + if(!bootstrapNodeAddress.isEmpty()) { + arguments << "--bootstrap-daemon-address" << bootstrapNodeAddress; + } + arguments << "--check-updates" << "disabled"; diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 2b9c8b84..d081ad7d 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -14,7 +14,7 @@ public: static DaemonManager * instance(const QStringList *args); - Q_INVOKABLE bool start(const QString &flags, bool testnet, const QString &dataDir = ""); + Q_INVOKABLE bool start(const QString &flags, bool testnet, const QString &dataDir = "", const QString &bootstrapNodeAddress = ""); Q_INVOKABLE bool stop(bool testnet); // return true if daemon process is started diff --git a/wizard/WizardDaemonSettings.qml b/wizard/WizardDaemonSettings.qml index 8634f652..953bb21d 100644 --- a/wizard/WizardDaemonSettings.qml +++ b/wizard/WizardDaemonSettings.qml @@ -55,6 +55,7 @@ ColumnLayout { function onPageClosed(settingsObject) { appWindow.persistentSettings.useRemoteNode = remoteNode.checked appWindow.persistentSettings.remoteNodeAddress = remoteNodeEdit.getAddress(); + appWindow.persistentSettings.bootstrapNodeAddress = bootstrapNodeEdit.daemonAddrText ? bootstrapNodeEdit.getAddress() : ""; return true } @@ -165,6 +166,19 @@ ColumnLayout { } } + Label { + Layout.fillWidth: true + Layout.topMargin: 20 * scaleRatio + fontSize: 14 * scaleRatio + text: qsTr("Bootstrap node (leave blank if not wanted)") + translationManager.emptyString + } + RemoteNodeEdit { + Layout.minimumWidth: 300 * scaleRatio + opacity: localNode.checked + id: bootstrapNodeEdit + daemonAddrText: persistentSettings.bootstrapNodeAddress.split(":")[0].trim() + daemonPortText: (persistentSettings.bootstrapNodeAddress.split(":")[1].trim() == "") ? "18081" : persistentSettings.bootstrapNodeAddress.split(":")[1] + } } RowLayout {