aboutsummaryrefslogtreecommitdiff
path: root/src/checkpoints.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/checkpoints.cpp')
-rw-r--r--src/checkpoints.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp
index 4419a06c83..c7e054df37 100644
--- a/src/checkpoints.cpp
+++ b/src/checkpoints.cpp
@@ -2,16 +2,23 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
-#include "checkpoints.h"
-#include "uint256.h"
-#include "util.h"
-
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
+#include <boost/foreach.hpp>
+
+#include "headers.h"
+#include "checkpoints.h"
namespace Checkpoints
{
typedef std::map<int, uint256> MapCheckpoints;
+ //
+ // What makes a good checkpoint block?
+ // + Is surrounded by blocks with reasonable timestamps
+ // (no blocks before with a timestamp after, none after with
+ // timestamp before)
+ // + Contains no strange transactions
+ //
static MapCheckpoints mapCheckpoints =
boost::assign::map_list_of
( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
@@ -36,8 +43,23 @@ namespace Checkpoints
int GetTotalBlocksEstimate()
{
- if (fTestNet) return 0; // Testnet has no checkpoints
+ if (fTestNet) return 0;
return mapCheckpoints.rbegin()->first;
}
+
+ CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex)
+ {
+ if (fTestNet) return NULL;
+
+ int64 nResult;
+ BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
+ {
+ const uint256& hash = i.second;
+ std::map<uint256, CBlockIndex*>::const_iterator t = mapBlockIndex.find(hash);
+ if (t != mapBlockIndex.end())
+ return t->second;
+ }
+ return NULL;
+ }
}