1
0
Fork 0
forked from lthn/blockchain

Merge branch 'non_pruning_mode' into develop

This commit is contained in:
sowle 2025-05-09 06:53:44 +03:00
commit 6ff59d2392
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
13 changed files with 143 additions and 46 deletions

View file

@ -40,7 +40,7 @@ namespace command_line
const arg_descriptor<std::string> arg_process_predownload_from_path("predownload-from-local-path", "Instead of downloading file use downloaded local file");
const arg_descriptor<bool> arg_validate_predownload ( "validate-predownload", "Paranoid mode, re-validate each block from pre-downloaded database and rebuild own database");
const arg_descriptor<std::string> arg_predownload_link ( "predownload-link", "Override url for blockchain database pre-downloading");
const arg_descriptor<bool> arg_non_pruning_mode ( "non-pruning-mode", "Enables a special operational mode with full retention of all tx signatures. Will terminate if the DB was previously in (normal) pruning mode. Use only if you know what you do.");
const arg_descriptor<std::string> arg_deeplink ( "deeplink-params", "Deeplink parameter, in that case app just forward params to running app");

View file

@ -232,6 +232,7 @@ namespace command_line
extern const arg_descriptor<std::string> arg_process_predownload_from_path;
extern const arg_descriptor<bool> arg_validate_predownload;
extern const arg_descriptor<std::string> arg_predownload_link;
extern const arg_descriptor<bool> arg_non_pruning_mode;
extern const arg_descriptor<std::string> arg_deeplink;
extern const arg_descriptor<std::string> arg_generate_rpc_autodoc;

View file

@ -21,11 +21,15 @@ namespace tools
};
#ifndef TESTNET
static constexpr pre_download_entry c_pre_download_mdbx = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3083770.pak", "e7cb7b5e1560c3a7615604880feda9df37636be83264a5afff01f44b5f824cc8", 8357805798, 12884705280 };
static constexpr pre_download_entry c_pre_download_lmdb = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3083770.pak", "685db01e1a4c827d20e777563009f771be593fe80cc32b8a4dfe2711e6a2b2f8", 10070627937, 12842385408 };
static constexpr pre_download_entry c_pre_download_mdbx = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3150000.pak", "296d3129fee9253adea332d6c6128941aa5ef67eecaba49b9f8327f8c2d86ea1", 9388521394, 14226862080 };
static constexpr pre_download_entry c_pre_download_lmdb = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3150000.pak", "bdb9d651636b36fd7d1f216c4afe89b1e7ec887da6eac7455ea18253a93345e8", 11287228509, 13988814848 };
static constexpr pre_download_entry c_pre_download_mdbx_non_pruned = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3141000_non_pruned.pak", "0703902d535253627a2dd3c8697b305844b0241dfffefce5ec9d9e8e3475cdab", 10065877170, 15032156160 };
static constexpr pre_download_entry c_pre_download_lmdb_non_pruned = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3141000_non_pruned.pak", "fe407e332d42a124d42781f6ccc6d2456728348230d7f05d94203ac405c37e63", 12081697874, 14824468480 };
#else
static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_mdbx_non_pruned = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_lmdb_non_pruned = { "", "", 0, 0 };
#endif
static constexpr uint64_t pre_download_min_size_difference = 512 * 1024 * 1024; // minimum difference in size between local DB and the downloadable one to start downloading
@ -41,7 +45,8 @@ namespace tools
std::string working_folder = dbbs.get_db_folder_path();
std::string db_main_file_path = working_folder + "/" + dbbs.get_db_main_file_name();
pre_download_entry pre_download = dbbs.get_engine_type() == db::db_lmdb ? c_pre_download_lmdb : c_pre_download_mdbx;
bool non_pruning_mode_enabled = tools::is_non_pruning_mode_enabled(vm);
pre_download_entry pre_download = dbbs.get_engine_type() == db::db_lmdb ? (non_pruning_mode_enabled ? c_pre_download_lmdb_non_pruned : c_pre_download_lmdb) : (non_pruning_mode_enabled ? c_pre_download_mdbx_non_pruned : c_pre_download_mdbx);
// override pre-download link if necessary
std::string url = pre_download.url;

