1
0
Fork 0
forked from lthn/blockchain

fixed bug in miner, added demangling for callstacks

This commit is contained in:
crypro.zoidberg 2019-01-23 21:13:26 +03:00
parent b42bf9f6f0
commit 29a6d0bce4
3 changed files with 24 additions and 5 deletions

View file

@ -111,6 +111,7 @@ namespace misc_utils
#if defined(__GNUC__)
#include <execinfo.h>
#include <boost/core/demangle.hpp>
#endif
inline std::string print_trace()
{
@ -125,9 +126,9 @@ namespace misc_utils
stack_depth = backtrace(stack_addrs, max_depth);
stack_strings = backtrace_symbols(stack_addrs, stack_depth);
for (size_t i = 1; i < stack_depth; i++) {
ss << stack_strings[i] << std::endl;
for (size_t i = 1; i < stack_depth; i++)
{
ss << boost::core::demangle(stack_strings[i]) << std::endl;
}
free(stack_strings); // malloc()ed by backtrace_symbols
#endif

View file

@ -27,13 +27,13 @@ namespace currency
}
crypto::hash scratchpad_keeper::get_pow_hash(const blobdata& bd, uint64_t height, const crypto::hash& scr_seed)
{
CRITICAL_REGION_BEGIN(m_lock);
crypto::hash res_hash = null_hash;
if (scr_seed != m_seed || get_scratchpad_size_for_height(height) != this->size())
{
bool r = generate(scr_seed, height);
CHECK_AND_ASSERT_THROW_MES(r, "Unable to generate scratchpad");
}
CRITICAL_REGION_BEGIN(m_lock);
CHECK_AND_ASSERT_THROW_MES(get_scratchpad_size_for_height(height) == this->size(), "Fatal error on hash calculation: scratchpad_size=" << m_scratchpad.size() << " at height=" << height << ", scr_seed=" << scr_seed << ", m_seed=" << m_seed);
CHECK_AND_ASSERT_THROW_MES(scr_seed == m_seed, "Fatal error on hash calculation: scratchpad_seed missmatch scr_seed=" << scr_seed << ", m_seed=" << m_seed);

View file

@ -34,10 +34,28 @@ void run_difficulty_analysis(const std::string& path)
std::transform(tok.begin(), tok.end(), std::back_inserter(array_num),
&boost::lexical_cast<uint64_t, std::string>);
array_num.push_back(0); //reserve space for hashrate value
blocks.push_back(array_num);
}
LOG_PRINT_L0("Loaded " << blocks.size() << " lines");
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++)
{
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;
}
//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;
}
std::string res_path = path + "hashrate.txt";
file_io_utils::save_string_to_file(res_path, ss.str());
LOG_PRINT_L0("Done, saved to file " << res_path);
return;
}