forked from lthn/blockchain
Fix #482 suggested by @jeffro256
This commit is contained in:
parent
d63feec2e1
commit
6a7c29be51
3 changed files with 10 additions and 8 deletions
|
|
@ -81,7 +81,7 @@ namespace currency
|
|||
{
|
||||
blobdata bd = get_block_hashing_blob(b);
|
||||
|
||||
access_nonce_in_block_blob(bd) = 0;
|
||||
set_nonce_to_blockblob(bd, 0);
|
||||
return crypto::cn_fast_hash(bd.data(), bd.size());
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -34,13 +34,15 @@ namespace currency
|
|||
void get_block_longhash(const block& b, crypto::hash& res);
|
||||
crypto::hash get_block_longhash(const block& b);
|
||||
|
||||
inline uint64_t& access_nonce_in_block_blob(blobdata& bd)
|
||||
inline uint64_t get_nonce_from_blockblob(const blobdata& bd)
|
||||
{
|
||||
return *reinterpret_cast<uint64_t*>(&bd[CURRENCY_MINER_BLOCK_BLOB_NONCE_OFFSET]);
|
||||
uint64_t nonce = 0;
|
||||
std::memcpy(&nonce, &bd[CURRENCY_MINER_BLOCK_BLOB_NONCE_OFFSET], sizeof(nonce));
|
||||
return nonce;
|
||||
}
|
||||
|
||||
inline const uint64_t& access_nonce_in_block_blob(const blobdata& bd)
|
||||
inline void set_nonce_to_blockblob(blobdata& bd, const uint64_t nonce)
|
||||
{
|
||||
return *reinterpret_cast<const uint64_t*>(&bd[CURRENCY_MINER_BLOCK_BLOB_NONCE_OFFSET]);
|
||||
std::memcpy(&bd[CURRENCY_MINER_BLOCK_BLOB_NONCE_OFFSET], &nonce, sizeof(nonce));
|
||||
}
|
||||
}
|
||||
|
|
@ -402,11 +402,11 @@ namespace
|
|||
#endif
|
||||
m_blockchain_last_block_id = top_block_id;
|
||||
|
||||
m_block_template_hash_blob = get_block_hashing_blob(m_block_template);
|
||||
if (access_nonce_in_block_blob(m_block_template_hash_blob) != 0)
|
||||
m_block_template_hash_blob = get_block_hashing_blob(m_block_template);
|
||||
if (get_nonce_from_blockblob(m_block_template_hash_blob) != 0)
|
||||
{
|
||||
LOG_PRINT_RED("non-zero nonce in generated block template", LOG_LEVEL_0);
|
||||
access_nonce_in_block_blob(m_block_template_hash_blob) = 0;
|
||||
set_nonce_to_blockblob(m_block_template_hash_blob, 0);
|
||||
}
|
||||
m_prev_block_template_ethash = m_block_template_ethash;
|
||||
m_block_template_ethash = crypto::cn_fast_hash(m_block_template_hash_blob.data(), m_block_template_hash_blob.size());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue