aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/checkpoints.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core/checkpoints.cpp')
-rw-r--r--src/cryptonote_core/checkpoints.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/cryptonote_core/checkpoints.cpp b/src/cryptonote_core/checkpoints.cpp
index 54c2f3a6d..33a2d2986 100644
--- a/src/cryptonote_core/checkpoints.cpp
+++ b/src/cryptonote_core/checkpoints.cpp
@@ -29,10 +29,11 @@ namespace cryptonote
return !m_points.empty() && (height <= (--m_points.end())->first);
}
//---------------------------------------------------------------------------
- bool checkpoints::check_block(uint64_t height, const crypto::hash& h) const
+ bool checkpoints::check_block(uint64_t height, const crypto::hash& h, bool& is_a_checkpoint) const
{
auto it = m_points.find(height);
- if(it == m_points.end())
+ is_a_checkpoint = it != m_points.end();
+ if(!is_a_checkpoint)
return true;
if(it->second == h)
@@ -45,4 +46,25 @@ namespace cryptonote
return false;
}
}
+ //---------------------------------------------------------------------------
+ bool checkpoints::check_block(uint64_t height, const crypto::hash& h) const
+ {
+ bool ignored;
+ return check_block(height, h, ignored);
+ }
+ //---------------------------------------------------------------------------
+ bool checkpoints::is_alternative_block_allowed(uint64_t blockchain_height, uint64_t block_height) const
+ {
+ if (0 == block_height)
+ return false;
+
+ auto it = m_points.upper_bound(blockchain_height);
+ // Is blockchain_height before the first checkpoint?
+ if (it == m_points.begin())
+ return true;
+
+ --it;
+ uint64_t checkpoint_height = it->first;
+ return checkpoint_height < block_height;
+ }
}