forked from lthn/blockchain
fixed multi-sync issue, fixed wrong 'set connected FALSE' warning, disabled market
This commit is contained in:
parent
008bcda9ca
commit
064f1edc17
3 changed files with 61 additions and 14 deletions
|
|
@ -25,7 +25,7 @@ namespace bc_services
|
|||
, m_core_runtime_config(currency::get_default_core_runtime_config())
|
||||
, m_last_seen_block_id(currency::null_hash)
|
||||
, m_deinitialized(false)
|
||||
, m_disabled(false)
|
||||
, m_disabled(true)
|
||||
|
||||
{}
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -145,8 +145,6 @@ namespace currency
|
|||
<< (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);
|
||||
// m_synchronized = false;
|
||||
LOG_PRINT_MAGENTA("Synchronized set to FALSE (process_payload_sync_data)", LOG_LEVEL_0);
|
||||
/*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
|
||||
|
|
@ -422,7 +420,7 @@ namespace currency
|
|||
total_blocks_parsing_time += block_parsing_time;
|
||||
|
||||
//to avoid concurrency in core between connections, suspend connections which delivered block later then first one
|
||||
if(count == 2)
|
||||
if(count = 2)
|
||||
{
|
||||
if(m_core.have_block(get_block_hash(b)))
|
||||
{
|
||||
|
|
@ -467,7 +465,7 @@ namespace currency
|
|||
m_core.pause_mine();
|
||||
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler(
|
||||
boost::bind(&t_core::resume_mine, &m_core));
|
||||
|
||||
size_t count = 0;
|
||||
for (const block_complete_entry& block_entry : arg.blocks)
|
||||
{
|
||||
CHECK_STOP_FLAG__DROP_AND_RETURN_IF_SET(1, "Blocks processing interrupted, connection dropped");
|
||||
|
|
@ -495,6 +493,14 @@ namespace currency
|
|||
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
||||
|
||||
m_core.handle_incoming_block(block_entry.block, bvc, false);
|
||||
if (count > 2 && bvc.m_already_exists)
|
||||
{
|
||||
context.m_state = currency_connection_context::state_idle;
|
||||
context.m_priv.m_needed_objects.clear();
|
||||
context.m_priv.m_requested_objects.clear();
|
||||
LOG_PRINT_L1("Connection set to idle state.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(bvc.m_verification_failed)
|
||||
{
|
||||
|
|
@ -513,6 +519,7 @@ namespace currency
|
|||
|
||||
TIME_MEASURE_FINISH(block_process_time);
|
||||
LOG_PRINT_L2("Block process time: " << block_process_time + transactions_process_time << "(" << transactions_process_time << "/" << block_process_time << ")ms");
|
||||
++count;
|
||||
}
|
||||
}
|
||||
uint64_t current_size = m_core.get_blockchain_storage().get_current_blockchain_size();
|
||||
|
|
|
|||
|
|
@ -14,19 +14,18 @@ using namespace epee;
|
|||
#include "currency_core/blockchain_storage.h"
|
||||
|
||||
|
||||
void run_difficulty_analysis(const std::string& path)
|
||||
bool parse_file(const std::string& path, std::vector<std::vector<uint64_t>>& blocks, uint64_t reserve_size)
|
||||
{
|
||||
std::ifstream fstr(path);
|
||||
if (!fstr.good())
|
||||
{
|
||||
LOG_ERROR("unable to open " << path);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_PRINT_L0("Loading array...");
|
||||
std::string line;
|
||||
std::vector<std::vector<uint64_t>> blocks;
|
||||
blocks.reserve(140000);
|
||||
blocks.reserve(reserve_size);
|
||||
while (std::getline(fstr, line))
|
||||
{
|
||||
std::vector<uint64_t> array_num;
|
||||
|
|
@ -38,18 +37,59 @@ void run_difficulty_analysis(const std::string& path)
|
|||
blocks.push_back(array_num);
|
||||
}
|
||||
LOG_PRINT_L0("Loaded " << blocks.size() << " lines");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void run_difficulty_analysis(const std::string& path)
|
||||
{
|
||||
//hash_rate_analysis(path);
|
||||
run_emulation(path);
|
||||
|
||||
}
|
||||
|
||||
void run_emulation(const std::string& path)
|
||||
{
|
||||
//0 - timestamp, 1 - difficulty/120, 2 net hashrate (h/s)
|
||||
|
||||
std::vector<std::vector<uint64_t>> blocks;
|
||||
parse_file(path, blocks, 500);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void hash_rate_analysis(const std::string& path)
|
||||
{
|
||||
|
||||
//0 = height, 1 - timestamp, 2 - difficulty, 3 cumulative_diff
|
||||
std::vector<std::vector<uint64_t>> blocks;
|
||||
parse_file(path, blocks, 140000);
|
||||
|
||||
LOG_PRINT_L0("Calculating hashrate...");
|
||||
std::stringstream ss;
|
||||
uint64_t curren_hashrate = 0;
|
||||
uint64_t step = 50;
|
||||
for (size_t i = 1; i != blocks.size(); i++)
|
||||
uint64_t step = 10;
|
||||
uint64_t hash_rate_range = 10;
|
||||
uint64_t second_windowf_or_hashrate = 20*60;
|
||||
|
||||
for (size_t i = hash_rate_range; i != blocks.size(); i++)
|
||||
{
|
||||
|
||||
if (i % step == 0 )
|
||||
if (i % step == 0)
|
||||
{
|
||||
curren_hashrate = (blocks[i][3] - blocks[i - step][3])/(blocks[i][1] - blocks[i- step][1]);
|
||||
ss << std::left << std::setw(10) << i << std::left << std::setw(15) << blocks[i][1] << std::left << std::setw(15) << blocks[i][2] << std::left << std::setw(20) << curren_hashrate * 120 << ENDL;
|
||||
//curren_hashrate = (blocks[i][3] - blocks[i - hash_rate_range][3])/(blocks[i][1] - blocks[i- hash_rate_range][1]);
|
||||
|
||||
// uint64_t cumul_dif = 0;
|
||||
// for (size_t j = i; j != 0 && blocks[j][1] > blocks[i][1]- second_windowf_or_hashrate; j--)
|
||||
// {
|
||||
// cumul_dif += blocks[j][2];
|
||||
// }
|
||||
// curren_hashrate = cumul_dif / second_windowf_or_hashrate;
|
||||
|
||||
curren_hashrate = (blocks[i][3] - blocks[i - hash_rate_range][3]) / (blocks[i][1] - blocks[i - hash_rate_range][1]);
|
||||
//std::setw(45) << epee::misc_utils::get_time_str(blocks[i][1])
|
||||
ss << std::left << std::setw(10) << i << std::left << std::setw(15) << blocks[i][1] << std::left << std::setw(15) << blocks[i][2]/120 << std::left << std::setw(20) << curren_hashrate << ENDL;
|
||||
}
|
||||
//blocks[i][4] = curren_hashrate;
|
||||
//ss << std::left << std::setw(10) << i << std::left << std::setw(15) << blocks[i][2] << std::left << std::setw(20) << blocks[i][4] << ENDL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue