#include "checkpoints.h"
-#include "db.h"
+#include "txdb.h"
#include "main.h"
#include "uint256.h"
boost::assign::map_list_of
( 0, std::make_pair(hashGenesisBlock, 1360105017) )
( 68600, std::make_pair(uint256("0xb646b0562080ab9411f85d4b2a1ca8b197c67ae170c5e328406871b44233cb06"), 1389867276) )
+ ( 92161, std::make_pair(uint256("0x000000000079090eb31e7fa55487e4e666466253e68b213f44b7977ea7a2eeec"), 1398919969) )
+ ( 98661, std::make_pair(uint256("0x48328dfc0eaffc659723739c6202854d1624449340193bdea3e71ece4ccdd43f"), 1401469019) )
;
// TestNet has no checkpoints
bool WriteSyncCheckpoint(const uint256& hashCheckpoint)
{
- CChainDB chaindb;
- chaindb.TxnBegin();
- if (!chaindb.WriteSyncCheckpoint(hashCheckpoint))
{
- chaindb.TxnAbort();
- return error("WriteSyncCheckpoint(): failed to write to db sync checkpoint %s", hashCheckpoint.ToString().c_str());
+ LOCK(Checkpoints::cs_hashSyncCheckpoint);
+
+ if (!pblocktree->WriteSyncCheckpoint(hashCheckpoint))
+ {
+ return error("WriteSyncCheckpoint(): failed to write to db sync checkpoint %s", hashCheckpoint.ToString().c_str());
+ }
}
- if (!chaindb.TxnCommit())
- return error("WriteSyncCheckpoint(): failed to commit to db sync checkpoint %s", hashCheckpoint.ToString().c_str());
Checkpoints::hashSyncCheckpoint = hashCheckpoint;
return true;
return false;
}
- CChainDB chaindb;
CBlockIndex* pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint];
if (!pindexCheckpoint->IsInMainChain())
{
CBlock block;
if (!block.ReadFromDisk(pindexCheckpoint))
return error("AcceptPendingSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
- if (!block.SetBestChain(pindexCheckpoint))
+ if (!SetBestChain(pindexCheckpoint))
{
hashInvalidCheckpoint = hashPendingCheckpoint;
return error("AcceptPendingSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
{
// checkpoint block accepted but not yet in main chain
printf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString().c_str());
- CChainDB chaindb;
CBlock block;
if (!block.ReadFromDisk(mapBlockIndex[hash]))
return error("ResetSyncCheckpoint: ReadFromDisk failed for hardened checkpoint %s", hash.ToString().c_str());
- if (!block.SetBestChain(mapBlockIndex[hash]))
+ if (!SetBestChain(mapBlockIndex[hash]))
{
return error("ResetSyncCheckpoint: SetBestChain failed for hardened checkpoint %s", hash.ToString().c_str());
}
return (nBestHeight >= pindexSync->nHeight + nCoinbaseMaturity ||
pindexSync->GetBlockTime() + nStakeMinAge < GetAdjustedTime());
}
-
- // Is the sync-checkpoint too old?
- bool IsSyncCheckpointTooOld(unsigned int nSeconds)
- {
- LOCK(cs_hashSyncCheckpoint);
- // sync-checkpoint should always be accepted block
- assert(mapBlockIndex.count(hashSyncCheckpoint));
- const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint];
- return (pindexSync->GetBlockTime() + nSeconds < GetAdjustedTime());
- }
}
// ppcoin: sync-checkpoint master key
if (!Checkpoints::ValidateSyncCheckpoint(hashCheckpoint))
return false;
- CChainDB chaindb;
CBlockIndex* pindexCheckpoint = mapBlockIndex[hashCheckpoint];
if (!pindexCheckpoint->IsInMainChain())
{
CBlock block;
if (!block.ReadFromDisk(pindexCheckpoint))
return error("ProcessSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashCheckpoint.ToString().c_str());
- if (!block.SetBestChain(pindexCheckpoint))
+ if (!SetBestChain(pindexCheckpoint))
{
Checkpoints::hashInvalidCheckpoint = hashCheckpoint;
return error("ProcessSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashCheckpoint.ToString().c_str());