From 6f2c2e1c27254116f979ec244cf3383d2ea87fad Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Wed, 24 Sep 2014 18:43:03 -0400 Subject: [PATCH] Adding an identical existing checkpoint should not error For checkpoints being read at runtime to work correctly, the checkpoint add code needs to not return false if a checkpoint is added that already exists. In this case, instead return false if the checkpoint is for a height that already has a checkpoint and the hashes are different. --- src/cryptonote_core/checkpoints.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/checkpoints.cpp b/src/cryptonote_core/checkpoints.cpp index c76a2384..8e4144a0 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; }