mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
Merge pull request #827
f1e70d1
Only log 1/N skipped blocks (Howard Chu)cebb97c
Move refresh height to keys file from cache file (Howard Chu)590c439
Make fast_refresh interruptible (Howard Chu)687855d
Set refresh height earlier (Howard Chu)2fb00c0
Fix19fe8ae3ef
(Howard Chu)
This commit is contained in:
commit
ae205020f6
@ -1010,6 +1010,7 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
|
|||||||
|
|
||||||
m_wallet.reset(new tools::wallet2(testnet));
|
m_wallet.reset(new tools::wallet2(testnet));
|
||||||
m_wallet->callback(this);
|
m_wallet->callback(this);
|
||||||
|
m_wallet->set_refresh_from_block_height(field_scan_from_height);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1055,8 +1056,6 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_wallet->set_refresh_from_block_height(field_scan_from_height);
|
|
||||||
|
|
||||||
wallet_file = m_wallet_file;
|
wallet_file = m_wallet_file;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@ -1175,7 +1174,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_restore_height)
|
if (!m_restore_height && m_generate_new.empty())
|
||||||
{
|
{
|
||||||
std::string heightstr = command_line::input_line("Restore from specific blockchain height (optional, default 0): ");
|
std::string heightstr = command_line::input_line("Restore from specific blockchain height (optional, default 0): ");
|
||||||
if (std::cin.eof())
|
if (std::cin.eof())
|
||||||
@ -1451,6 +1450,16 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
m_wallet->callback(this);
|
m_wallet->callback(this);
|
||||||
m_wallet->set_seed_language(mnemonic_language);
|
m_wallet->set_seed_language(mnemonic_language);
|
||||||
|
|
||||||
|
// for a totally new account, we don't care about older blocks.
|
||||||
|
if (!m_generate_new.empty())
|
||||||
|
{
|
||||||
|
std::string err;
|
||||||
|
m_wallet->set_refresh_from_block_height(get_daemon_blockchain_height(err));
|
||||||
|
} else if (m_restore_height)
|
||||||
|
{
|
||||||
|
m_wallet->set_refresh_from_block_height(m_restore_height);
|
||||||
|
}
|
||||||
|
|
||||||
crypto::secret_key recovery_val;
|
crypto::secret_key recovery_val;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1466,15 +1475,6 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_wallet->init(m_daemon_address);
|
m_wallet->init(m_daemon_address);
|
||||||
// for a totally new account, we don't care about older blocks.
|
|
||||||
if (!m_restore_deterministic_wallet)
|
|
||||||
{
|
|
||||||
std::string err;
|
|
||||||
m_wallet->set_refresh_from_block_height(get_daemon_blockchain_height(err));
|
|
||||||
} else if (m_restore_height)
|
|
||||||
{
|
|
||||||
m_wallet->set_refresh_from_block_height(m_restore_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert rng value to electrum-style word list
|
// convert rng value to electrum-style word list
|
||||||
std::string electrum_words;
|
std::string electrum_words;
|
||||||
@ -1507,6 +1507,8 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
|
|
||||||
m_wallet.reset(new tools::wallet2(testnet));
|
m_wallet.reset(new tools::wallet2(testnet));
|
||||||
m_wallet->callback(this);
|
m_wallet->callback(this);
|
||||||
|
if (m_restore_height)
|
||||||
|
m_wallet->set_refresh_from_block_height(m_restore_height);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1522,7 +1524,6 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_wallet->init(m_daemon_address);
|
m_wallet->init(m_daemon_address);
|
||||||
m_wallet->set_refresh_from_block_height(m_restore_height);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1534,6 +1535,8 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
|
|
||||||
m_wallet.reset(new tools::wallet2(testnet));
|
m_wallet.reset(new tools::wallet2(testnet));
|
||||||
m_wallet->callback(this);
|
m_wallet->callback(this);
|
||||||
|
if (m_restore_height)
|
||||||
|
m_wallet->set_refresh_from_block_height(m_restore_height);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1548,7 +1551,6 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_wallet->init(m_daemon_address);
|
m_wallet->init(m_daemon_address);
|
||||||
m_wallet->set_refresh_from_block_height(m_restore_height);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +519,8 @@ void wallet2::process_new_blockchain_entry(const cryptonote::block& b, const cry
|
|||||||
LOG_PRINT_L2("Processed block: " << bl_id << ", height " << height << ", " << miner_tx_handle_time + txs_handle_time << "(" << miner_tx_handle_time << "/" << txs_handle_time <<")ms");
|
LOG_PRINT_L2("Processed block: " << bl_id << ", height " << height << ", " << miner_tx_handle_time + txs_handle_time << "(" << miner_tx_handle_time << "/" << txs_handle_time <<")ms");
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
LOG_PRINT_L2( "Skipped block by timestamp, height: " << height << ", block time " << b.timestamp << ", account time " << m_account.get_createtime());
|
if (!(height % 100))
|
||||||
|
LOG_PRINT_L2( "Skipped block by timestamp, height: " << height << ", block time " << b.timestamp << ", account time " << m_account.get_createtime());
|
||||||
}
|
}
|
||||||
m_blockchain.push_back(bl_id);
|
m_blockchain.push_back(bl_id);
|
||||||
++m_local_bc_height;
|
++m_local_bc_height;
|
||||||
@ -796,7 +797,8 @@ void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height,
|
|||||||
{
|
{
|
||||||
std::list<crypto::hash> hashes;
|
std::list<crypto::hash> hashes;
|
||||||
size_t current_index = m_blockchain.size();
|
size_t current_index = m_blockchain.size();
|
||||||
while(current_index < stop_height)
|
|
||||||
|
while(m_run.load(std::memory_order_relaxed) && current_index < stop_height)
|
||||||
{
|
{
|
||||||
pull_hashes(0, blocks_start_height, short_chain_history, hashes);
|
pull_hashes(0, blocks_start_height, short_chain_history, hashes);
|
||||||
if (hashes.size() < 3)
|
if (hashes.size() < 3)
|
||||||
@ -823,7 +825,8 @@ void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height,
|
|||||||
{
|
{
|
||||||
if(current_index >= m_blockchain.size())
|
if(current_index >= m_blockchain.size())
|
||||||
{
|
{
|
||||||
LOG_PRINT_L2( "Skipped block by height: " << current_index);
|
if (!(current_index % 1000))
|
||||||
|
LOG_PRINT_L2( "Skipped block by height: " << current_index);
|
||||||
m_blockchain.push_back(bl_id);
|
m_blockchain.push_back(bl_id);
|
||||||
++m_local_bc_height;
|
++m_local_bc_height;
|
||||||
|
|
||||||
@ -860,6 +863,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re
|
|||||||
|
|
||||||
// pull the first set of blocks
|
// pull the first set of blocks
|
||||||
get_short_chain_history(short_chain_history);
|
get_short_chain_history(short_chain_history);
|
||||||
|
m_run.store(true, std::memory_order_relaxed);
|
||||||
if (start_height > m_blockchain.size() || m_refresh_from_block_height > m_blockchain.size()) {
|
if (start_height > m_blockchain.size() || m_refresh_from_block_height > m_blockchain.size()) {
|
||||||
if (!start_height)
|
if (!start_height)
|
||||||
start_height = m_refresh_from_block_height;
|
start_height = m_refresh_from_block_height;
|
||||||
@ -877,7 +881,6 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re
|
|||||||
// subsequent pulls in this refresh.
|
// subsequent pulls in this refresh.
|
||||||
start_height = 0;
|
start_height = 0;
|
||||||
|
|
||||||
m_run.store(true, std::memory_order_relaxed);
|
|
||||||
while(m_run.load(std::memory_order_relaxed))
|
while(m_run.load(std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1057,6 +1060,9 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p
|
|||||||
value2.SetInt(m_refresh_type);
|
value2.SetInt(m_refresh_type);
|
||||||
json.AddMember("refresh_type", value2, json.GetAllocator());
|
json.AddMember("refresh_type", value2, json.GetAllocator());
|
||||||
|
|
||||||
|
value2.SetUint64(m_refresh_from_block_height);
|
||||||
|
json.AddMember("refresh_height", value2, json.GetAllocator());
|
||||||
|
|
||||||
// Serialize the JSON object
|
// Serialize the JSON object
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
@ -1163,6 +1169,9 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
|||||||
else
|
else
|
||||||
LOG_PRINT_L0("Unknown refresh-type value (" << field_refresh_type << "), using default");
|
LOG_PRINT_L0("Unknown refresh-type value (" << field_refresh_type << "), using default");
|
||||||
}
|
}
|
||||||
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_height, uint64_t, Uint64, false);
|
||||||
|
if (field_refresh_height_found)
|
||||||
|
m_refresh_from_block_height = field_refresh_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cryptonote::account_keys& keys = m_account.get_keys();
|
const cryptonote::account_keys& keys = m_account.get_keys();
|
||||||
|
@ -308,6 +308,7 @@ namespace tools
|
|||||||
template <class t_archive>
|
template <class t_archive>
|
||||||
inline void serialize(t_archive &a, const unsigned int ver)
|
inline void serialize(t_archive &a, const unsigned int ver)
|
||||||
{
|
{
|
||||||
|
uint64_t dummy_refresh_height = 0; // moved to keys file
|
||||||
if(ver < 5)
|
if(ver < 5)
|
||||||
return;
|
return;
|
||||||
a & m_blockchain;
|
a & m_blockchain;
|
||||||
@ -328,7 +329,7 @@ namespace tools
|
|||||||
a & m_confirmed_txs;
|
a & m_confirmed_txs;
|
||||||
if(ver < 11)
|
if(ver < 11)
|
||||||
return;
|
return;
|
||||||
a & m_refresh_from_block_height;
|
a & dummy_refresh_height;
|
||||||
if(ver < 12)
|
if(ver < 12)
|
||||||
return;
|
return;
|
||||||
a & m_tx_notes;
|
a & m_tx_notes;
|
||||||
|
Loading…
Reference in New Issue
Block a user