mirror of
https://github.com/monero-project/monero.git
synced 2025-08-04 06:04:17 -04:00
Update schema for "tx_outputs" to use array containing amount output indices
This speeds up wallet refresh by directly retrieving a tx's amount output indices.
It removes the indirection and walking the amount output duplicate list
for every amount in each requested tx.
"tx_outputs" is used by:
Amount output indices are needed for wallet refresh.
Global output indices are needed for removing a tx.
Both amount output indices and global output indices are now stored in
an array of 64-bit unsigned ints:
tx_outputs[<tx_hash>] -> [ <a1_oi, a1_gi, a2_oi, a2_gi, ...> ]
Previously it was:
tx_outputs[<tx_hash>] -> duplicate list of <a1_gi, a2_gi, a3_gi, ...>
The amount output list had to be walked for every amount in order to
find each amount's output index, by comparing the amount's global output
index with each one in the duplicate list until a match was found.
See also d045dfa7ce
This commit is contained in:
parent
309f8f3d44
commit
132c666f67
4 changed files with 134 additions and 122 deletions
|
@ -84,12 +84,19 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
|
|||
|
||||
add_transaction_data(blk_hash, tx, tx_hash);
|
||||
|
||||
std::vector<uint64_t> amount_output_indices;
|
||||
std::vector<uint64_t> global_output_indices;
|
||||
|
||||
// iterate tx.vout using indices instead of C++11 foreach syntax because
|
||||
// we need the index
|
||||
for (uint64_t i = 0; i < tx.vout.size(); ++i)
|
||||
{
|
||||
add_output(tx_hash, tx.vout[i], i, tx.unlock_time);
|
||||
uint64_t amount_output_index, global_output_index;
|
||||
add_output(tx_hash, tx.vout[i], i, tx.unlock_time, amount_output_index, global_output_index);
|
||||
amount_output_indices.push_back(amount_output_index);
|
||||
global_output_indices.push_back(global_output_index);
|
||||
}
|
||||
add_amount_and_global_output_indices(tx_hash, amount_output_indices, global_output_indices);
|
||||
}
|
||||
|
||||
uint64_t BlockchainDB::add_block( const block& blk
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue