aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_utilities')
-rw-r--r--src/blockchain_utilities/CMakeLists.txt3
-rw-r--r--src/blockchain_utilities/blockchain_export.cpp9
-rw-r--r--src/blockchain_utilities/blockchain_import.cpp111
-rw-r--r--src/blockchain_utilities/blocksdat_file.cpp20
-rw-r--r--src/blockchain_utilities/bootstrap_file.cpp68
-rw-r--r--src/blockchain_utilities/cn_deserialize.cpp8
6 files changed, 115 insertions, 104 deletions
diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt
index a9ece98fc..b26fe04cc 100644
--- a/src/blockchain_utilities/CMakeLists.txt
+++ b/src/blockchain_utilities/CMakeLists.txt
@@ -72,6 +72,7 @@ target_link_libraries(blockchain_import
cryptonote_core
blockchain_db
p2p
+ epee
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
@@ -98,6 +99,7 @@ target_link_libraries(blockchain_export
cryptonote_core
blockchain_db
p2p
+ epee
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
@@ -118,6 +120,7 @@ target_link_libraries(cn_deserialize
LINK_PRIVATE
cryptonote_core
p2p
+ epee
${CMAKE_THREAD_LIBS_INIT})
add_dependencies(cn_deserialize
diff --git a/src/blockchain_utilities/blockchain_export.cpp b/src/blockchain_utilities/blockchain_export.cpp
index 231bea337..952855fa5 100644
--- a/src/blockchain_utilities/blockchain_export.cpp
+++ b/src/blockchain_utilities/blockchain_export.cpp
@@ -38,8 +38,11 @@
#include "blockchain_db/db_types.h"
#include "version.h"
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "bcutil"
+
namespace po = boost::program_options;
-using namespace epee; // log_space
+using namespace epee;
std::string join_set_strings(const std::unordered_set<std::string>& db_types_all, const char* delim)
{
@@ -122,10 +125,8 @@ int main(int argc, char* argv[])
log_level = command_line::get_arg(vm, arg_log_level);
block_stop = command_line::get_arg(vm, arg_block_stop);
- log_space::get_set_log_detalisation_level(true, log_level);
- log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
+ mlog_configure("", true);
LOG_PRINT_L0("Starting...");
- LOG_PRINT_L0("Setting log level = " << log_level);
bool opt_testnet = command_line::get_arg(vm, arg_testnet_on);
bool opt_blocks_dat = command_line::get_arg(vm, arg_blocks_dat);
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp
index 43e2f8b45..dc8d2d8fd 100644
--- a/src/blockchain_utilities/blockchain_import.cpp
+++ b/src/blockchain_utilities/blockchain_import.cpp
@@ -44,6 +44,9 @@
#include "fake_core.h"
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "bcutil"
+
namespace
{
// CONFIG
@@ -132,7 +135,7 @@ int parse_db_arguments(const std::string& db_arg_str, std::string& db_type, int&
#if !defined(BERKELEY_DB)
if (db_type == "berkeley")
{
- LOG_ERROR("BerkeleyDB support disabled.");
+ MFATAL("BerkeleyDB support disabled.");
return false;
}
#endif
@@ -163,7 +166,7 @@ int parse_db_arguments(const std::string& db_arg_str, std::string& db_type, int&
continue;
if (db_type == "lmdb")
{
- LOG_PRINT_L1("LMDB flag: " << it);
+ MINFO("LMDB flag: " << it);
if (it == "nosync")
db_flags |= MDB_NOSYNC;
else if (it == "nometasync")
@@ -211,7 +214,7 @@ int pop_blocks(FakeCore& simple_core, int num_blocks)
if (simple_core.support_batch)
use_batch = true;
else
- LOG_PRINT_L0("WARNING: batch transactions enabled but unsupported or unnecessary for this database type - ignoring");
+ MWARNING("WARNING: batch transactions enabled but unsupported or unnecessary for this database type - ignoring");
}
if (use_batch)
@@ -260,14 +263,14 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
boost::system::error_code ec;
if (!boost::filesystem::exists(fs_import_file_path, ec))
{
- LOG_PRINT_L0("bootstrap file not found: " << fs_import_file_path);
+ MFATAL("bootstrap file not found: " << fs_import_file_path);
return false;
}
BootstrapFile bootstrap;
// BootstrapFile bootstrap(import_file_path);
uint64_t total_source_blocks = bootstrap.count_blocks(import_file_path);
- LOG_PRINT_L0("bootstrap file last block number: " << total_source_blocks-1 << " (zero-based height) total blocks: " << total_source_blocks);
+ MINFO("bootstrap file last block number: " << total_source_blocks-1 << " (zero-based height) total blocks: " << total_source_blocks);
std::cout << ENDL;
std::cout << "Preparing to read blocks..." << ENDL;
@@ -280,7 +283,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
uint64_t num_imported = 0;
if (import_file.fail())
{
- LOG_PRINT_L0("import_file.open() fail");
+ MFATAL("import_file.open() fail");
return false;
}
@@ -309,7 +312,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
// These are what we'll try to use, and they don't have to be a determination
// from source and destination blockchains, but those are the defaults.
- LOG_PRINT_L0("start block: " << start_height << " stop block: " <<
+ MINFO("start block: " << start_height << " stop block: " <<
block_stop);
bool use_batch = false;
@@ -318,13 +321,13 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
if (simple_core.support_batch)
use_batch = true;
else
- LOG_PRINT_L0("WARNING: batch transactions enabled but unsupported or unnecessary for this database type - ignoring");
+ MWARNING("WARNING: batch transactions enabled but unsupported or unnecessary for this database type - ignoring");
}
if (use_batch)
simple_core.batch_start(db_batch_size);
- LOG_PRINT_L0("Reading blockchain from bootstrap file...");
+ MINFO("Reading blockchain from bootstrap file...");
std::cout << ENDL;
// Within the loop, we skip to start_height before we start adding.
@@ -338,7 +341,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
// TODO: bootstrap.read_chunk();
if (! import_file) {
std::cout << refresh_string;
- LOG_PRINT_L0("End of file reached");
+ MINFO("End of file reached");
quit = 1;
break;
}
@@ -349,29 +352,29 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
{
throw std::runtime_error("Error in deserialization of chunk size");
}
- LOG_PRINT_L3("chunk_size: " << chunk_size);
+ MDEBUG("chunk_size: " << chunk_size);
if (chunk_size > BUFFER_SIZE)
{
- LOG_PRINT_L0("WARNING: chunk_size " << chunk_size << " > BUFFER_SIZE " << BUFFER_SIZE);
+ MWARNING("WARNING: chunk_size " << chunk_size << " > BUFFER_SIZE " << BUFFER_SIZE);
throw std::runtime_error("Aborting: chunk size exceeds buffer size");
}
if (chunk_size > 100000)
{
- LOG_PRINT_L0("NOTE: chunk_size " << chunk_size << " > 100000");
+ MINFO("NOTE: chunk_size " << chunk_size << " > 100000");
}
else if (chunk_size == 0) {
- LOG_PRINT_L0("ERROR: chunk_size == 0");
+ MFATAL("ERROR: chunk_size == 0");
return 2;
}
import_file.read(buffer_block, chunk_size);
if (! import_file) {
- LOG_PRINT_L0("ERROR: unexpected end of file: bytes read before error: "
+ MFATAL("ERROR: unexpected end of file: bytes read before error: "
<< import_file.gcount() << " of chunk_size " << chunk_size);
return 2;
}
bytes_read += chunk_size;
- LOG_PRINT_L3("Total bytes read: " << bytes_read);
+ MINFO("Total bytes read: " << bytes_read);
if (h + NUM_BLOCKS_PER_CHUNK < start_height + 1)
{
@@ -384,7 +387,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
<< " / " << block_stop
<< std::flush;
std::cout << ENDL << ENDL;
- LOG_PRINT_L0("Specified block number reached - stopping. block: " << h-1 << " total blocks: " << h);
+ MINFO("Specified block number reached - stopping. block: " << h-1 << " total blocks: " << h);
quit = 1;
break;
}
@@ -405,14 +408,14 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
if ((h-1) % display_interval == 0)
{
std::cout << refresh_string;
- LOG_PRINT_L0("loading block number " << h-1);
+ MDEBUG("loading block number " << h-1);
}
else
{
- LOG_PRINT_L3("loading block number " << h-1);
+ MDEBUG("loading block number " << h-1);
}
b = bp.block;
- LOG_PRINT_L2("block prev_id: " << b.prev_id << ENDL);
+ MDEBUG("block prev_id: " << b.prev_id << ENDL);
if ((h-1) % progress_interval == 0)
{
@@ -427,12 +430,12 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
archived_txs = bp.txs;
// std::cout << refresh_string;
- // LOG_PRINT_L1("txs: " << archived_txs.size());
+ // MDEBUG("txs: " << archived_txs.size());
// if archived_txs is invalid
// {
// std::cout << refresh_string;
- // LOG_PRINT_RED_L0("exception while de-archiving txs, height=" << h);
+ // MFATAL("exception while de-archiving txs, height=" << h);
// quit = 1;
// break;
// }
@@ -445,20 +448,20 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
++tx_num;
// if tx is invalid
// {
- // LOG_PRINT_RED_L0("exception while indexing tx from txs, height=" << h <<", tx_num=" << tx_num);
+ // MFATAL("exception while indexing tx from txs, height=" << h <<", tx_num=" << tx_num);
// quit = 1;
// break;
// }
// std::cout << refresh_string;
- // LOG_PRINT_L1("tx hash: " << get_transaction_hash(tx));
+ // MDEBUG("tx hash: " << get_transaction_hash(tx));
// crypto::hash hsh = null_hash;
// size_t blob_size = 0;
// NOTE: all tx hashes except for coinbase tx are available in the block data
// get_transaction_hash(tx, hsh, blob_size);
- // LOG_PRINT_L0("tx " << tx_num << " " << hsh << " : " << ENDL);
- // LOG_PRINT_L0(obj_to_json_str(tx) << ENDL);
+ // MDEBUG("tx " << tx_num << " " << hsh << " : " << ENDL);
+ // MDEBUG(obj_to_json_str(tx) << ENDL);
// add blocks with verification.
// for Blockchain and blockchain_storage add_new_block().
@@ -475,7 +478,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
r = simple_core.m_pool.add_tx(tx, tvc, true, true, false, version);
if (!r)
{
- LOG_PRINT_RED_L0("failed to add transaction to transaction pool, height=" << h <<", tx_num=" << tx_num);
+ MFATAL("failed to add transaction to transaction pool, height=" << h <<", tx_num=" << tx_num);
quit = 1;
break;
}
@@ -499,8 +502,8 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
if (bvc.m_verifivation_failed)
{
- LOG_PRINT_L0("Failed to add block to blockchain, verification failed, height = " << h);
- LOG_PRINT_L0("skipping rest of file");
+ MFATAL("Failed to add block to blockchain, verification failed, height = " << h);
+ MFATAL("skipping rest of file");
// ok to commit previously batched data because it failed only in
// verification of potential new block with nothing added to batch
// yet
@@ -509,8 +512,8 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
}
if (! bvc.m_added_to_main_chain)
{
- LOG_PRINT_L0("Failed to add block to blockchain, height = " << h);
- LOG_PRINT_L0("skipping rest of file");
+ MFATAL("Failed to add block to blockchain, height = " << h);
+ MFATAL("skipping rest of file");
// make sure we don't commit partial block data
quit = 2;
break;
@@ -527,9 +530,9 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
coins_generated = bp.coins_generated;
// std::cout << refresh_string;
- // LOG_PRINT_L2("block_size: " << block_size);
- // LOG_PRINT_L2("cumulative_difficulty: " << cumulative_difficulty);
- // LOG_PRINT_L2("coins_generated: " << coins_generated);
+ // MDEBUG("block_size: " << block_size);
+ // MDEBUG("cumulative_difficulty: " << cumulative_difficulty);
+ // MDEBUG("coins_generated: " << coins_generated);
try
{
@@ -538,7 +541,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
catch (const std::exception& e)
{
std::cout << refresh_string;
- LOG_PRINT_RED_L0("Error adding block to blockchain: " << e.what());
+ MFATAL("Error adding block to blockchain: " << e.what());
quit = 2; // make sure we don't commit partial block data
break;
}
@@ -563,7 +566,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
catch (const std::exception& e)
{
std::cout << refresh_string;
- LOG_PRINT_RED_L0("exception while reading from file, height=" << h << ": " << e.what());
+ MFATAL("exception while reading from file, height=" << h << ": " << e.what());
return 2;
}
} // while
@@ -582,10 +585,10 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path,
simple_core.batch_stop();
}
simple_core.m_storage.get_db().show_stats();
- LOG_PRINT_L0("Number of blocks imported: " << num_imported);
+ MINFO("Number of blocks imported: " << num_imported);
if (h > 0)
// TODO: if there was an error, the last added block is probably at zero-based height h-2
- LOG_PRINT_L0("Finished at block: " << h-1 << " total blocks: " << h);
+ MINFO("Finished at block: " << h-1 << " total blocks: " << h);
}
std::cout << ENDL;
return 0;
@@ -602,7 +605,7 @@ int main(int argc, char* argv[])
std::string available_dbs = join_set_strings(db_types_all, ", ");
available_dbs = "available: " + available_dbs;
- uint32_t log_level = LOG_LEVEL_0;
+ uint32_t log_level = 0;
uint64_t num_blocks = 0;
uint64_t block_stop = 0;
std::string m_config_folder;
@@ -719,10 +722,8 @@ int main(int argc, char* argv[])
m_config_folder = command_line::get_arg(vm, data_dir_arg);
db_arg_str = command_line::get_arg(vm, arg_database);
- log_space::get_set_log_detalisation_level(true, log_level);
- log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
- LOG_PRINT_L0("Starting...");
- LOG_PRINT_L0("Setting log level = " << log_level);
+ mlog_configure("", true);
+ MINFO("Starting...");
boost::filesystem::path fs_import_file_path;
@@ -767,23 +768,23 @@ int main(int argc, char* argv[])
db_engine_compiled = "memory";
}
- LOG_PRINT_L0("database: " << db_type);
- LOG_PRINT_L0("database flags: " << db_flags);
- LOG_PRINT_L0("verify: " << std::boolalpha << opt_verify << std::noboolalpha);
+ MINFO("database: " << db_type);
+ MINFO("database flags: " << db_flags);
+ MINFO("verify: " << std::boolalpha << opt_verify << std::noboolalpha);
if (opt_batch)
{
- LOG_PRINT_L0("batch: " << std::boolalpha << opt_batch << std::noboolalpha
+ MINFO("batch: " << std::boolalpha << opt_batch << std::noboolalpha
<< " batch size: " << db_batch_size);
}
else
{
- LOG_PRINT_L0("batch: " << std::boolalpha << opt_batch << std::noboolalpha);
+ MINFO("batch: " << std::boolalpha << opt_batch << std::noboolalpha);
}
- LOG_PRINT_L0("resume: " << std::boolalpha << opt_resume << std::noboolalpha);
- LOG_PRINT_L0("testnet: " << std::boolalpha << opt_testnet << std::noboolalpha);
+ MINFO("resume: " << std::boolalpha << opt_resume << std::noboolalpha);
+ MINFO("testnet: " << std::boolalpha << opt_testnet << std::noboolalpha);
- LOG_PRINT_L0("bootstrap file path: " << import_file_path);
- LOG_PRINT_L0("database path: " << m_config_folder);
+ MINFO("bootstrap file path: " << import_file_path);
+ MINFO("database path: " << m_config_folder);
try
{
@@ -813,15 +814,15 @@ int main(int argc, char* argv[])
if (! vm["pop-blocks"].defaulted())
{
num_blocks = command_line::get_arg(vm, arg_pop_blocks);
- LOG_PRINT_L0("height: " << simple_core.m_storage.get_current_blockchain_height());
+ MINFO("height: " << simple_core.m_storage.get_current_blockchain_height());
pop_blocks(simple_core, num_blocks);
- LOG_PRINT_L0("height: " << simple_core.m_storage.get_current_blockchain_height());
+ MINFO("height: " << simple_core.m_storage.get_current_blockchain_height());
return 0;
}
if (! vm["drop-hard-fork"].defaulted())
{
- LOG_PRINT_L0("Dropping hard fork tables...");
+ MINFO("Dropping hard fork tables...");
simple_core.m_storage.get_db().drop_hard_fork_info();
return 0;
}
diff --git a/src/blockchain_utilities/blocksdat_file.cpp b/src/blockchain_utilities/blocksdat_file.cpp
index 926562ba2..7ccb9a145 100644
--- a/src/blockchain_utilities/blocksdat_file.cpp
+++ b/src/blockchain_utilities/blocksdat_file.cpp
@@ -28,6 +28,8 @@
#include "blocksdat_file.h"
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "bcutil"
namespace po = boost::program_options;
@@ -50,7 +52,7 @@ bool BlocksdatFile::open_writer(const boost::filesystem::path& file_path, uint64
{
if (!boost::filesystem::is_directory(dir_path))
{
- LOG_PRINT_RED_L0("export directory path is a file: " << dir_path);
+ MFATAL("export directory path is a file: " << dir_path);
return false;
}
}
@@ -58,7 +60,7 @@ bool BlocksdatFile::open_writer(const boost::filesystem::path& file_path, uint64
{
if (!boost::filesystem::create_directory(dir_path))
{
- LOG_PRINT_RED_L0("Failed to create directory " << dir_path);
+ MFATAL("Failed to create directory " << dir_path);
return false;
}
}
@@ -66,7 +68,7 @@ bool BlocksdatFile::open_writer(const boost::filesystem::path& file_path, uint64
m_raw_data_file = new std::ofstream();
- LOG_PRINT_L0("creating file");
+ MINFO("creating file");
m_raw_data_file->open(file_path.string(), std::ios_base::binary | std::ios_base::out | std::ios::trunc);
if (m_raw_data_file->fail())
@@ -123,21 +125,21 @@ bool BlocksdatFile::store_blockchain_raw(Blockchain* _blockchain_storage, tx_mem
uint64_t block_start = 0;
uint64_t block_stop = 0;
- LOG_PRINT_L0("source blockchain height: " << m_blockchain_storage->get_current_blockchain_height()-1);
+ MINFO("source blockchain height: " << m_blockchain_storage->get_current_blockchain_height()-1);
if ((requested_block_stop > 0) && (requested_block_stop < m_blockchain_storage->get_current_blockchain_height()))
{
- LOG_PRINT_L0("Using requested block height: " << requested_block_stop);
+ MINFO("Using requested block height: " << requested_block_stop);
block_stop = requested_block_stop;
}
else
{
block_stop = m_blockchain_storage->get_current_blockchain_height() - 1;
- LOG_PRINT_L0("Using block height of source blockchain: " << block_stop);
+ MINFO("Using block height of source blockchain: " << block_stop);
}
- LOG_PRINT_L0("Storing blocks raw data...");
+ MINFO("Storing blocks raw data...");
if (!BlocksdatFile::open_writer(output_file, block_stop))
{
- LOG_PRINT_RED_L0("failed to open raw file for write");
+ MFATAL("failed to open raw file for write");
return false;
}
for (m_cur_height = block_start; m_cur_height <= block_stop; ++m_cur_height)
@@ -157,7 +159,7 @@ bool BlocksdatFile::store_blockchain_raw(Blockchain* _blockchain_storage, tx_mem
std::cout << refresh_string;
std::cout << "block " << m_cur_height-1 << "/" << block_stop << ENDL;
- LOG_PRINT_L0("Number of blocks exported: " << num_blocks_written);
+ MINFO("Number of blocks exported: " << num_blocks_written);
return BlocksdatFile::close();
}
diff --git a/src/blockchain_utilities/bootstrap_file.cpp b/src/blockchain_utilities/bootstrap_file.cpp
index 61bd35a6f..add2c65e6 100644
--- a/src/blockchain_utilities/bootstrap_file.cpp
+++ b/src/blockchain_utilities/bootstrap_file.cpp
@@ -32,6 +32,8 @@
#include "bootstrap_file.h"
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "bcutil"
namespace po = boost::program_options;
@@ -59,7 +61,7 @@ bool BootstrapFile::open_writer(const boost::filesystem::path& file_path)
{
if (!boost::filesystem::is_directory(dir_path))
{
- LOG_PRINT_RED_L0("export directory path is a file: " << dir_path);
+ MFATAL("export directory path is a file: " << dir_path);
return false;
}
}
@@ -67,7 +69,7 @@ bool BootstrapFile::open_writer(const boost::filesystem::path& file_path)
{
if (!boost::filesystem::create_directory(dir_path))
{
- LOG_PRINT_RED_L0("Failed to create directory " << dir_path);
+ MFATAL("Failed to create directory " << dir_path);
return false;
}
}
@@ -80,14 +82,14 @@ bool BootstrapFile::open_writer(const boost::filesystem::path& file_path)
if (! boost::filesystem::exists(file_path))
{
- LOG_PRINT_L0("creating file");
+ MDEBUG("creating file");
do_initialize_file = true;
num_blocks = 0;
}
else
{
num_blocks = count_blocks(file_path.string());
- LOG_PRINT_L0("appending to existing file with height: " << num_blocks-1 << " total blocks: " << num_blocks);
+ MDEBUG("appending to existing file with height: " << num_blocks-1 << " total blocks: " << num_blocks);
}
m_height = num_blocks;
@@ -138,7 +140,7 @@ bool BootstrapFile::initialize_file()
uint32_t bd_size = 0;
blobdata bd = t_serializable_object_to_blob(bfi);
- LOG_PRINT_L1("bootstrap::file_info size: " << bd.size());
+ MDEBUG("bootstrap::file_info size: " << bd.size());
bd_size = bd.size();
if (! ::serialization::dump_binary(bd_size, blob))
@@ -149,7 +151,7 @@ bool BootstrapFile::initialize_file()
*output_stream_header << bd;
bd = t_serializable_object_to_blob(bbi);
- LOG_PRINT_L1("bootstrap::blocks_info size: " << bd.size());
+ MDEBUG("bootstrap::blocks_info size: " << bd.size());
bd_size = bd.size();
if (! ::serialization::dump_binary(bd_size, blob))
@@ -172,10 +174,10 @@ void BootstrapFile::flush_chunk()
m_output_stream->flush();
uint32_t chunk_size = m_buffer.size();
- // LOG_PRINT_L0("chunk_size " << chunk_size);
+ // MTRACE("chunk_size " << chunk_size);
if (chunk_size > BUFFER_SIZE)
{
- LOG_PRINT_L0("WARNING: chunk_size " << chunk_size << " > BUFFER_SIZE " << BUFFER_SIZE);
+ MWARNING("WARNING: chunk_size " << chunk_size << " > BUFFER_SIZE " << BUFFER_SIZE);
}
std::string blob;
@@ -196,14 +198,14 @@ void BootstrapFile::flush_chunk()
long num_chars_written = pos_after - pos_before;
if (static_cast<unsigned long>(num_chars_written) != chunk_size)
{
- LOG_PRINT_RED_L0("Error writing chunk: height: " << m_cur_height << " chunk_size: " << chunk_size << " num chars written: " << num_chars_written);
+ MFATAL("Error writing chunk: height: " << m_cur_height << " chunk_size: " << chunk_size << " num chars written: " << num_chars_written);
throw std::runtime_error("Error writing chunk");
}
m_buffer.clear();
delete m_output_stream;
m_output_stream = new boost::iostreams::stream<boost::iostreams::back_insert_device<buffer_type>>(m_buffer);
- LOG_PRINT_L1("flushed chunk: chunk_size: " << chunk_size);
+ MDEBUG("flushed chunk: chunk_size: " << chunk_size);
}
void BootstrapFile::write_block(block& block)
@@ -267,10 +269,10 @@ bool BootstrapFile::store_blockchain_raw(Blockchain* _blockchain_storage, tx_mem
m_blockchain_storage = _blockchain_storage;
m_tx_pool = _tx_pool;
uint64_t progress_interval = 100;
- LOG_PRINT_L0("Storing blocks raw data...");
+ MINFO("Storing blocks raw data...");
if (!BootstrapFile::open_writer(output_file))
{
- LOG_PRINT_RED_L0("failed to open raw file for write");
+ MFATAL("failed to open raw file for write");
return false;
}
block b;
@@ -280,16 +282,16 @@ bool BootstrapFile::store_blockchain_raw(Blockchain* _blockchain_storage, tx_mem
// height.
uint64_t block_start = m_height;
uint64_t block_stop = 0;
- LOG_PRINT_L0("source blockchain height: " << m_blockchain_storage->get_current_blockchain_height()-1);
+ MINFO("source blockchain height: " << m_blockchain_storage->get_current_blockchain_height()-1);
if ((requested_block_stop > 0) && (requested_block_stop < m_blockchain_storage->get_current_blockchain_height()))
{
- LOG_PRINT_L0("Using requested block height: " << requested_block_stop);
+ MINFO("Using requested block height: " << requested_block_stop);
block_stop = requested_block_stop;
}
else
{
block_stop = m_blockchain_storage->get_current_blockchain_height() - 1;
- LOG_PRINT_L0("Using block height of source blockchain: " << block_stop);
+ MINFO("Using block height of source blockchain: " << block_stop);
}
for (m_cur_height = block_start; m_cur_height <= block_stop; ++m_cur_height)
{
@@ -315,9 +317,9 @@ bool BootstrapFile::store_blockchain_raw(Blockchain* _blockchain_storage, tx_mem
std::cout << refresh_string;
std::cout << "block " << m_cur_height-1 << "/" << block_stop << ENDL;
- LOG_PRINT_L0("Number of blocks exported: " << num_blocks_written);
+ MINFO("Number of blocks exported: " << num_blocks_written);
if (num_blocks_written > 0)
- LOG_PRINT_L0("Largest chunk: " << m_max_chunk << " bytes");
+ MINFO("Largest chunk: " << m_max_chunk << " bytes");
return BootstrapFile::close();
}
@@ -338,11 +340,11 @@ uint64_t BootstrapFile::seek_to_first_chunk(std::ifstream& import_file)
if (file_magic != blockchain_raw_magic)
{
- LOG_PRINT_RED_L0("bootstrap file not recognized");
+ MFATAL("bootstrap file not recognized");
throw std::runtime_error("Aborting");
}
else
- LOG_PRINT_L0("bootstrap file recognized");
+ MINFO("bootstrap file recognized");
uint32_t buflen_file_info;
@@ -352,7 +354,7 @@ uint64_t BootstrapFile::seek_to_first_chunk(std::ifstream& import_file)
throw std::runtime_error("Error reading expected number of bytes");
if (! ::serialization::parse_binary(str1, buflen_file_info))
throw std::runtime_error("Error in deserialization of buflen_file_info");
- LOG_PRINT_L1("bootstrap::file_info size: " << buflen_file_info);
+ MINFO("bootstrap::file_info size: " << buflen_file_info);
if (buflen_file_info > sizeof(buf1))
throw std::runtime_error("Error: bootstrap::file_info size exceeds buffer size");
@@ -363,9 +365,9 @@ uint64_t BootstrapFile::seek_to_first_chunk(std::ifstream& import_file)
bootstrap::file_info bfi;
if (! ::serialization::parse_binary(str1, bfi))
throw std::runtime_error("Error in deserialization of bootstrap::file_info");
- LOG_PRINT_L0("bootstrap file v" << unsigned(bfi.major_version) << "." << unsigned(bfi.minor_version));
- LOG_PRINT_L0("bootstrap magic size: " << sizeof(file_magic));
- LOG_PRINT_L0("bootstrap header size: " << bfi.header_size);
+ MINFO("bootstrap file v" << unsigned(bfi.major_version) << "." << unsigned(bfi.minor_version));
+ MINFO("bootstrap magic size: " << sizeof(file_magic));
+ MINFO("bootstrap header size: " << bfi.header_size);
uint64_t full_header_size = sizeof(file_magic) + bfi.header_size;
import_file.seekg(full_header_size);
@@ -379,7 +381,7 @@ uint64_t BootstrapFile::count_blocks(const std::string& import_file_path)
boost::system::error_code ec;
if (!boost::filesystem::exists(raw_file_path, ec))
{
- LOG_PRINT_L0("bootstrap file not found: " << raw_file_path);
+ MFATAL("bootstrap file not found: " << raw_file_path);
throw std::runtime_error("Aborting");
}
std::ifstream import_file;
@@ -388,14 +390,14 @@ uint64_t BootstrapFile::count_blocks(const std::string& import_file_path)
uint64_t h = 0;
if (import_file.fail())
{
- LOG_PRINT_L0("import_file.open() fail");
+ MFATAL("import_file.open() fail");
throw std::runtime_error("Aborting");
}
uint64_t full_header_size; // 4 byte magic + length of header structures
full_header_size = seek_to_first_chunk(import_file);
- LOG_PRINT_L0("Scanning blockchain from bootstrap file...");
+ MINFO("Scanning blockchain from bootstrap file...");
block b;
bool quit = false;
uint64_t bytes_read = 0;
@@ -409,7 +411,7 @@ uint64_t BootstrapFile::count_blocks(const std::string& import_file_path)
import_file.read(buf1, sizeof(chunk_size));
if (!import_file) {
std::cout << refresh_string;
- LOG_PRINT_L1("End of file reached");
+ MDEBUG("End of file reached");
quit = true;
break;
}
@@ -425,38 +427,38 @@ uint64_t BootstrapFile::count_blocks(const std::string& import_file_path)
str1.assign(buf1, sizeof(chunk_size));
if (! ::serialization::parse_binary(str1, chunk_size))
throw std::runtime_error("Error in deserialization of chunk_size");
- LOG_PRINT_L3("chunk_size: " << chunk_size);
+ MDEBUG("chunk_size: " << chunk_size);
if (chunk_size > BUFFER_SIZE)
{
std::cout << refresh_string;
- LOG_PRINT_L0("WARNING: chunk_size " << chunk_size << " > BUFFER_SIZE " << BUFFER_SIZE
+ MWARNING("WARNING: chunk_size " << chunk_size << " > BUFFER_SIZE " << BUFFER_SIZE
<< " height: " << h-1);
throw std::runtime_error("Aborting: chunk size exceeds buffer size");
}
if (chunk_size > 100000)
{
std::cout << refresh_string;
- LOG_PRINT_L0("NOTE: chunk_size " << chunk_size << " > 100000" << " height: "
+ MDEBUG("NOTE: chunk_size " << chunk_size << " > 100000" << " height: "
<< h-1);
}
else if (chunk_size <= 0) {
std::cout << refresh_string;
- LOG_PRINT_L0("ERROR: chunk_size " << chunk_size << " <= 0" << " height: " << h-1);
+ MDEBUG("ERROR: chunk_size " << chunk_size << " <= 0" << " height: " << h-1);
throw std::runtime_error("Aborting");
}
// skip to next expected block size value
import_file.seekg(chunk_size, std::ios_base::cur);
if (! import_file) {
std::cout << refresh_string;
- LOG_PRINT_L0("ERROR: unexpected end of file: bytes read before error: "
+ MFATAL("ERROR: unexpected end of file: bytes read before error: "
<< import_file.gcount() << " of chunk_size " << chunk_size);
throw std::runtime_error("Aborting");
}
bytes_read += chunk_size;
// std::cout << refresh_string;
- LOG_PRINT_L3("Number bytes scanned: " << bytes_read);
+ MINFO("Number bytes scanned: " << bytes_read);
}
import_file.close();
diff --git a/src/blockchain_utilities/cn_deserialize.cpp b/src/blockchain_utilities/cn_deserialize.cpp
index a8448dcee..ae8e38435 100644
--- a/src/blockchain_utilities/cn_deserialize.cpp
+++ b/src/blockchain_utilities/cn_deserialize.cpp
@@ -33,8 +33,11 @@
#include "common/command_line.h"
#include "version.h"
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "bcutil"
+
namespace po = boost::program_options;
-using namespace epee; // log_space
+using namespace epee;
using namespace cryptonote;
@@ -87,8 +90,7 @@ int main(int argc, char* argv[])
return 1;
}
- log_space::get_set_log_detalisation_level(true, log_level);
- log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
+ mlog_configure("", true);
std::string m_config_folder;