mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-22 22:18:53 +00:00
move db specific options to BlockchainDB
Avoids common depending on blockchain_db, which can cause link errors.
This commit is contained in:
parent
72b5f37f58
commit
a95e460c71
@ -78,6 +78,23 @@ std::string blockchain_db_types(const std::string& sep)
|
|||||||
return ret;
|
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)
|
BlockchainDB *new_db(const std::string& db_type)
|
||||||
{
|
{
|
||||||
if (db_type == "lmdb")
|
if (db_type == "lmdb")
|
||||||
@ -89,6 +106,13 @@ BlockchainDB *new_db(const std::string& db_type)
|
|||||||
return NULL;
|
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()
|
void BlockchainDB::pop_block()
|
||||||
{
|
{
|
||||||
block blk;
|
block blk;
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
#include "common/command_line.h"
|
||||||
#include "crypto/hash.h"
|
#include "crypto/hash.h"
|
||||||
#include "cryptonote_protocol/blobdatatype.h"
|
#include "cryptonote_protocol/blobdatatype.h"
|
||||||
#include "cryptonote_basic/cryptonote_basic.h"
|
#include "cryptonote_basic/cryptonote_basic.h"
|
||||||
@ -101,6 +103,10 @@ namespace cryptonote
|
|||||||
/** a pair of <transaction hash, output index>, typedef for convenience */
|
/** a pair of <transaction hash, output index>, typedef for convenience */
|
||||||
typedef std::pair<crypto::hash, uint64_t> tx_out_index;
|
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)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -535,6 +541,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~BlockchainDB() { };
|
virtual ~BlockchainDB() { };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief init command line options
|
||||||
|
*/
|
||||||
|
static void init_options(boost::program_options::options_description& desc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief reset profiling stats
|
* @brief reset profiling stats
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <boost/algorithm/string/compare.hpp>
|
#include <boost/algorithm/string/compare.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include "blockchain_db/db_types.h"
|
|
||||||
#include "common/i18n.h"
|
#include "common/i18n.h"
|
||||||
#include "cryptonote_config.h"
|
#include "cryptonote_config.h"
|
||||||
#include "string_tools.h"
|
#include "string_tools.h"
|
||||||
@ -96,22 +95,6 @@ namespace command_line
|
|||||||
, "checkpoints from DNS server will be enforced"
|
, "checkpoints from DNS server will be enforced"
|
||||||
, false
|
, false
|
||||||
};
|
};
|
||||||
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 arg_descriptor<bool> arg_db_salvage = {
|
|
||||||
"db-salvage"
|
|
||||||
, "Try to salvage a blockchain database if it seems corrupted"
|
|
||||||
, false
|
|
||||||
};
|
|
||||||
const command_line::arg_descriptor<uint64_t> arg_fast_block_sync = {
|
const command_line::arg_descriptor<uint64_t> arg_fast_block_sync = {
|
||||||
"fast-block-sync"
|
"fast-block-sync"
|
||||||
, "Sync up most of the way by using embedded, known block hashes."
|
, "Sync up most of the way by using embedded, known block hashes."
|
||||||
|
@ -212,9 +212,6 @@ namespace command_line
|
|||||||
extern const arg_descriptor<int> arg_test_dbg_lock_sleep;
|
extern const arg_descriptor<int> arg_test_dbg_lock_sleep;
|
||||||
extern const arg_descriptor<bool, false> arg_testnet_on;
|
extern const arg_descriptor<bool, false> arg_testnet_on;
|
||||||
extern const arg_descriptor<bool> arg_dns_checkpoints;
|
extern const arg_descriptor<bool> arg_dns_checkpoints;
|
||||||
extern const arg_descriptor<std::string> arg_db_type;
|
|
||||||
extern const arg_descriptor<std::string> arg_db_sync_mode;
|
|
||||||
extern const arg_descriptor<bool, false> arg_db_salvage;
|
|
||||||
extern const arg_descriptor<uint64_t> arg_fast_block_sync;
|
extern const arg_descriptor<uint64_t> arg_fast_block_sync;
|
||||||
extern const arg_descriptor<uint64_t> arg_prep_blocks_threads;
|
extern const arg_descriptor<uint64_t> arg_prep_blocks_threads;
|
||||||
extern const arg_descriptor<uint64_t> arg_show_time_stats;
|
extern const arg_descriptor<uint64_t> arg_show_time_stats;
|
||||||
|
@ -156,11 +156,8 @@ namespace cryptonote
|
|||||||
|
|
||||||
command_line::add_arg(desc, command_line::arg_testnet_on);
|
command_line::add_arg(desc, command_line::arg_testnet_on);
|
||||||
command_line::add_arg(desc, command_line::arg_dns_checkpoints);
|
command_line::add_arg(desc, command_line::arg_dns_checkpoints);
|
||||||
command_line::add_arg(desc, command_line::arg_db_type);
|
|
||||||
command_line::add_arg(desc, command_line::arg_prep_blocks_threads);
|
command_line::add_arg(desc, command_line::arg_prep_blocks_threads);
|
||||||
command_line::add_arg(desc, command_line::arg_fast_block_sync);
|
command_line::add_arg(desc, command_line::arg_fast_block_sync);
|
||||||
command_line::add_arg(desc, command_line::arg_db_sync_mode);
|
|
||||||
command_line::add_arg(desc, command_line::arg_db_salvage);
|
|
||||||
command_line::add_arg(desc, command_line::arg_show_time_stats);
|
command_line::add_arg(desc, command_line::arg_show_time_stats);
|
||||||
command_line::add_arg(desc, command_line::arg_block_sync_size);
|
command_line::add_arg(desc, command_line::arg_block_sync_size);
|
||||||
command_line::add_arg(desc, command_line::arg_check_updates);
|
command_line::add_arg(desc, command_line::arg_check_updates);
|
||||||
@ -170,6 +167,7 @@ namespace cryptonote
|
|||||||
command_line::add_arg(desc, nodetool::arg_p2p_bind_port, false);
|
command_line::add_arg(desc, nodetool::arg_p2p_bind_port, false);
|
||||||
|
|
||||||
miner::init_options(desc);
|
miner::init_options(desc);
|
||||||
|
BlockchainDB::init_options(desc);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::handle_command_line(const boost::program_options::variables_map& vm)
|
bool core::handle_command_line(const boost::program_options::variables_map& vm)
|
||||||
@ -279,9 +277,9 @@ namespace cryptonote
|
|||||||
m_config_folder_mempool = m_config_folder_mempool + "/" + m_port;
|
m_config_folder_mempool = m_config_folder_mempool + "/" + m_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string db_type = command_line::get_arg(vm, command_line::arg_db_type);
|
std::string db_type = command_line::get_arg(vm, cryptonote::arg_db_type);
|
||||||
std::string db_sync_mode = command_line::get_arg(vm, command_line::arg_db_sync_mode);
|
std::string db_sync_mode = command_line::get_arg(vm, cryptonote::arg_db_sync_mode);
|
||||||
bool db_salvage = command_line::get_arg(vm, command_line::arg_db_salvage) != 0;
|
bool db_salvage = command_line::get_arg(vm, cryptonote::arg_db_salvage) != 0;
|
||||||
bool fast_sync = command_line::get_arg(vm, command_line::arg_fast_block_sync) != 0;
|
bool fast_sync = command_line::get_arg(vm, command_line::arg_fast_block_sync) != 0;
|
||||||
uint64_t blocks_threads = command_line::get_arg(vm, command_line::arg_prep_blocks_threads);
|
uint64_t blocks_threads = command_line::get_arg(vm, command_line::arg_prep_blocks_threads);
|
||||||
std::string check_updates_string = command_line::get_arg(vm, command_line::arg_check_updates);
|
std::string check_updates_string = command_line::get_arg(vm, command_line::arg_check_updates);
|
||||||
|
@ -142,7 +142,7 @@ int main(int argc, char const * argv[])
|
|||||||
|
|
||||||
epee::debug::g_test_dbg_lock_sleep() = command_line::get_arg(vm, command_line::arg_test_dbg_lock_sleep);
|
epee::debug::g_test_dbg_lock_sleep() = command_line::get_arg(vm, command_line::arg_test_dbg_lock_sleep);
|
||||||
|
|
||||||
std::string db_type = command_line::get_arg(vm, command_line::arg_db_type);
|
std::string db_type = command_line::get_arg(vm, cryptonote::arg_db_type);
|
||||||
|
|
||||||
// verify that blockchaindb type is valid
|
// verify that blockchaindb type is valid
|
||||||
if(!cryptonote::blockchain_valid_db_type(db_type))
|
if(!cryptonote::blockchain_valid_db_type(db_type))
|
||||||
|
Loading…
Reference in New Issue
Block a user