diff options
| author | Riccardo Spagni <ric@spagni.net> | 2014-09-06 21:57:37 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2014-09-06 21:57:37 +0200 |
| commit | 3c2b74215b7c2d78f2bdcb46883eb104916be985 (patch) | |
| tree | 16d8fcae07e2d617406565e05d96a8e44b6e8d19 /src/cryptonote_core/blockchain_storage.cpp | |
| parent | a544603a7b449026b49da48a4f323af25d2f2219 (diff) | |
| parent | 0a9f2f5236f4679209db2c4ee5eb4e223f619d24 (diff) | |
| download | monzero-core-0.8.8.3.tar.gz monzero-core-0.8.8.3.tar.xz monzero-core-0.8.8.3.zip | |
Merge pull request #121 from fluffypony/masterv0.8.8.3
Fix tree_hash, patch for bad block 202612
Diffstat (limited to 'src/cryptonote_core/blockchain_storage.cpp')
| -rw-r--r-- | src/cryptonote_core/blockchain_storage.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp index e47c35ea5..c41b50204 100644 --- a/src/cryptonote_core/blockchain_storage.cpp +++ b/src/cryptonote_core/blockchain_storage.cpp @@ -88,7 +88,28 @@ bool blockchain_storage::init(const std::string& config_folder) m_config_folder = config_folder; LOG_PRINT_L0("Loading blockchain..."); const std::string filename = m_config_folder + "/" CRYPTONOTE_BLOCKCHAINDATA_FILENAME; - if(!tools::unserialize_obj_from_file(*this, filename)) + if(tools::unserialize_obj_from_file(*this, filename)) + { + + // checkpoints + + // mainchain + for (size_t height=0; height < m_blocks.size(); ++height) + { + CHECK_AND_ASSERT_MES((!m_checkpoints.is_in_checkpoint_zone(height)) || m_checkpoints.check_block(height,get_block_hash(m_blocks[height].bl)),false,"checkpoint fail, blockchain.bin invalid"); + } + + // check alt chains + #if 0 + // doesn't work when a checkpoint is added and there are already alt chains. However, the rest of the blockchain code suffers from the same issue, so ignore for now + // see issue #118 + BOOST_FOREACH(blocks_ext_by_hash::value_type& alt_block, m_alternative_chains) + { + CHECK_AND_ASSERT_MES(m_checkpoints.is_alternative_block_allowed(m_blocks.size()-1,alt_block.second.height),false,"stored alternative block not allowed, blockchain.bin invalid"); + } + #endif + } + else { LOG_PRINT_L0("Can't load blockchain storage from file, generating genesis block."); block bl = boost::value_initialized<block>(); @@ -743,7 +764,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto:: return false; } - //block is not related with head of main chain + //Block is not related with head of main chain //first of all - look in alternative chains container auto it_main_prev = m_blocks_index.find(b.prev_id); auto it_prev = m_alternative_chains.find(b.prev_id); |
