forked from lthn/blockchain
fix that makes sure that daemon and wallet are 'on the same page' in terms of hardfork recognition
This commit is contained in:
parent
9efce2ddb3
commit
7ac70737dc
3 changed files with 16 additions and 0 deletions
|
|
@ -302,6 +302,7 @@ namespace currency
|
|||
res.status = API_RETURN_CODE_FAIL;
|
||||
return false;
|
||||
}
|
||||
res.current_hardfork = m_core.get_blockchain_storage().get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height);
|
||||
|
||||
for(auto& b: bs)
|
||||
{
|
||||
|
|
@ -339,6 +340,7 @@ namespace currency
|
|||
res.status = API_RETURN_CODE_FAIL;
|
||||
return false;
|
||||
}
|
||||
res.current_hardfork = m_core.get_blockchain_storage().get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height);
|
||||
|
||||
LOG_PRINT_L2("[on_get_blocks]: Enumerating over blocks ....");
|
||||
for (auto& b : bs)
|
||||
|
|
@ -357,6 +359,8 @@ namespace currency
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOG_PRINT_L2("[on_get_blocks]: Finished");
|
||||
res.status = API_RETURN_CODE_OK;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -274,12 +274,14 @@ namespace currency
|
|||
std::list<t_block_complete_entry> blocks;
|
||||
uint64_t start_height;
|
||||
uint64_t current_height;
|
||||
uint64_t current_hardfork;
|
||||
std::string status;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(blocks) DOC_DSCR("Bunch of blocks") DOC_EXMP_AUTO(1) DOC_END
|
||||
KV_SERIALIZE(start_height) DOC_DSCR("Starting height of the resulting bunch of blocks.") DOC_EXMP(2000000) DOC_END
|
||||
KV_SERIALIZE(current_height) DOC_DSCR("Current height of the blockchain.") DOC_EXMP(2555000) DOC_END
|
||||
KV_SERIALIZE(current_hardfork) DOC_DSCR("Current hardfork, used for wallet <-> version verification") DOC_EXMP(4) DOC_END
|
||||
KV_SERIALIZE(status) DOC_DSCR("Status of the call.") DOC_EXMP(API_RETURN_CODE_OK) DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2019,6 +2019,16 @@ void wallet2::pull_blocks(size_t& blocks_added, std::atomic<bool>& stop, bool& f
|
|||
"wrong daemon response: m_start_height=" + std::to_string(res.start_height) +
|
||||
" not less than local blockchain size=" + std::to_string(get_blockchain_current_size()));
|
||||
|
||||
//check if wallet are "on the same hardfork" with daemon with latest height of daemon
|
||||
if (res.current_hardfork != 0 && res.current_hardfork != get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height))
|
||||
{
|
||||
LOG_ERROR("Daemon currently on the hardfork (" << res.current_hardfork
|
||||
<< ") at heigh (" << res.current_height << "), while wallet think it's hardfork (" << get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height) << ") at a given height");
|
||||
THROW_IF_TRUE_WALLET_EX(true, error::wallet_internal_error, "Daemon and wallet ver validation failed, hardforks missmatch");
|
||||
}
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
handle_pulled_blocks(blocks_added, stop, res, full_reset_needed);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue