diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-11-20 12:34:25 +0900 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-11-20 12:34:25 +0900 |
commit | 6c223fa96fb46ecb815b86cc3065aeed42205b76 (patch) | |
tree | a0d963aa0411b9d0f7c2738d81b90d06b09e49d4 /src/cryptonote_core/blockchain.cpp | |
parent | Merge pull request #4820 (diff) | |
parent | tests: add unit tests for get_output_distribution (diff) | |
download | monero-6c223fa96fb46ecb815b86cc3065aeed42205b76.tar.xz |
Merge pull request #4812
31d80027 tests: add unit tests for get_output_distribution (moneromooo-monero)
0936dae8 blockchain: remove "0 is height" shortcut from get_output_distribution (moneromooo-monero)
872c7eb2 Revert "blockchain: simplify output distribution code" (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index f3105114e..e80e3f66c 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1805,6 +1805,7 @@ bool Blockchain::get_output_distribution(uint64_t amount, uint64_t from_height, case STAGENET: start_height = stagenet_hard_forks[3].height; break; case TESTNET: start_height = testnet_hard_forks[3].height; break; case MAINNET: start_height = mainnet_hard_forks[3].height; break; + case FAKECHAIN: start_height = 0; break; default: return false; } } @@ -1823,18 +1824,21 @@ bool Blockchain::get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t db_height = m_db->height(); if (db_height == 0) return false; - if (to_height == 0) - to_height = db_height - 1; if (start_height >= db_height || to_height >= db_height) return false; if (amount == 0) { std::vector<uint64_t> heights; heights.reserve(to_height + 1 - start_height); - for (uint64_t h = start_height; h <= to_height; ++h) + uint64_t real_start_height = start_height > 0 ? start_height-1 : start_height; + for (uint64_t h = real_start_height; h <= to_height; ++h) heights.push_back(h); distribution = m_db->get_block_cumulative_rct_outputs(heights); - base = 0; + if (start_height > 0) + { + base = distribution[0]; + distribution.erase(distribution.begin()); + } return true; } else |