View file

@ -26,6 +26,7 @@ using namespace epee;
#include <boost/asio.hpp>
#include "string_coding.h"
#include "command_line.h"
namespace tools
{
@ -729,6 +730,17 @@ std::string get_nix_version_display_string()
return true;
}
bool is_non_pruning_mode_enabled(const boost::program_options::variables_map& vm, bool *p_enabled_via_env /* = nullptr */)
{
const char* npm_env = std::getenv("ZANO_NON_PRUNING_MODE");
std::string npm_env_str = boost::algorithm::to_lower_copy(std::string(npm_env ? npm_env : ""));
bool npm_env_enabled = (npm_env_str == "1" || npm_env_str == "on" || npm_env_str == "true");
bool result = (command_line::has_arg(vm, command_line::arg_non_pruning_mode) && command_line::get_arg(vm, command_line::arg_non_pruning_mode)) || npm_env_enabled;
if (result && p_enabled_via_env != nullptr)
*p_enabled_via_env = npm_env_enabled;
return result;
}
//this code was taken from https://stackoverflow.com/a/8594696/5566653
//credits goes to @nijansen: https://stackoverflow.com/users/1056003/nijansen
bool copy_dir( boost::filesystem::path const & source, boost::filesystem::path const & destination)

View file

@ -12,6 +12,7 @@
#include <mutex>
#include <system_error>
#include <boost/filesystem.hpp>
#include <boost/program_options/variables_map.hpp>
#include "crypto/crypto.h"
#include "crypto/hash.h"
@ -41,6 +42,7 @@ namespace tools
bool parse_client_version(const std::string& str, int& major, int& minor, int& revision, int& build_number, std::string& commit_id, bool& dirty);
bool parse_client_version_build_number(const std::string& str, int& build_number);
bool check_remote_client_version(const std::string& client_ver);
bool is_non_pruning_mode_enabled(const boost::program_options::variables_map& vm, bool *p_enabled_via_env = nullptr);
bool create_directories_if_necessary(const std::string& path);
std::error_code replace_file(const std::string& replacement_name, const std::string& replaced_name);
@ -57,6 +59,7 @@ namespace tools
return crypto::cn_fast_hash(s.data(), s.size());
}
// the following is unsafe, consider removing -- sowle
inline
crypto::public_key get_public_key_from_string(const std::string& str_key)
{

View file

@ -1113,7 +1113,7 @@ bool handle_generate_integrated_address(po::variables_map& vm)
}
//---------------------------------------------------------------------------------------------------------------
template<class archive_processor_t>
bool process_archive(archive_processor_t& arch_processor, bool is_packing, std::ifstream& source, std::ofstream& target)
bool process_archive(archive_processor_t& arch_processor, bool is_packing, const std::string& path_target, std::ifstream& source, std::ofstream& target)
{
source.seekg(0, std::ios::end);
uint64_t sz = source.tellg();
@ -1167,8 +1167,11 @@ bool process_archive(archive_processor_t& arch_processor, bool is_packing, std::
crypto::hash data_hash = hash_stream.calculate_hash();
std::cout << "\r\nFile " << (is_packing ? "packed" : "unpacked") << " from size " << sz << " to " << written_bytes <<
"\r\nhash of the data is " << epee::string_tools::pod_to_hex(data_hash) << "\r\n";
std::cout << ENDL
<< "File " << (is_packing ? "packed" : "unpacked") << " from size " << sz << " to " << written_bytes << ENDL
<< "hash of the data is " << epee::string_tools::pod_to_hex(data_hash) << ENDL
<< ENDL
<< " = { \"" << boost::filesystem::basename(path_target) << "\", \"" << epee::string_tools::pod_to_hex(data_hash) << "\", " << written_bytes << ", " << sz << " }" << ENDL;
return true;
}
@ -1247,12 +1250,12 @@ bool handle_pack_file(po::variables_map& vm)
if (do_pack)
{
epee::net_utils::gzip_encoder_lyambda gzip_encoder(Z_BEST_SPEED);
return process_archive(gzip_encoder, true, source, target);
return process_archive(gzip_encoder, true, path_target, source, target);
}
else
{
epee::net_utils::gzip_decoder_lambda gzip_decoder;
return process_archive(gzip_decoder, false, source, target);
return process_archive(gzip_decoder, false, path_target, source, target);
}
}

