diff options
| author | Thomas Winget <tewinget@gmail.com> | 2014-09-29 16:30:47 -0400 |
|---|---|---|
| committer | Thomas Winget <tewinget@gmail.com> | 2014-09-30 16:21:37 -0400 |
| commit | f0b4138f1f6ecb86c971dd7edf72a92d54e22721 (patch) | |
| tree | f185f6e4ddd42d55615ec3d047acce488ad8fc57 /src/cryptonote_core/cryptonote_core.cpp | |
| parent | 7568f89c5559a667c53dfaa6d1bef27fe3b4ae86 (diff) | |
| download | monzero-core-f0b4138f1f6ecb86c971dd7edf72a92d54e22721.tar.gz monzero-core-f0b4138f1f6ecb86c971dd7edf72a92d54e22721.tar.xz monzero-core-f0b4138f1f6ecb86c971dd7edf72a92d54e22721.zip | |
various changes to runtime checkpoint updating
json checkpoints will be checked every 10 minutes, dns every 60.
json checkpoints always enforced, dns still with flag.
conflicting checkpoints is hard fail, but soft if dns enforce flag not
set and dns checkpoints are wonky.
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
| -rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index d14be252b..c83e6e0a0 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -56,7 +56,8 @@ namespace cryptonote m_starter_message_showed(false), m_target_blockchain_height(0), m_checkpoints_path(""), - m_last_checkpoints_update(0) + m_last_dns_checkpoints_update(0), + m_last_json_checkpoints_update(0) { set_cryptonote_protocol(pprotocol); } @@ -86,10 +87,16 @@ namespace cryptonote bool core::update_checkpoints() { bool res = true; - if (time(NULL) - m_last_checkpoints_update >= 3600) + if (time(NULL) - m_last_dns_checkpoints_update >= 3600) { - res = m_blockchain_storage.update_checkpoints(m_checkpoints_path); - m_last_checkpoints_update = time(NULL); + res = m_blockchain_storage.update_checkpoints(m_checkpoints_path, true); + m_last_dns_checkpoints_update = time(NULL); + m_last_json_checkpoints_update = time(NULL); + } + else if (time(NULL) - m_last_json_checkpoints_update >= 600) + { + res = m_blockchain_storage.update_checkpoints(m_checkpoints_path, false); + m_last_json_checkpoints_update = time(NULL); } return res; } @@ -152,7 +159,7 @@ namespace cryptonote // load json & DNS checkpoints, and verify them // with respect to what blocks we already have - update_checkpoints(); + CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints."); r = m_miner.init(vm, testnet); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage"); @@ -445,7 +452,10 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::handle_incoming_block(const blobdata& block_blob, block_verification_context& bvc, bool update_miner_blocktemplate) { - update_checkpoints(); + // load json & DNS checkpoints every 10min/hour respectively, + // and verify them with respect to what blocks we already have + CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints."); + bvc = boost::value_initialized<block_verification_context>(); if(block_blob.size() > get_max_block_size()) { |
