forked from Public/monero-gui
Merge pull request #3345
6b0cb8d support pruning of new databases (benevanoff)
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "DaemonManager.h"
|
||||
#include "common/util.h"
|
||||
#include <QElapsedTimer>
|
||||
#include <QFile>
|
||||
#include <QMutexLocker>
|
||||
@@ -47,7 +48,7 @@ namespace {
|
||||
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())
|
||||
{
|
||||
@@ -85,6 +86,12 @@ bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const
|
||||
arguments << "--bootstrap-daemon-address" << bootstrapNodeAddress;
|
||||
}
|
||||
|
||||
if (pruneBlockchain) {
|
||||
if (!checkLmdbExists(dataDir)) { // check that DB has not already been created
|
||||
arguments << "--prune-blockchain";
|
||||
}
|
||||
}
|
||||
|
||||
if (noSync) {
|
||||
arguments << "--no-sync";
|
||||
}
|
||||
@@ -323,6 +330,13 @@ QVariantMap DaemonManager::validateDataDir(const QString &dataDir) const
|
||||
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)
|
||||
: QObject(parent)
|
||||
, m_scheduler(this)
|
||||
|
||||
Reference in New Issue
Block a user