1
0
Fork 0
forked from lthn/blockchain

added more debug info to pow verification

This commit is contained in:
crypro.zoidberg 2019-04-14 23:41:24 +02:00
parent 44fe6ada85
commit 47aa684f4d
4 changed files with 13 additions and 7 deletions

View file

@ -57,6 +57,14 @@ namespace currency
return result;
}
//---------------------------------------------------------------
crypto::hash get_block_header_mining_hash(const block& b)
{
blobdata bd = get_block_hashing_blob(b);
access_nonce_in_block_blob(bd) = 0;
return crypto::cn_fast_hash(bd.data(), bd.size());
}
//---------------------------------------------------------------
void get_block_longhash(const block& b, crypto::hash& res)
{
/*
@ -65,11 +73,7 @@ namespace currency
To achieve the same effect we make blob of data from block in normal way, but then set to zerro nonce
inside serialized buffer, and then pass this nonce to ethash algo as a second argument, as it expected.
*/
blobdata bd = get_block_hashing_blob(b);
access_nonce_in_block_blob(bd) = 0;
crypto::hash bl_hash = crypto::cn_fast_hash(bd.data(), bd.size());
crypto::hash bl_hash = get_block_header_mining_hash(b);
res = get_block_longhash(get_block_height(b), bl_hash, b.nonce);
}
//---------------------------------------------------------------

View file

@ -29,6 +29,7 @@ namespace currency
{
int ethash_height_to_epoch(uint64_t height);
crypto::hash ethash_epoch_to_seed(int epoch);
crypto::hash get_block_header_mining_hash(const block& b);
crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_header_hash, uint64_t nonce);
void get_block_longhash(const block& b, crypto::hash& res);
crypto::hash get_block_longhash(const block& b);

View file

@ -4297,6 +4297,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
LOG_ERROR("Block with id: " << id << ENDL
<< "PoW hash: " << proof_hash << ENDL
<< "nonce: " << bl.nonce << ENDL
<< "header_mining_hash: " << get_block_header_mining_hash(bl) << ENDL
<< "expected difficulty: " << current_diffic);
bvc.m_verification_failed = true;
return false;

View file

@ -821,7 +821,7 @@ namespace
}
m_json_helper.feed(str, data_size);
LP_CC_WORKER(m_context, "data received: " << data_size << " bytes:" << ENDL << std::string(str, data_size), LOG_LEVEL_4);
LP_CC_WORKER(m_context, "DATA received <<<<<<<<<<<<< " << data_size << " bytes:" << ENDL << std::string(str, data_size), LOG_LEVEL_0);
if (m_json_helper.has_objects())
{
@ -975,7 +975,7 @@ namespace
void send(const std::string& data)
{
static_cast<epee::net_utils::i_service_endpoint*>(m_p_connection)->do_send(data.c_str(), data.size());
LOG_PRINT_CC(m_context, "DATA sent >>>>>>>>>>>>> " << ENDL << data, LOG_LEVEL_4);
LOG_PRINT_CC(m_context, "DATA sent >>>>>>>>>>>>> " << ENDL << data, LOG_LEVEL_0);
}
void send_notification(const std::string& json)