diff options
author | warptangent <warptangent@tutanota.com> | 2016-01-31 05:10:14 -0800 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2016-04-05 20:30:50 +0100 |
commit | 132c666f67937676bea1cc145c242b857f9852a2 (patch) | |
tree | 2496f5c995ba5e2b1100b8e318bd7d751f7cbf51 /src/blockchain_db/lmdb/db_lmdb.h | |
parent | blockchain_utilities: Update documentation (diff) | |
download | monero-132c666f67937676bea1cc145c242b857f9852a2.tar.xz |
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 d045dfa7ce0bf131681193c97560da26f9f37900
Diffstat (limited to 'src/blockchain_db/lmdb/db_lmdb.h')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index e58643efa..8f80b8c7e 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -246,7 +246,10 @@ public: virtual void get_output_tx_and_index(const uint64_t& amount, const std::vector<uint64_t> &offsets, std::vector<tx_out_index> &indices); virtual void get_output_global_indices(const uint64_t& amount, const std::vector<uint64_t> &offsets, std::vector<uint64_t> &indices); - virtual std::vector<uint64_t> get_tx_output_indices(const crypto::hash& h) const; + virtual void get_amount_and_global_output_indices(const crypto::hash& h, + std::vector<uint64_t>& amount_output_indices, + std::vector<uint64_t>& global_output_indices) const; + virtual std::vector<uint64_t> get_tx_amount_output_indices(const crypto::hash& h) const; virtual bool has_key_image(const crypto::key_image& img) const; @@ -298,7 +301,18 @@ private: virtual void remove_transaction_data(const crypto::hash& tx_hash, const transaction& tx); - virtual void add_output(const crypto::hash& tx_hash, const tx_out& tx_output, const uint64_t& local_index, const uint64_t unlock_time); + virtual void add_output(const crypto::hash& tx_hash, + const tx_out& tx_output, + const uint64_t& local_index, + const uint64_t unlock_time, + uint64_t& amount_output_index, + uint64_t& global_output_index + ); + + virtual void add_amount_and_global_output_indices(const crypto::hash& tx_hash, + const std::vector<uint64_t>& amount_output_indices, + const std::vector<uint64_t>& global_output_indices + ); virtual void remove_output(const tx_out& tx_output); |