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.
This commit is contained in:
Thomas Winget 2014-09-24 18:43:03 -04:00
parent e00f0551e0
commit 6f2c2e1c27

View file

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