Merge pull request #4731

f26ce08c wallet: add a non destructive blockchain rescan (moneromooo-monero)
This commit is contained in:
Riccardo Spagni
2018-11-06 21:30:12 +02:00
6 changed files with 54 additions and 17 deletions
+19 -3
View File
@@ -5105,11 +5105,27 @@ void wallet2::rescan_spent()
}
}
//----------------------------------------------------------------------------------------------------
void wallet2::rescan_blockchain(bool refresh)
void wallet2::rescan_blockchain(bool hard, bool refresh)
{
clear();
if(hard)
{
clear();
setup_new_blockchain();
}
else
{
m_blockchain.clear();
m_transfers.clear();
m_key_images.clear();
m_pub_keys.clear();
m_scanned_pool_txs[0].clear();
m_scanned_pool_txs[1].clear();
setup_new_blockchain();
cryptonote::block b;
generate_genesis(b);
m_blockchain.push_back(get_block_hash(b));
m_last_block_reward = cryptonote::get_outs_money_amount(b.miner_tx);
}
if (refresh)
this->refresh(false);
+1 -1
View File
@@ -788,7 +788,7 @@ namespace tools
uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); }
void rescan_spent();
void rescan_blockchain(bool refresh = true);
void rescan_blockchain(bool hard, bool refresh = true);
bool is_transfer_unlocked(const transfer_details& td) const;
bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) const;
+1 -1
View File
@@ -1781,7 +1781,7 @@ namespace tools
try
{
m_wallet->rescan_blockchain();
m_wallet->rescan_blockchain(req.hard);
}
catch (const std::exception& e)
{
@@ -1057,7 +1057,10 @@ namespace wallet_rpc
{
struct request
{
bool hard;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_OPT(hard, false);
END_KV_SERIALIZE_MAP()
};