aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-08-07 15:11:04 +0200
committerRiccardo Spagni <ric@spagni.net>2017-08-07 15:11:04 +0200
commit8048de268a613962fd85b02a8cf97aec48555360 (patch)
tree3453f58e742f3471f0758f86a64c70b1730c76ea
parentMerge pull request #2215 (diff)
parentblockchain: fix cryptonight buffer leak on exit (diff)
downloadmonero-8048de268a613962fd85b02a8cf97aec48555360.tar.xz
Merge pull request #2216
d8becf2e blockchain: fix cryptonight buffer leak on exit (moneromooo-monero) 91aa90fc blockchain: ensure all blocks get their longhash precalculated (moneromooo-monero) ff4bcaed blockchain: pass correct height to get_block_longhash (moneromooo-monero)
-rw-r--r--src/cryptonote_core/blockchain.cpp12
-rw-r--r--src/cryptonote_core/blockchain.h2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 1602cd06d..815f5b4f3 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -3555,19 +3555,17 @@ void Blockchain::set_enforce_dns_checkpoints(bool enforce_checkpoints)
}
//------------------------------------------------------------------
-void Blockchain::block_longhash_worker(const uint64_t height, const std::vector<block> &blocks, std::unordered_map<crypto::hash, crypto::hash> &map) const
+void Blockchain::block_longhash_worker(uint64_t height, const std::vector<block> &blocks, std::unordered_map<crypto::hash, crypto::hash> &map) const
{
TIME_MEASURE_START(t);
slow_hash_allocate_state();
- //FIXME: height should be changing here, as get_block_longhash expects
- // the height of the block passed to it
for (const auto & block : blocks)
{
if (m_cancel)
- return;
+ break;
crypto::hash id = get_block_hash(block);
- crypto::hash pow = get_block_longhash(block, height);
+ crypto::hash pow = get_block_longhash(block, height++);
map.emplace(id, pow);
}
@@ -3759,9 +3757,11 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
if (!blocks_exist)
{
m_blocks_longhash_table.clear();
+ uint64_t thread_height = height;
for (uint64_t i = 0; i < threads; i++)
{
- thread_list.push_back(new boost::thread(attrs, boost::bind(&Blockchain::block_longhash_worker, this, height + (i * batches), std::cref(blocks[i]), std::ref(maps[i]))));
+ thread_list.push_back(new boost::thread(attrs, boost::bind(&Blockchain::block_longhash_worker, this, thread_height, std::cref(blocks[i]), std::ref(maps[i]))));
+ thread_height += blocks[i].size();
}
for (size_t j = 0; j < thread_list.size(); j++)
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 4f2e4f0d3..564b53af3 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -846,7 +846,7 @@ namespace cryptonote
* @param blocks the blocks to be hashed
* @param map return-by-reference the hashes for each block
*/
- void block_longhash_worker(const uint64_t height, const std::vector<block> &blocks,
+ void block_longhash_worker(uint64_t height, const std::vector<block> &blocks,
std::unordered_map<crypto::hash, crypto::hash> &map) const;
/**