Merge pull request #1848
cfa2564a
blockchain: don't try to load an empty block hash set (moneromooo-monero)38359036
blockchain_import: make --log-level understand categories (moneromooo-monero)5fee8561
blockchain_export: make --log-level understand categories (moneromooo-monero)50ebf661
blockchain_import: error out nicely on exceptions (moneromooo-monero)87d57d9c
blockchain_export: error out nicely on exceptions (moneromooo-monero)
This commit is contained in:
commit
ea047307da
|
@ -57,6 +57,8 @@ std::string join_set_strings(const std::unordered_set<std::string>& db_types_all
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||
|
||||
std::string default_db_type = "lmdb";
|
||||
|
@ -80,7 +82,7 @@ int main(int argc, char* argv[])
|
|||
po::options_description desc_cmd_only("Command line options");
|
||||
po::options_description desc_cmd_sett("Command line options and settings options");
|
||||
const command_line::arg_descriptor<std::string> arg_output_file = {"output-file", "Specify output file", "", true};
|
||||
const command_line::arg_descriptor<uint32_t> arg_log_level = {"log-level", "", log_level};
|
||||
const command_line::arg_descriptor<std::string> arg_log_level = {"log-level", "0-4 or categories", ""};
|
||||
const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop};
|
||||
const command_line::arg_descriptor<bool> arg_testnet_on = {
|
||||
"testnet"
|
||||
|
@ -124,11 +126,13 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
log_level = command_line::get_arg(vm, arg_log_level);
|
||||
mlog_configure(mlog_get_default_log_path("monero-blockchain-export.log"), true);
|
||||
if (!vm["log-level"].defaulted())
|
||||
mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
|
||||
else
|
||||
mlog_set_log(std::string(std::to_string(log_level) + ",bcutil:INFO").c_str());
|
||||
block_stop = command_line::get_arg(vm, arg_block_stop);
|
||||
|
||||
mlog_configure(mlog_get_default_log_path("monero-blockchain-export.log"), true);
|
||||
mlog_set_log(std::string(std::to_string(log_level) + ",bcutil:INFO").c_str());
|
||||
LOG_PRINT_L0("Starting...");
|
||||
|
||||
bool opt_testnet = command_line::get_arg(vm, arg_testnet_on);
|
||||
|
@ -226,4 +230,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to export blockchain raw data");
|
||||
LOG_PRINT_L0("Blockchain raw data exported OK");
|
||||
return 0;
|
||||
|
||||
CATCH_ENTRY("Export error", 1);
|
||||
}
|
||||
|
|
|
@ -596,6 +596,8 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||
|
||||
std::string default_db_type = "lmdb";
|
||||
|
@ -622,7 +624,7 @@ int main(int argc, char* argv[])
|
|||
po::options_description desc_cmd_only("Command line options");
|
||||
po::options_description desc_cmd_sett("Command line options and settings options");
|
||||
const command_line::arg_descriptor<std::string> arg_input_file = {"input-file", "Specify input file", "", true};
|
||||
const command_line::arg_descriptor<uint32_t> arg_log_level = {"log-level", "", log_level};
|
||||
const command_line::arg_descriptor<std::string> arg_log_level = {"log-level", "0-4 or categories", ""};
|
||||
const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop};
|
||||
const command_line::arg_descriptor<uint64_t> arg_batch_size = {"batch-size", "", db_batch_size};
|
||||
const command_line::arg_descriptor<uint64_t> arg_pop_blocks = {"pop-blocks", "Remove blocks from end of blockchain", num_blocks};
|
||||
|
@ -682,7 +684,6 @@ int main(int argc, char* argv[])
|
|||
if (! r)
|
||||
return 1;
|
||||
|
||||
log_level = command_line::get_arg(vm, arg_log_level);
|
||||
opt_verify = command_line::get_arg(vm, arg_verify);
|
||||
opt_batch = command_line::get_arg(vm, arg_batch);
|
||||
opt_resume = command_line::get_arg(vm, arg_resume);
|
||||
|
@ -725,7 +726,11 @@ int main(int argc, char* argv[])
|
|||
db_arg_str = command_line::get_arg(vm, arg_database);
|
||||
|
||||
mlog_configure(mlog_get_default_log_path("monero-blockchain-import.log"), true);
|
||||
if (!vm["log-level"].defaulted())
|
||||
mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
|
||||
else
|
||||
mlog_set_log(std::string(std::to_string(log_level) + ",bcutil:INFO").c_str());
|
||||
|
||||
MINFO("Starting...");
|
||||
|
||||
boost::filesystem::path fs_import_file_path;
|
||||
|
@ -852,4 +857,6 @@ int main(int argc, char* argv[])
|
|||
// calls delete on its BlockchainDB derived class' object, which closes its
|
||||
// files.
|
||||
return 0;
|
||||
|
||||
CATCH_ENTRY("Import error", 1);
|
||||
}
|
||||
|
|
|
@ -4016,7 +4016,7 @@ void Blockchain::cancel()
|
|||
static const char expected_block_hashes_hash[] = "23d8a8c73de7b2383c72a016d9a6034e69d62dd48077d1c414e064ceab6daa94";
|
||||
void Blockchain::load_compiled_in_block_hashes()
|
||||
{
|
||||
if (m_fast_sync && get_blocks_dat_start(m_testnet) != nullptr)
|
||||
if (m_fast_sync && get_blocks_dat_start(m_testnet) != nullptr && get_blocks_dat_size(m_testnet) > 0)
|
||||
{
|
||||
MINFO("Loading precomputed blocks (" << get_blocks_dat_size(m_testnet) << " bytes)");
|
||||
|
||||
|
|
Loading…
Reference in New Issue