( 0, hashGenesisBlock )
; // ppcoin: no checkpoint yet; to be created in future releases
- // ppcoin: automatic checkpoint (represented by height of checkpoint)
- int nAutoCheckpoint = 0;
- int nBranchPoint = 0; // branch point to alternative branch
-
bool CheckHardened(int nHeight, const uint256& hash)
{
if (fTestNet) return true; // Testnet has no checkpoints
return hash == i->second;
}
+ int GetTotalBlocksEstimate()
+ {
+ 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;
+ }
+
+ // ppcoin: synchronized checkpoint (centrally broadcasted)
+ uint256 hashSyncCheckpoint;
+
+ bool AcceptNewSyncCheckpoint(uint256 hashCheckpoint)
+ {
+ }
+
+ // ppcoin: automatic checkpoint (represented by height of checkpoint)
+ int nAutoCheckpoint = 0;
+ int nBranchPoint = 0; // branch point to alternative branch
+
// ppcoin: check automatic checkpoint
// To pass the check:
// - All ancestors (including the block itself) have block index already
printf("Checkpoints: auto checkpoint now at height=%d\n", nAutoCheckpoint);
}
- int GetTotalBlocksEstimate()
- {
- if (fTestNet) return 0;
-
- return mapCheckpoints.rbegin()->first;
- }
-
// ppcoin: reset auto checkpoint
bool ResetAutoCheckpoint(int nCheckpoint)
{
return true;
}
-
- 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;
- }
}
//
namespace Checkpoints
{
- extern int nAutoCheckpoint;
- extern int nBranchPoint;
-
// Returns true if block passes checkpoint checks
bool CheckHardened(int nHeight, const uint256& hash);
- bool CheckAuto(const CBlockIndex *pindex);
-
- int GetNextChainCheckpoint(const CBlockIndex *pindex);
- int GetNextAutoCheckpoint(int nCheckpoint);
- void AdvanceAutoCheckpoint(int nCheckpoint);
- bool ResetAutoCheckpoint(int nCheckpoint);
// Return conservative estimate of total number of blocks, 0 if unknown
int GetTotalBlocksEstimate();
// Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex);
+
+ // ppcoin: synchronized checkpoint
+ extern uint256 hashSyncCheckpoint;
+
+ // ppcoin: automatic checkpoint
+ extern int nAutoCheckpoint;
+ extern int nBranchPoint;
+
+ bool CheckAuto(const CBlockIndex *pindex);
+ int GetNextChainCheckpoint(const CBlockIndex *pindex);
+ int GetNextAutoCheckpoint(int nCheckpoint);
+ void AdvanceAutoCheckpoint(int nCheckpoint);
+ bool ResetAutoCheckpoint(int nCheckpoint);
}
#endif
return Write(string("nAutoCheckpoint"), nCheckpoint);
}
+bool CTxDB::ReadSyncCheckpoint(uint256& hashCheckpoint)
+{
+ return Read(string("hashSyncCheckpoint"), hashCheckpoint);
+}
+
+bool CTxDB::WriteSyncCheckpoint(uint256 hashCheckpoint)
+{
+ return Write(string("hashSyncCheckpoint"), hashCheckpoint);
+}
+
CBlockIndex static * InsertBlockIndex(uint256 hash)
{
if (hash == 0)
nBestChainTrust = pindexBest->nChainTrust;
printf("LoadBlockIndex(): hashBestChain=%s height=%d trust=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, nBestChainTrust);
- // Load nAutoCheckpoint
+ // ppcoin: load nAutoCheckpoint
if (!ReadAutoCheckpoint(Checkpoints::nAutoCheckpoint))
return error("CTxDB::LoadBlockIndex() : nAutoCheckpoint not loaded");
printf("LoadBlockIndex(): automatic checkpoint at height=%d\n", Checkpoints::nAutoCheckpoint);
+ // ppcoin: load hashSyncCheckpoint
+ if (!ReadSyncCheckpoint(Checkpoints::hashSyncCheckpoint))
+ return error("CTxDB::LoadBlockIndex() : hashSyncCheckpoint not loaded");
+ printf("LoadBlockIndex(): synchronized checkpoint %s\n", Checkpoints::hashSyncCheckpoint.ToString().c_str());
+
// Load nBestInvalidTrust, OK if it doesn't exist
ReadBestInvalidTrust(nBestInvalidTrust);
bool WriteBestInvalidTrust(uint64 nBestInvalidTrust);
bool ReadAutoCheckpoint(int& nAutoCheckpoint);
bool WriteAutoCheckpoint(int nCheckpoint, bool fReset=false);
+ bool ReadSyncCheckpoint(uint256& hashCheckpoint);
+ bool WriteSyncCheckpoint(uint256 hashCheckpoint);
bool LoadBlockIndex();
};