mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
More DB support cleanup
Hide DB types from db_types.h - no reason to recompile dependencies
when DB types change.
Also remove lingering in-memory DB references, they've been
obsolete since 9e82b694da
This commit is contained in:
parent
4c7f8ac04f
commit
80344740bd
@ -38,6 +38,14 @@
|
||||
#include "berkeleydb/db_bdb.h"
|
||||
#endif
|
||||
|
||||
static const char *db_types[] = {
|
||||
"lmdb",
|
||||
#ifdef BERKELEY_DB
|
||||
"berkeley",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "blockchain.db"
|
||||
|
||||
@ -46,6 +54,30 @@ using epee::string_tools::pod_to_hex;
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
bool blockchain_valid_db_type(const std::string& db_type)
|
||||
{
|
||||
int i;
|
||||
for (i=0; db_types[i]; i++)
|
||||
{
|
||||
if (db_types[i] == db_type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string blockchain_db_types(const std::string& sep)
|
||||
{
|
||||
int i;
|
||||
std::string ret = "";
|
||||
for (i=0; db_types[i]; i++)
|
||||
{
|
||||
if (i)
|
||||
ret += sep;
|
||||
ret += db_types[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BlockchainDB *new_db(const std::string& db_type)
|
||||
{
|
||||
if (db_type == "lmdb")
|
||||
|
@ -31,9 +31,6 @@
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
const std::unordered_set<std::string> blockchain_db_types =
|
||||
{ "lmdb"
|
||||
};
|
||||
|
||||
bool blockchain_valid_db_type(const std::string& db_type);
|
||||
std::string blockchain_db_types(const std::string& sep);
|
||||
} // namespace cryptonote
|
||||
|
@ -40,17 +40,6 @@
|
||||
namespace po = boost::program_options;
|
||||
using namespace epee;
|
||||
|
||||
std::string join_set_strings(const std::unordered_set<std::string>& db_types_all, const char* delim)
|
||||
{
|
||||
std::string result;
|
||||
std::ostringstream s;
|
||||
std::copy(db_types_all.begin(), db_types_all.end(), std::ostream_iterator<std::string>(s, delim));
|
||||
result = s.str();
|
||||
if (result.length() > 0)
|
||||
result.erase(result.end()-strlen(delim), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
@ -59,10 +48,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
std::string default_db_type = "lmdb";
|
||||
|
||||
std::unordered_set<std::string> db_types_all = cryptonote::blockchain_db_types;
|
||||
db_types_all.insert("memory");
|
||||
|
||||
std::string available_dbs = join_set_strings(db_types_all, ", ");
|
||||
std::string available_dbs = cryptonote::blockchain_db_types(", ");
|
||||
available_dbs = "available: " + available_dbs;
|
||||
|
||||
uint32_t log_level = 0;
|
||||
@ -140,7 +126,7 @@ int main(int argc, char* argv[])
|
||||
m_config_folder = command_line::get_arg(vm, data_dir_arg);
|
||||
|
||||
std::string db_type = command_line::get_arg(vm, arg_database);
|
||||
if (db_types_all.count(db_type) == 0)
|
||||
if (!cryptonote::blockchain_valid_db_type(db_type))
|
||||
{
|
||||
std::cerr << "Invalid database type: " << db_type << std::endl;
|
||||
return 1;
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "blockchain_db/db_types.h"
|
||||
#include "cryptonote_core/cryptonote_core.h"
|
||||
|
||||
#include <lmdb.h> // for db flag arguments
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "bcutil"
|
||||
|
||||
@ -78,18 +76,6 @@ namespace po = boost::program_options;
|
||||
using namespace cryptonote;
|
||||
using namespace epee;
|
||||
|
||||
|
||||
std::string join_set_strings(const std::unordered_set<std::string>& db_types_all, const char* delim)
|
||||
{
|
||||
std::string result;
|
||||
std::ostringstream s;
|
||||
std::copy(db_types_all.begin(), db_types_all.end(), std::ostream_iterator<std::string>(s, delim));
|
||||
result = s.str();
|
||||
if (result.length() > 0)
|
||||
result.erase(result.end()-strlen(delim), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
// db_mode: safe, fast, fastest
|
||||
int get_db_flags_from_mode(const std::string& db_mode)
|
||||
{
|
||||
@ -516,12 +502,8 @@ int main(int argc, char* argv[])
|
||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||
|
||||
std::string default_db_type = "lmdb";
|
||||
std::string default_db_engine_compiled = "blockchain_db";
|
||||
|
||||
std::unordered_set<std::string> db_types_all = cryptonote::blockchain_db_types;
|
||||
db_types_all.insert("memory");
|
||||
|
||||
std::string available_dbs = join_set_strings(db_types_all, ", ");
|
||||
std::string available_dbs = cryptonote::blockchain_db_types(", ");
|
||||
available_dbs = "available: " + available_dbs;
|
||||
|
||||
uint32_t log_level = 0;
|
||||
@ -667,7 +649,6 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
std::string db_type;
|
||||
std::string db_engine_compiled;
|
||||
int db_flags = 0;
|
||||
int res = 0;
|
||||
res = parse_db_arguments(db_arg_str, db_type, db_flags);
|
||||
@ -677,25 +658,12 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (db_types_all.count(db_type) == 0)
|
||||
if (!cryptonote::blockchain_valid_db_type(db_type))
|
||||
{
|
||||
std::cerr << "Invalid database type: " << db_type << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((db_type == "lmdb")
|
||||
#if defined(BERKELEY_DB)
|
||||
|| (db_type == "berkeley")
|
||||
#endif
|
||||
)
|
||||
{
|
||||
db_engine_compiled = "blockchain_db";
|
||||
}
|
||||
else
|
||||
{
|
||||
db_engine_compiled = "memory";
|
||||
}
|
||||
|
||||
MINFO("database: " << db_type);
|
||||
MINFO("database flags: " << db_flags);
|
||||
MINFO("verify: " << std::boolalpha << opt_verify << std::noboolalpha);
|
||||
@ -724,16 +692,6 @@ int main(int argc, char* argv[])
|
||||
// properties to do so. Both ways work, but fake core isn't necessary in that
|
||||
// circumstance.
|
||||
|
||||
if (db_type != "lmdb"
|
||||
#if defined(BERKELEY_DB)
|
||||
&& db_type != "berkeley"
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::cerr << "database type unrecognized" << ENDL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects
|
||||
cryptonote::core core(&pr);
|
||||
core.disable_dns_checkpoints(true);
|
||||
|
@ -96,7 +96,7 @@ namespace command_line
|
||||
, "checkpoints from DNS server will be enforced"
|
||||
, false
|
||||
};
|
||||
std::string arg_db_type_description = "Specify database type, available: " + boost::algorithm::join(cryptonote::blockchain_db_types, ", ");
|
||||
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()
|
||||
|
@ -145,13 +145,10 @@ int main(int argc, char const * argv[])
|
||||
std::string db_type = command_line::get_arg(vm, command_line::arg_db_type);
|
||||
|
||||
// verify that blockchaindb type is valid
|
||||
if(cryptonote::blockchain_db_types.count(db_type) == 0)
|
||||
if(!cryptonote::blockchain_valid_db_type(db_type))
|
||||
{
|
||||
std::cout << "Invalid database type (" << db_type << "), available types are:" << std::endl;
|
||||
for (const auto& type : cryptonote::blockchain_db_types)
|
||||
{
|
||||
std::cout << "\t" << type << std::endl;
|
||||
}
|
||||
std::cout << "Invalid database type (" << db_type << "), available types are: " <<
|
||||
cryptonote::blockchain_db_types(", ") << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user