mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-23 13:47:47 +00:00
wallet2: skip derivation precalc for blocks we know we'll skip
This commit is contained in:
parent
e4b049da05
commit
d45b85e170
2 changed files with 24 additions and 1 deletions
|
@ -2165,6 +2165,12 @@ void wallet2::process_outgoing(const crypto::hash &txid, const cryptonote::trans
|
|||
add_rings(tx);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::should_skip_block(const cryptonote::block &b, uint64_t height) const
|
||||
{
|
||||
// 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
|
||||
return !(b.timestamp + 60*60*24 > m_account.get_createtime() && height >= m_refresh_from_block_height);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::process_new_blockchain_entry(const cryptonote::block& b, const cryptonote::block_complete_entry& bche, const parsed_block &parsed_block, const crypto::hash& bl_id, uint64_t height, const std::vector<tx_cache_data> &tx_cache_data, size_t tx_cache_data_offset, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache)
|
||||
{
|
||||
THROW_WALLET_EXCEPTION_IF(bche.txs.size() + 1 != parsed_block.o_indices.indices.size(), error::wallet_internal_error,
|
||||
|
@ -2174,7 +2180,7 @@ void wallet2::process_new_blockchain_entry(const cryptonote::block& b, const cry
|
|||
//handle transactions from new block
|
||||
|
||||
//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
|
||||
if(b.timestamp + 60*60*24 > m_account.get_createtime() && height >= m_refresh_from_block_height)
|
||||
if (!should_skip_block(b, height))
|
||||
{
|
||||
TIME_MEASURE_START(miner_tx_handle_time);
|
||||
if (m_refresh_type != RefreshNoCoinbase)
|
||||
|
@ -2306,6 +2312,11 @@ void wallet2::process_parsed_blocks(uint64_t start_height, const std::vector<cry
|
|||
{
|
||||
THROW_WALLET_EXCEPTION_IF(parsed_blocks[i].txes.size() != parsed_blocks[i].block.tx_hashes.size(),
|
||||
error::wallet_internal_error, "Mismatched parsed_blocks[i].txes.size() and parsed_blocks[i].block.tx_hashes.size()");
|
||||
if (should_skip_block(parsed_blocks[i].block, start_height + i))
|
||||
{
|
||||
txidx += 1 + parsed_blocks[i].block.tx_hashes.size();
|
||||
continue;
|
||||
}
|
||||
if (m_refresh_type != RefreshNoCoinbase)
|
||||
tpool.submit(&waiter, [&, i, txidx](){ cache_tx_data(parsed_blocks[i].block.miner_tx, get_transaction_hash(parsed_blocks[i].block.miner_tx), tx_cache_data[txidx]); });
|
||||
++txidx;
|
||||
|
@ -2334,6 +2345,8 @@ void wallet2::process_parsed_blocks(uint64_t start_height, const std::vector<cry
|
|||
|
||||
for (size_t i = 0; i < tx_cache_data.size(); ++i)
|
||||
{
|
||||
if (tx_cache_data[i].empty())
|
||||
continue;
|
||||
tpool.submit(&waiter, [&hwdev, &gender, &tx_cache_data, i]() {
|
||||
auto &slot = tx_cache_data[i];
|
||||
boost::unique_lock<hw::device> hwdev_lock(hwdev);
|
||||
|
@ -2352,6 +2365,7 @@ void wallet2::process_parsed_blocks(uint64_t start_height, const std::vector<cry
|
|||
if (o.target.type() == typeid(cryptonote::txout_to_key))
|
||||
{
|
||||
std::vector<crypto::key_derivation> additional_derivations;
|
||||
additional_derivations.reserve(tx_cache_data[txidx].additional.size());
|
||||
for (const auto &iod: tx_cache_data[txidx].additional)
|
||||
additional_derivations.push_back(iod.derivation);
|
||||
const auto &key = boost::get<txout_to_key>(o.target).key;
|
||||
|
@ -2369,6 +2383,12 @@ void wallet2::process_parsed_blocks(uint64_t start_height, const std::vector<cry
|
|||
txidx = 0;
|
||||
for (size_t i = 0; i < blocks.size(); ++i)
|
||||
{
|
||||
if (should_skip_block(parsed_blocks[i].block, start_height + i))
|
||||
{
|
||||
txidx += 1 + parsed_blocks[i].block.tx_hashes.size();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_refresh_type != RefreshType::RefreshNoCoinbase)
|
||||
{
|
||||
THROW_WALLET_EXCEPTION_IF(txidx >= tx_cache_data.size(), error::wallet_internal_error, "txidx out of range");
|
||||
|
|
|
@ -530,6 +530,8 @@ namespace tools
|
|||
std::vector<cryptonote::tx_extra_field> tx_extra_fields;
|
||||
std::vector<is_out_data> primary;
|
||||
std::vector<is_out_data> additional;
|
||||
|
||||
bool empty() const { return tx_extra_fields.empty() && primary.empty() && additional.empty(); }
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -1277,6 +1279,7 @@ namespace tools
|
|||
*/
|
||||
bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password);
|
||||
void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, uint64_t height, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
|
||||
bool should_skip_block(const cryptonote::block &b, uint64_t height) const;
|
||||
void process_new_blockchain_entry(const cryptonote::block& b, const cryptonote::block_complete_entry& bche, const parsed_block &parsed_block, const crypto::hash& bl_id, uint64_t height, const std::vector<tx_cache_data> &tx_cache_data, size_t tx_cache_data_offset, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
|
||||
void detach_blockchain(uint64_t height);
|
||||
void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
|
||||
|
|
Loading…
Reference in a new issue