aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-10-16 19:45:35 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-10-17 00:11:26 +0100
commitb13e7f284b909df8ca54fe93c231910a130f9f3e (patch)
treea79e281f205a0578312aa3b7cfc9a488036b9078 /src/cryptonote_core
parentbootstrap_file: do not try to create a directory with an empty name (diff)
downloadmonero-b13e7f284b909df8ca54fe93c231910a130f9f3e.tar.xz
blockchain_export can now export to a blocks.dat format
Also make the number of blocks endian independant, and add support for testnet
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index e06c3c08c..c38b58841 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -352,13 +352,14 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet)
m_async_pool.create_thread(boost::bind(&boost::asio::io_service::run, &m_async_service));
#if defined(PER_BLOCK_CHECKPOINT)
- if (m_fast_sync && !testnet && get_blocks_dat_start() != nullptr)
+ if (m_fast_sync && get_blocks_dat_start(testnet) != nullptr)
{
- if (get_blocks_dat_size() > 4)
+ if (get_blocks_dat_size(testnet) > 4)
{
- const unsigned char *p = get_blocks_dat_start();
- uint32_t nblocks = *(uint32_t *) p;
- if(nblocks > 0 && nblocks > m_db->height())
+ const unsigned char *p = get_blocks_dat_start(testnet);
+ const uint32_t nblocks = *p | ((*(p+1))<<8) | ((*(p+2))<<16) | ((*(p+3))<<24);
+ const size_t size_needed = 4 + nblocks * sizeof(crypto::hash);
+ if(nblocks > 0 && nblocks > m_db->height() && get_blocks_dat_size(testnet) >= size_needed)
{
LOG_PRINT_L0("Loading precomputed blocks: " << nblocks);
p += sizeof(uint32_t);