aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-09-02 11:30:37 +0200
committerRiccardo Spagni <ric@spagni.net>2017-09-02 11:30:38 +0200
commitee1a766861097e6af4acaa35c4dda8b7904dd1e8 (patch)
tree635e49d165241675623df33dba1a4bb2f4010b8b /src/blockchain_db
parentMerge pull request #2364 (diff)
parentRevert "Cleanup test impact of moving blockchain_db_types()" (diff)
downloadmonero-ee1a766861097e6af4acaa35c4dda8b7904dd1e8.tar.xz
Merge pull request #2370
3d19ab70 Revert "Cleanup test impact of moving blockchain_db_types()" (Howard Chu) a95e460c move db specific options to BlockchainDB (moneromooo-monero)
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/blockchain_db.cpp24
-rw-r--r--src/blockchain_db/blockchain_db.h11
2 files changed, 35 insertions, 0 deletions
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp
index 01a59e079..d62a250ff 100644
--- a/src/blockchain_db/blockchain_db.cpp
+++ b/src/blockchain_db/blockchain_db.cpp
@@ -78,6 +78,23 @@ std::string blockchain_db_types(const std::string& sep)
return ret;
}
+std::string arg_db_type_description = "Specify database type, available: " + cryptonote::blockchain_db_types(", ");
+const command_line::arg_descriptor<std::string> arg_db_type = {
+ "db-type"
+, arg_db_type_description.c_str()
+, DEFAULT_DB_TYPE
+};
+const command_line::arg_descriptor<std::string> arg_db_sync_mode = {
+ "db-sync-mode"
+, "Specify sync option, using format [safe|fast|fastest]:[sync|async]:[nblocks_per_sync]."
+, "fast:async:1000"
+};
+const command_line::arg_descriptor<bool> arg_db_salvage = {
+ "db-salvage"
+, "Try to salvage a blockchain database if it seems corrupted"
+, false
+};
+
BlockchainDB *new_db(const std::string& db_type)
{
if (db_type == "lmdb")
@@ -89,6 +106,13 @@ BlockchainDB *new_db(const std::string& db_type)
return NULL;
}
+void BlockchainDB::init_options(boost::program_options::options_description& desc)
+{
+ command_line::add_arg(desc, arg_db_type);
+ command_line::add_arg(desc, arg_db_sync_mode);
+ command_line::add_arg(desc, arg_db_salvage);
+}
+
void BlockchainDB::pop_block()
{
block blk;
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index ad246d85e..85a494ce7 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -33,6 +33,8 @@
#include <list>
#include <string>
#include <exception>
+#include <boost/program_options.hpp>
+#include "common/command_line.h"
#include "crypto/hash.h"
#include "cryptonote_protocol/blobdatatype.h"
#include "cryptonote_basic/cryptonote_basic.h"
@@ -101,6 +103,10 @@ namespace cryptonote
/** a pair of <transaction hash, output index>, typedef for convenience */
typedef std::pair<crypto::hash, uint64_t> tx_out_index;
+extern const command_line::arg_descriptor<std::string> arg_db_type;
+extern const command_line::arg_descriptor<std::string> arg_db_sync_mode;
+extern const command_line::arg_descriptor<bool, false> arg_db_salvage;
+
#pragma pack(push, 1)
/**
@@ -536,6 +542,11 @@ public:
virtual ~BlockchainDB() { };
/**
+ * @brief init command line options
+ */
+ static void init_options(boost::program_options::options_description& desc);
+
+ /**
* @brief reset profiling stats
*/
void reset_stats();