aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities/blocksdat_file.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-13 21:03:04 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-18 16:29:00 +0100
commit7adceee634354f9291de8dd021669d7ca5cf3f2a (patch)
tree30743bd5eaddab868baba6e19bc3aace6e68951c /src/blockchain_utilities/blocksdat_file.cpp
parentMerge pull request #2446 (diff)
downloadmonero-7adceee634354f9291de8dd021669d7ca5cf3f2a.tar.xz
precomputed block hashes are now in blocks of N (currently 256)
This shaves a lot of space off binaries
Diffstat (limited to 'src/blockchain_utilities/blocksdat_file.cpp')
-rw-r--r--src/blockchain_utilities/blocksdat_file.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/blockchain_utilities/blocksdat_file.cpp b/src/blockchain_utilities/blocksdat_file.cpp
index 63224225f..32e93345e 100644
--- a/src/blockchain_utilities/blocksdat_file.cpp
+++ b/src/blockchain_utilities/blocksdat_file.cpp
@@ -82,7 +82,7 @@ bool BlocksdatFile::open_writer(const boost::filesystem::path& file_path, uint64
bool BlocksdatFile::initialize_file(uint64_t block_stop)
{
- const uint32_t nblocks = block_stop + 1;
+ const uint32_t nblocks = (block_stop + 1) / HASH_OF_HASHES_STEP;
unsigned char nblocksc[4];
nblocksc[0] = nblocks & 0xff;
@@ -101,8 +101,16 @@ bool BlocksdatFile::initialize_file(uint64_t block_stop)
void BlocksdatFile::write_block(const crypto::hash& block_hash)
{
- const std::string data(block_hash.data, sizeof(block_hash));
- *m_raw_data_file << data;
+ m_hashes.push_back(block_hash);
+ while (m_hashes.size() >= HASH_OF_HASHES_STEP)
+ {
+ crypto::hash hash;
+ crypto::cn_fast_hash(m_hashes.data(), HASH_OF_HASHES_STEP * sizeof(crypto::hash), hash);
+ memmove(m_hashes.data(), m_hashes.data() + HASH_OF_HASHES_STEP * sizeof(crypto::hash), (m_hashes.size() - HASH_OF_HASHES_STEP) * sizeof(crypto::hash));
+ m_hashes.resize(m_hashes.size() - HASH_OF_HASHES_STEP);
+ const std::string data(hash.data, sizeof(hash));
+ *m_raw_data_file << data;
+ }
}
bool BlocksdatFile::close()