blockchain: fix returned height in create_block_template

It's now needed for CNv4, and was not retained when cached
This commit is contained in:
moneromooo-monero 2019-03-30 20:25:40 +00:00
parent 423d3bb86b
commit aff80e7043
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
2 changed files with 6 additions and 3 deletions

View File

@ -1326,6 +1326,7 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
m_btc.timestamp = time(NULL); // update timestamp unconditionally m_btc.timestamp = time(NULL); // update timestamp unconditionally
b = m_btc; b = m_btc;
diffic = m_btc_difficulty; diffic = m_btc_difficulty;
height = m_btc_height;
expected_reward = m_btc_expected_reward; expected_reward = m_btc_expected_reward;
return true; return true;
} }
@ -1470,7 +1471,7 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
", cumulative weight " << cumulative_weight << " is now good"); ", cumulative weight " << cumulative_weight << " is now good");
#endif #endif
cache_block_template(b, miner_address, ex_nonce, diffic, expected_reward, pool_cookie); cache_block_template(b, miner_address, ex_nonce, diffic, height, expected_reward, pool_cookie);
return true; return true;
} }
LOG_ERROR("Failed to create_block_template with " << 10 << " tries"); LOG_ERROR("Failed to create_block_template with " << 10 << " tries");
@ -4838,13 +4839,14 @@ void Blockchain::invalidate_block_template_cache()
m_btc_valid = false; m_btc_valid = false;
} }
void Blockchain::cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t expected_reward, uint64_t pool_cookie) void Blockchain::cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t height, uint64_t expected_reward, uint64_t pool_cookie)
{ {
MDEBUG("Setting block template cache"); MDEBUG("Setting block template cache");
m_btc = b; m_btc = b;
m_btc_address = address; m_btc_address = address;
m_btc_nonce = nonce; m_btc_nonce = nonce;
m_btc_difficulty = diff; m_btc_difficulty = diff;
m_btc_height = height;
m_btc_expected_reward = expected_reward; m_btc_expected_reward = expected_reward;
m_btc_pool_cookie = pool_cookie; m_btc_pool_cookie = pool_cookie;
m_btc_valid = true; m_btc_valid = true;

View File

@ -1092,6 +1092,7 @@ namespace cryptonote
account_public_address m_btc_address; account_public_address m_btc_address;
blobdata m_btc_nonce; blobdata m_btc_nonce;
difficulty_type m_btc_difficulty; difficulty_type m_btc_difficulty;
uint64_t m_btc_height;
uint64_t m_btc_pool_cookie; uint64_t m_btc_pool_cookie;
uint64_t m_btc_expected_reward; uint64_t m_btc_expected_reward;
bool m_btc_valid; bool m_btc_valid;
@ -1462,6 +1463,6 @@ namespace cryptonote
* *
* At some point, may be used to push an update to miners * At some point, may be used to push an update to miners
*/ */
void cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t expected_reward, uint64_t pool_cookie); void cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t height, uint64_t expected_reward, uint64_t pool_cookie);
}; };
} // namespace cryptonote } // namespace cryptonote