X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fcheckpoints.cpp;h=c7e054df378157e0ba753c501cbdfc936e300e7e;hb=10fd7f66893fd62ab65f9302115834c441eb571b;hp=4419a06c83099c52f237f0833c1e5c463d68b858;hpb=eb5fff9e16b2c3e94835cd3a8897318472df2374;p=novacoin.git diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 4419a06..c7e054d 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 // for 'map_list_of()' +#include + +#include "headers.h" +#include "checkpoints.h" namespace Checkpoints { typedef std::map 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& mapBlockIndex) + { + if (fTestNet) return NULL; + + int64 nResult; + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) + { + const uint256& hash = i.second; + std::map::const_iterator t = mapBlockIndex.find(hash); + if (t != mapBlockIndex.end()) + return t->second; + } + return NULL; + } }