blockchain_export can now export to a blocks.dat format

Also make the number of blocks endian independant, and add
support for testnet
This commit is contained in:
moneromooo-monero 2015-10-16 19:45:35 +01:00
parent 11db442a6c
commit b13e7f284b
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
11 changed files with 368 additions and 38 deletions

View file

@ -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);