forked from lthn/blockchain
fixed wallet bugs related to new sync protocol
This commit is contained in:
parent
fb2ed72086
commit
60101dc1f5
6 changed files with 21 additions and 16 deletions
|
|
@ -118,9 +118,9 @@ namespace tools
|
|||
|
||||
DWORD cb_needed;
|
||||
std::vector<HMODULE> module_handles(1);
|
||||
EnumProcessModules(h_process, &module_handles[0], module_handles.size() * sizeof(HMODULE), &cb_needed);
|
||||
EnumProcessModules(h_process, &module_handles[0], static_cast<DWORD>(module_handles.size() * sizeof(HMODULE)), &cb_needed);
|
||||
module_handles.resize(cb_needed / sizeof(HMODULE));
|
||||
EnumProcessModules(h_process, &module_handles[0], module_handles.size() * sizeof(HMODULE), &cb_needed);
|
||||
EnumProcessModules(h_process, &module_handles[0], static_cast<DWORD>(module_handles.size() * sizeof(HMODULE)), &cb_needed);
|
||||
|
||||
std::vector<module_data> modules;
|
||||
std::transform(module_handles.begin(), module_handles.end(), std::back_inserter(modules), get_mod_info(h_process));
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ namespace currency
|
|||
crypto::secret_key view_secret_key;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(account_address)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(spend_secret_key)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(view_secret_key)
|
||||
KV_SERIALIZE_N(account_address, "m_account_address")
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(spend_secret_key, "m_spend_secret_key")
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(view_secret_key, "m_view_secret_key")
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ namespace currency
|
|||
END_SERIALIZE()
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(spend_public_key)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(view_public_key)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(spend_public_key, "m_spend_public_key")
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(view_public_key, "m_view_public_key")
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
|
|
|||
|
|
@ -1070,7 +1070,7 @@ void wallet2::process_unconfirmed(const currency::transaction& tx, std::vector<s
|
|||
void wallet2::process_new_blockchain_entry(const currency::block& b, const currency::block_direct_data_entry& bche, const crypto::hash& bl_id, uint64_t height)
|
||||
{
|
||||
//handle transactions from new block
|
||||
THROW_IF_TRUE_WALLET_EX(height != get_blockchain_current_size(), error::wallet_internal_error,
|
||||
THROW_IF_TRUE_WALLET_EX(height != get_blockchain_current_size() && !(height == m_minimum_height && get_blockchain_current_size() <= 1), error::wallet_internal_error,
|
||||
"current_index=" + std::to_string(height) + ", get_blockchain_current_height()=" + std::to_string(get_blockchain_current_size()));
|
||||
|
||||
//optimization: seeking only for blocks that are not older then the wallet creation time plus 1 day. 1 day is for possible user incorrect time setup
|
||||
|
|
@ -1137,7 +1137,8 @@ void wallet2::set_minimum_height(uint64_t h)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
uint64_t wallet2::get_wallet_minimum_height()
|
||||
{
|
||||
if (m_minimum_height)
|
||||
|
||||
if (m_minimum_height != WALLET_MINIMUM_HEIGHT_UNSET_CONST)
|
||||
return m_minimum_height;
|
||||
|
||||
currency::COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE::request req = AUTO_VAL_INIT(req);
|
||||
|
|
@ -1146,6 +1147,7 @@ uint64_t wallet2::get_wallet_minimum_height()
|
|||
bool r = m_core_proxy->call_COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE(req, res);
|
||||
THROW_IF_FALSE_WALLET_EX(r, error::no_connection_to_daemon, "call_COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE");
|
||||
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(res.status == CORE_RPC_STATUS_OK, "FAILED TO CALL COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE");
|
||||
m_minimum_height = res.h;
|
||||
return res.h;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
@ -1191,7 +1193,7 @@ void wallet2::pull_blocks(size_t& blocks_added, std::atomic<bool>& stop)
|
|||
return;
|
||||
}
|
||||
THROW_IF_TRUE_WALLET_EX(res.status != CORE_RPC_STATUS_OK, error::get_blocks_error, res.status);
|
||||
THROW_IF_TRUE_WALLET_EX(get_blockchain_current_size() && get_blockchain_current_size() <= res.start_height, error::wallet_internal_error,
|
||||
THROW_IF_TRUE_WALLET_EX(get_blockchain_current_size() && get_blockchain_current_size() <= res.start_height && res.start_height != m_minimum_height, error::wallet_internal_error,
|
||||
"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()));
|
||||
|
||||
|
|
@ -1227,7 +1229,7 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic<bool>& stop
|
|||
//TODO: get_block_hash is slow
|
||||
crypto::hash bl_id = get_block_hash(bl);
|
||||
|
||||
if (height > processed_blocks_count)
|
||||
if (processed_blocks_count != 1 && height > processed_blocks_count)
|
||||
{//internal error:
|
||||
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false,
|
||||
"height{" << height <<"} > processed_blocks_count{" << processed_blocks_count << "}");
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#define WALLET_DEFAULT_POS_MINT_PACKING_SIZE 100
|
||||
|
||||
const uint64_t WALLET_MINIMUM_HEIGHT_UNSET_CONST = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
#undef LOG_DEFAULT_CHANNEL
|
||||
#define LOG_DEFAULT_CHANNEL "wallet"
|
||||
|
|
@ -318,7 +319,7 @@ namespace tools
|
|||
m_do_rise_transfer(false),
|
||||
m_watch_only(false),
|
||||
m_last_pow_block_h(0),
|
||||
m_minimum_height(0),
|
||||
m_minimum_height(WALLET_MINIMUM_HEIGHT_UNSET_CONST),
|
||||
m_pos_mint_packing_size(WALLET_DEFAULT_POS_MINT_PACKING_SIZE)
|
||||
{};
|
||||
public:
|
||||
|
|
@ -333,7 +334,7 @@ namespace tools
|
|||
m_log_prefix("???"),
|
||||
m_watch_only(false),
|
||||
m_last_pow_block_h(0),
|
||||
m_minimum_height(0),
|
||||
m_minimum_height(WALLET_MINIMUM_HEIGHT_UNSET_CONST),
|
||||
m_pos_mint_packing_size(WALLET_DEFAULT_POS_MINT_PACKING_SIZE)
|
||||
{
|
||||
m_core_runtime_config = currency::get_default_core_runtime_config();
|
||||
|
|
@ -677,7 +678,7 @@ namespace tools
|
|||
}
|
||||
}
|
||||
//convert from old version
|
||||
if (ver < CURRENCY_FORMATION_VERSION + 65)
|
||||
if (ver < 150)
|
||||
{
|
||||
LOG_PRINT_MAGENTA("Converting blockchain into a short form...", LOG_LEVEL_0);
|
||||
std::vector<crypto::hash> old_blockchain;
|
||||
|
|
@ -686,12 +687,14 @@ namespace tools
|
|||
for (auto& h : old_blockchain)
|
||||
{
|
||||
m_chain.push_new_block_id(h, count);
|
||||
count++;
|
||||
}
|
||||
LOG_PRINT_MAGENTA("Converting done", LOG_LEVEL_0);
|
||||
}
|
||||
else
|
||||
{
|
||||
a & m_chain;
|
||||
a & m_minimum_height;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,12 +61,12 @@ void wallet_chain_shortener::push_new_block_id(const crypto::hash& id, uint64_t
|
|||
|
||||
//primary 10
|
||||
//self check
|
||||
if (!m_last_20_blocks.empty())
|
||||
if (m_local_bc_size != 1)
|
||||
{
|
||||
THROW_IF_FALSE_WALLET_INT_ERR_EX(get_blockchain_current_size() == height, "Inernal error: get_blockchain_current_height(){" << get_blockchain_current_size() << "} == height{" << height << "} is not equal");
|
||||
}
|
||||
|
||||
m_local_bc_size++;
|
||||
m_local_bc_size = height+1;
|
||||
m_last_20_blocks[height] = id;
|
||||
if (m_last_20_blocks.size() > WALLET_EVERYBLOCK_SIZE)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue