diff options
author | Riccardo Spagni <ric@spagni.net> | 2014-10-02 16:48:01 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-10-02 16:48:05 +0200 |
commit | 1cf22b27a6b95e1e44c35157f5c5ccb73efec9da (patch) | |
tree | 770a470c84cd8c7c7ef816dd2c34078d5aebbc7a /src/cryptonote_core/checkpoints.cpp | |
parent | simplewallet ignoring testnet port in RPC mode (diff) | |
parent | Daemon should now exit on conflicting checkpoints (diff) | |
download | monero-1cf22b27a6b95e1e44c35157f5c5ccb73efec9da.tar.xz |
Merge pull request #165
c0bdd51 Daemon should now exit on conflicting checkpoints (Thomas Winget)
f0b4138 various changes to runtime checkpoint updating (Thomas Winget)
7568f89 Fixed segfault with checkpoints loading (Thomas Winget)
b261d92 DNS checkpoint updating added, and daemon flag to enforce them (Thomas Winget)
30caebf reload checkpoints file every ~hr and print if any fail (Thomas Winget)
0e14491 updated DNSResolver/things that use it for DNSSEC (Thomas Winget)
6f2c2e1 Adding an identical existing checkpoint should not error (Thomas Winget)
Diffstat (limited to 'src/cryptonote_core/checkpoints.cpp')
-rw-r--r-- | src/cryptonote_core/checkpoints.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/cryptonote_core/checkpoints.cpp b/src/cryptonote_core/checkpoints.cpp index c76a23841..25759792b 100644 --- a/src/cryptonote_core/checkpoints.cpp +++ b/src/cryptonote_core/checkpoints.cpp @@ -44,8 +44,13 @@ namespace cryptonote { crypto::hash h = null_hash; bool r = epee::string_tools::parse_tpod_from_hex_string(hash_str, h); - CHECK_AND_ASSERT_MES(r, false, "WRONG HASH IN CHECKPOINTS!!!"); - CHECK_AND_ASSERT_MES(0 == m_points.count(height), false, "WRONG HASH IN CHECKPOINTS!!!"); + CHECK_AND_ASSERT_MES(r, false, "Failed to parse checkpoint hash string into binary representation!"); + + // return false if adding at a height we already have AND the hash is different + if (m_points.count(height)) + { + CHECK_AND_ASSERT_MES(h == m_points[height], false, "Checkpoint at given height already exists, and hash for new checkpoint was different!"); + } m_points[height] = h; return true; } @@ -93,6 +98,7 @@ namespace cryptonote uint64_t checkpoint_height = it->first; return checkpoint_height < block_height; } + //--------------------------------------------------------------------------- uint64_t checkpoints::get_max_height() { std::map< uint64_t, crypto::hash >::const_iterator highest = @@ -101,5 +107,21 @@ namespace cryptonote boost::bind(&std::map< uint64_t, crypto::hash >::value_type::first, _2 ) ) ); return highest->first; } + //--------------------------------------------------------------------------- + const std::map<uint64_t, crypto::hash>& checkpoints::get_points() + { + return m_points; + } + bool checkpoints::check_for_conflicts(checkpoints& other) + { + for (auto& pt : other.get_points()) + { + if (m_points.count(pt.first)) + { + CHECK_AND_ASSERT_MES(pt.second == m_points[pt.first], false, "Checkpoint at given height already exists, and hash for new checkpoint was different!"); + } + } + return true; + } } |