View file

@ -74,8 +74,8 @@ using namespace currency;
DISABLE_VS_WARNINGS(4267)
const command_line::arg_descriptor<uint32_t> arg_db_cache_l1 ( "db-cache-l1", "Specify size of memory mapped db cache file");
const command_line::arg_descriptor<uint32_t> arg_db_cache_l2 ( "db-cache-l2", "Specify cached elements in db helpers");
const command_line::arg_descriptor<uint32_t> arg_db_cache_l1 ( "db-cache-l1", "Specify size of memory mapped db cache file");
const command_line::arg_descriptor<uint32_t> arg_db_cache_l2 ( "db-cache-l2", "Specify cached elements in db helpers");
//------------------------------------------------------------------
blockchain_storage::blockchain_storage(tx_memory_pool& tx_pool) :m_db(nullptr, m_rw_lock),
@ -111,7 +111,8 @@ blockchain_storage::blockchain_storage(tx_memory_pool& tx_pool) :m_db(nullptr, m
m_deinit_is_done(false),
m_cached_next_pow_difficulty(0),
m_cached_next_pos_difficulty(0),
m_blockchain_launch_timestamp(0)
m_blockchain_launch_timestamp(0),
m_non_pruning_mode_enabled(false)
{
@ -155,6 +156,7 @@ void blockchain_storage::init_options(boost::program_options::options_descriptio
{
command_line::add_arg(desc, arg_db_cache_l1);
command_line::add_arg(desc, arg_db_cache_l2);
command_line::add_arg(desc, command_line::arg_non_pruning_mode);
}
//------------------------------------------------------------------
uint64_t blockchain_storage::get_block_h_older_then(uint64_t timestamp) const
@ -278,6 +280,13 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
return false;
}
bool npm_env_enabled = false;
m_non_pruning_mode_enabled = tools::is_non_pruning_mode_enabled(vm, &npm_env_enabled);
if (m_non_pruning_mode_enabled)
{
LOG_PRINT_CYAN("*** Non-pruning mode ENABLED" << (npm_env_enabled ? " (via an environment variable)" : "") << ". This build will allways retain all transaction data regardless of checkpoints. The DB is expected to have all data and will be verified soon.", LOG_LEVEL_0);
}
uint64_t cache_size_l1 = CACHE_SIZE;
if (command_line::has_arg(vm, arg_db_cache_l1))
{
@ -594,6 +603,52 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
<< " major failure: " << (m_db_major_failure ? "true" : "false"),
LOG_LEVEL_0);
if (m_non_pruning_mode_enabled)
{
size_t txs = 0;
size_t pruned_txs = 0;
size_t signatures = 0;
size_t attachments = 0;
uint64_t last_block_height = m_db_blocks.size() > 0 ? m_db_blocks.size() - 1 : 0;
LOG_PRINT_CYAN("The blockchain will be scanned now; it takes a while, please wait...", LOG_LEVEL_0);
for (uint64_t height = 0; height <= last_block_height; height++)
{
auto vptr = m_db_blocks[height];
CHECK_AND_ASSERT_MES(vptr.get(), false, "Failed to get block on height");
for (const auto& h : vptr->bl.tx_hashes)
{
auto it = m_db_transactions.find(h);
CHECK_AND_ASSERT_MES(it != m_db_transactions.end(), false, "failed to find transaction " << h << " in blockchain index, in block on height = " << height);
CHECK_AND_ASSERT_MES(it->m_keeper_block_height == height, false,
"failed to validate extra check, it->second.m_keeper_block_height = " << it->m_keeper_block_height <<
"is mot equal to height = " << height << " in blockchain index, for block on height = " << height);
if (it->tx.signatures.size() == 0)
{
pruned_txs += 1;
CHECK_AND_ASSERT_THROW_MES(false, "found pruned tx " << h << ", non pruning mode couldn't be activated on pruned DB, terminating...");
}
txs += 1;
signatures += it->tx.signatures.size();
attachments += it->tx.attachment.size();
}
}
LOG_PRINT_CYAN(ENDL << "blockchain (non)pruning status:" << ENDL <<
" last block height: " << last_block_height << ENDL <<
" total txs: " << txs << ENDL <<
" pruned txs: " << pruned_txs << ENDL <<
" total signatures: " << signatures << ENDL <<
" total attachments: " << attachments << ENDL <<
ENDL << "Blockchain DB was successfully scanned for pruned txs.", LOG_LEVEL_0);
}
return true;
}
@ -704,7 +759,7 @@ bool blockchain_storage::set_checkpoints(checkpoints&& chk_pts)
{
m_db.begin_transaction();
if (m_db_blocks.size() < m_checkpoints.get_top_checkpoint_height())
m_is_in_checkpoint_zone = true;
m_is_in_checkpoint_zone = !m_non_pruning_mode_enabled; // set to true unless non-pruning mode is on
prune_ring_signatures_and_attachments_if_need();
m_db.commit_transaction();
return true;
@ -727,6 +782,7 @@ bool blockchain_storage::set_checkpoints(checkpoints&& chk_pts)
bool blockchain_storage::prune_ring_signatures_and_attachments(uint64_t height, uint64_t& transactions_pruned, uint64_t& signatures_pruned, uint64_t& attachments_pruned)
{
CRITICAL_REGION_LOCAL(m_read_lock);
CHECK_AND_ASSERT_MES(!m_non_pruning_mode_enabled, false, "cannot prune while non-pruning mode is enabled");
CHECK_AND_ASSERT_MES(height < m_db_blocks.size(), false, "prune_ring_signatures called with wrong parameter: " << height << ", m_blocks.size() = " << m_db_blocks.size());
auto vptr = m_db_blocks[height];
@ -761,6 +817,9 @@ bool blockchain_storage::prune_ring_signatures_and_attachments_if_need()
{
CRITICAL_REGION_LOCAL(m_read_lock);
if (m_non_pruning_mode_enabled)
return true;
uint64_t top_block_height = get_top_block_height();
uint64_t pruning_end_height = m_checkpoints.get_checkpoint_before_height(top_block_height);
if (pruning_end_height > m_db_current_pruned_rs_height)
@ -2032,7 +2091,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto::
}
else
{
m_is_in_checkpoint_zone = true;
m_is_in_checkpoint_zone = !m_non_pruning_mode_enabled; // set to true unless non-pruning mode is on
if (!m_checkpoints.check_block(abei.height, id))
{
LOG_ERROR("CHECKPOINT VALIDATION FAILED");
@ -6888,7 +6947,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
if (m_checkpoints.is_in_checkpoint_zone(get_current_blockchain_size()))
{
m_is_in_checkpoint_zone = true;
m_is_in_checkpoint_zone = !m_non_pruning_mode_enabled; // set to true unless non-pruning mode is on
if (!m_checkpoints.check_block(get_current_blockchain_size(), id))
{
LOG_ERROR("CHECKPOINT VALIDATION FAILED @ " << height);

View file

@ -341,6 +341,7 @@ namespace currency
bool is_multisig_output_spent(const crypto::hash& multisig_id) const;
boost::multiprecision::uint128_t total_coins()const;
bool is_pos_allowed()const;
bool is_non_pruning_mode_enabled() const { return m_non_pruning_mode_enabled; }
uint64_t get_tx_fee_median()const;
uint64_t get_tx_fee_window_value_median() const;
uint64_t get_tx_expiration_median() const;
@ -593,6 +594,7 @@ namespace currency
std::atomic<bool> m_is_in_checkpoint_zone;
std::atomic<bool> m_is_blockchain_storing;
bool m_non_pruning_mode_enabled;
std::string m_config_folder;
//events

View file

@ -49,7 +49,7 @@ namespace currency
};
state m_state;
uint64_t m_remote_blockchain_height;
uint64_t m_remote_blockchain_size; // height of the top block + 1
uint64_t m_last_response_height;
int64_t m_time_delta;
std::string m_remote_version;

View file

@ -122,7 +122,7 @@ namespace currency
std::list<blobdata> txs;
std::list<block_complete_entry> blocks;
std::list<crypto::hash> missed_ids;
uint64_t current_blockchain_height;
uint64_t current_blockchain_height; // height of the top block + 1
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(txs)
@ -140,6 +140,7 @@ namespace currency
uint64_t last_checkpoint_height;
uint64_t core_time;
std::string client_version;
bool non_pruning_mode_enabled;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(current_height)
@ -147,6 +148,7 @@ namespace currency
KV_SERIALIZE(last_checkpoint_height)
KV_SERIALIZE(core_time)
KV_SERIALIZE(client_version)
KV_SERIALIZE(non_pruning_mode_enabled)
END_KV_SERIALIZE_MAP()
};

View file

@ -181,24 +181,38 @@ namespace currency
LOG_PRINT_L0("wtf");
}
if (m_core.get_blockchain_storage().is_non_pruning_mode_enabled())
{
// if non-pruning mode is enabled, allow syncronization iff the remote is also in non-pruning mode,
// or if this node top height above the last checkpoint height of the remote
if (!hshd.non_pruning_mode_enabled && m_core.get_top_block_height() < hshd.last_checkpoint_height)
{
LOG_PRINT_YELLOW("Non-pruning mode: current top block height (" << m_core.get_top_block_height() << ") is less than the remote's most recent checkpoint height (" << hshd.last_checkpoint_height <<
") and the remove isn't in non-pruning mode, disconnecting.", LOG_LEVEL_0);
return false;
}
}
int64_t diff = static_cast<int64_t>(hshd.current_height) - static_cast<int64_t>(m_core.get_current_blockchain_size());
LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, (is_inital ? "Inital ":"Idle ") << "sync data returned unknown top block (" << hshd.top_id << "): " << m_core.get_top_block_height() << " -> " << hshd.current_height - 1
<< " [" << std::abs(diff) << " blocks (" << diff / (24 * 60 * 60 / DIFFICULTY_TOTAL_TARGET ) << " days) "
<< (0 <= diff ? std::string("behind") : std::string("ahead"))
<< "] " << ENDL << "SYNCHRONIZATION started", (is_inital ? LOG_LEVEL_0 : LOG_LEVEL_1), (is_inital ? epee::log_space::console_color_yellow : epee::log_space::console_color_magenta));
LOG_PRINT_L1("Remote top block height: " << hshd.current_height << ", id: " << hshd.top_id);
LOG_PRINT_L1("Remote top block height: " << hshd.current_height - 1 << ", id: " << hshd.top_id);
/*check if current height is in remote's checkpoints zone*/
if(hshd.last_checkpoint_height
&& m_core.get_blockchain_storage().get_checkpoints().get_top_checkpoint_height() < hshd.last_checkpoint_height
&& m_core.get_current_blockchain_size() < hshd.last_checkpoint_height )
&& m_core.get_top_block_height() < hshd.last_checkpoint_height )
{
LOG_PRINT_RED("Remote node has longer checkpoints zone (" << hshd.last_checkpoint_height << ") " <<
"than local (" << m_core.get_blockchain_storage().get_checkpoints().get_top_checkpoint_height() << "). " <<
"It means that current software is outdated, please updated it! " <<
(m_core.get_blockchain_storage().is_non_pruning_mode_enabled() ? "It is expected since this node is in non-pruning mode. " : "It means that current software is outdated, please updated it! ") <<
"Current height lays under checkpoints zone on remote host, so it's impossible to validate remote transactions locally, disconnecting.", LOG_LEVEL_0);
return false;
}
else if (m_core.get_blockchain_storage().get_checkpoints().get_top_checkpoint_height() < hshd.last_checkpoint_height)
if (m_core.get_blockchain_storage().get_checkpoints().get_top_checkpoint_height() < hshd.last_checkpoint_height)
{
LOG_PRINT_MAGENTA("Remote node has longer checkpoints zone (" << hshd.last_checkpoint_height << ") " <<
"than local (" << m_core.get_blockchain_storage().get_checkpoints().get_top_checkpoint_height() << "). " <<
@ -206,7 +220,7 @@ namespace currency
}
context.m_state = currency_connection_context::state_synchronizing;
context.m_remote_blockchain_height = hshd.current_height;
context.m_remote_blockchain_size = hshd.current_height;
context.m_priv.m_last_fetched_block_ids.clear();
//let the socket to send response to handshake, but request callback, to let send request data after response
LOG_PRINT_L3("requesting callback");
@ -242,6 +256,7 @@ namespace currency
hshd.last_checkpoint_height = m_core.get_blockchain_storage().get_checkpoints().get_top_checkpoint_height();
hshd.core_time = m_core.get_blockchain_storage().get_core_runtime_config().get_core_time();
hshd.client_version = PROJECT_VERSION_LONG;
hshd.non_pruning_mode_enabled = m_core.get_blockchain_storage().is_non_pruning_mode_enabled();
return true;
}
//------------------------------------------------------------------------------------------------------------------------
@ -522,7 +537,7 @@ namespace currency
return 1;
}
context.m_remote_blockchain_height = arg.current_blockchain_height;
context.m_remote_blockchain_size = arg.current_blockchain_height;
uint64_t total_blocks_parsing_time = 0;
size_t count = 0;
@ -664,9 +679,9 @@ namespace currency
}
uint64_t current_size = m_core.get_blockchain_storage().get_current_blockchain_size();
LOG_PRINT_YELLOW(">>>>>>>>> sync progress: " << arg.blocks.size() << " blocks added, now have "
<< current_size << " of " << context.m_remote_blockchain_height
<< " ( " << std::fixed << std::setprecision(2) << current_size * 100.0 / context.m_remote_blockchain_height << "% ) and "
<< context.m_remote_blockchain_height - current_size << " blocks left"
<< current_size << " of " << context.m_remote_blockchain_size
<< " ( " << std::fixed << std::setprecision(2) << current_size * 100.0 / context.m_remote_blockchain_size << "% ) and "
<< context.m_remote_blockchain_size - current_size << " blocks left"
, LOG_LEVEL_0);
request_missing_objects(context, true);
@ -743,7 +758,7 @@ namespace currency
LOG_PRINT_L2("[NOTIFY]NOTIFY_REQUEST_GET_OBJECTS(req_missing): requested_cumulative_size=" << requested_cumulative_size << ", blocks.size()=" << req.blocks.size() << ", txs.size()=" << req.txs.size());
LOG_PRINT_L3("[NOTIFY]NOTIFY_REQUEST_GET_OBJECTS(req_missing): " << ENDL << currency::print_kv_structure(req));
post_notify<NOTIFY_REQUEST_GET_OBJECTS>(req, context);
}else if(context.m_last_response_height < context.m_remote_blockchain_height-1)
}else if(context.m_last_response_height < context.m_remote_blockchain_size-1)
{//we have to fetch more objects ids, request blockchain entry
NOTIFY_REQUEST_CHAIN::request r = boost::value_initialized<NOTIFY_REQUEST_CHAIN::request>();
@ -783,11 +798,11 @@ namespace currency
}else
{
CHECK_AND_ASSERT_MES(context.m_last_response_height == context.m_remote_blockchain_height-1
CHECK_AND_ASSERT_MES(context.m_last_response_height == context.m_remote_blockchain_size-1
&& !context.m_priv.m_needed_objects.size()
&& !context.m_priv.m_requested_objects.size(), false, "request_missing_blocks final condition failed!"
<< "\r\nm_last_response_height=" << context.m_last_response_height
<< "\r\nm_remote_blockchain_height=" << context.m_remote_blockchain_height
<< "\r\nm_remote_blockchain_size=" << context.m_remote_blockchain_size
<< "\r\nm_needed_objects.size()=" << context.m_priv.m_needed_objects.size()
<< "\r\nm_requested_objects.size()=" << context.m_priv.m_requested_objects.size()
<< "\r\non connection [" << epee::net_utils::print_connection_context_short(context)<< "]");
@ -998,9 +1013,9 @@ namespace currency
return 1;
}
context.m_remote_blockchain_height = arg.total_height;
context.m_remote_blockchain_size = arg.total_height;
context.m_last_response_height = arg.start_height + arg.m_block_ids.size()-1;
if(context.m_last_response_height > context.m_remote_blockchain_height)
if(context.m_last_response_height > context.m_remote_blockchain_size)
{
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_CHAIN_ENTRY, with \r\nm_total_height=" << arg.total_height
<< "\r\nm_start_height=" << arg.start_height

View file

@ -193,6 +193,7 @@ int main(int argc, char* argv[])
std::string data_dir;
po::variables_map vm;
bool exit_requested = false;
bool r = command_line::handle_error_helper(desc_options, [&]()
@ -213,7 +214,7 @@ int main(int argc, char* argv[])
return true;
}
std::string data_dir = command_line::get_arg(vm, command_line::arg_data_dir);
data_dir = command_line::get_arg(vm, command_line::arg_data_dir);
std::string config = command_line::get_arg(vm, command_line::arg_config_file);
boost::filesystem::path data_dir_path(epee::string_encoding::utf8_to_wstring(data_dir));
@ -240,17 +241,11 @@ int main(int argc, char* argv[])
return EXIT_SUCCESS;
//set up logging options
std::string log_dir;
std::string log_dir = data_dir;
std::string log_file_name = log_space::log_singletone::get_default_log_file();
//check if there was specific option
if (command_line::has_arg(vm, command_line::arg_log_dir))
{
log_dir = command_line::get_arg(vm, command_line::arg_log_dir);
}
else
{
log_dir = command_line::get_arg(vm, command_line::arg_data_dir);
}
log_space::log_singletone::add_logger(LOGGER_FILE, log_file_name.c_str(), log_dir.c_str());
LOG_PRINT_L0(CURRENCY_NAME << " v" << PROJECT_VERSION_LONG);
@ -264,7 +259,7 @@ int main(int argc, char* argv[])
// stratum server is enabled if any of its options present
bool stratum_enabled = currency::stratum_server::should_start(vm);
LOG_PRINT("Module folder: " << argv[0], LOG_LEVEL_0);
LOG_PRINT("Module folder: " << argv[0] << ", data folder: " << data_dir, LOG_LEVEL_0);
//create objects and link them
bc_services::bc_offers_service offers_service(nullptr);

View file

@ -570,14 +570,14 @@ namespace nodetool
{
if(!m_payload_handler.process_payload_sync_data(rsp.payload_data, context, true))
{
LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE invoked, but process_payload_sync_data returned false, dropping connection.");
LOG_PRINT_L1("COMMAND_HANDSHAKE invoked, but process_payload_sync_data returned false, dropping connection.");
hsh_result = false;
return;
}
if (is_peer_id_used(rsp.node_data.peer_id))
{
LOG_PRINT_L0("It seems that peer " << std::hex << rsp.node_data.peer_id << " has already been connected, dropping connection");
LOG_PRINT_L1("It seems that peer " << std::hex << rsp.node_data.peer_id << " has already been connected, dropping connection");
hsh_result = false;
return;
}
@ -587,7 +587,7 @@ namespace nodetool
if(rsp.node_data.peer_id == m_config.m_peer_id)
{
LOG_PRINT_L0("Connection to self detected, dropping connection");
LOG_PRINT_L1("Connection to self detected, dropping connection");
hsh_result = false;
return;
}
@ -606,7 +606,7 @@ namespace nodetool
if(!hsh_result)
{
LOG_PRINT_CC_L0(context_, "COMMAND_HANDSHAKE Failed, closing connection");
LOG_PRINT_CC_L1(context_, "COMMAND_HANDSHAKE Failed, closing connection");
m_net_server.get_config_object().close(context_.m_connection_id);
}