diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-20 20:19:39 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-05 11:58:05 +0000 |
commit | 79b4e9f3779796d9233e3e169f5c1086a49717dd (patch) | |
tree | 6ca8ebd03038cb703ffc89cab72482ce9e31a271 /tests/unit_tests/long_term_block_weight.cpp | |
parent | blockchain: avoid pointless transaction copy and temporary (diff) | |
download | monero-79b4e9f3779796d9233e3e169f5c1086a49717dd.tar.xz |
save some database calls when getting top block hash and height
Diffstat (limited to 'tests/unit_tests/long_term_block_weight.cpp')
-rw-r--r-- | tests/unit_tests/long_term_block_weight.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/unit_tests/long_term_block_weight.cpp b/tests/unit_tests/long_term_block_weight.cpp index 113b01865..f37b608b6 100644 --- a/tests/unit_tests/long_term_block_weight.cpp +++ b/tests/unit_tests/long_term_block_weight.cpp @@ -64,11 +64,13 @@ public: virtual uint64_t height() const override { return blocks.size(); } virtual size_t get_block_weight(const uint64_t &h) const override { return blocks[h].weight; } virtual uint64_t get_block_long_term_weight(const uint64_t &h) const override { return blocks[h].long_term_weight; } - virtual crypto::hash top_block_hash() const override { + virtual crypto::hash top_block_hash(uint64_t *block_height = NULL) const override { uint64_t h = height(); crypto::hash top = crypto::null_hash; if (h) *(uint64_t*)&top = h - 1; + if (block_height) + *block_height = h - 1; return top; } virtual void pop_block(cryptonote::block &blk, std::vector<cryptonote::transaction> &txs) override { blocks.pop_back(); } |