throw runtime_error(
"Provided checkpoint block is not on main chain\n");
}
+ else
+ {
+ checkpoint.hashCheckpoint = Checkpoints::AutoSelectSyncCheckpoint();
+ if (checkpoint.hashCheckpoint == Checkpoints::hashSyncCheckpoint)
+ throw runtime_error(
+ "Unable to select a more recent sync-checkpoint");
+ }
CDataStream sMsg;
sMsg << (CUnsignedSyncCheckpoint)checkpoint;
BOOST_FOREACH(CNode* pnode, vNodes)
checkpoint.RelayTo(pnode);
- return Value::null;
+ Object result;
+ result.push_back(Pair("checkpoint", Checkpoints::hashSyncCheckpoint.ToString().c_str()));
+ result.push_back(Pair("height", mapBlockIndex[Checkpoints::hashSyncCheckpoint]->nHeight));
+ result.push_back(Pair("timestamp", DateTimeStrFormat("%x %H:%M:%S", mapBlockIndex[Checkpoints::hashSyncCheckpoint]->GetBlockTime()).c_str()));
+ return result;
}
return false;
}
+ uint256 AutoSelectSyncCheckpoint()
+ {
+ // select block roughly 8 hours ago
+ CBlockIndex *pindex = mapBlockIndex[hashSyncCheckpoint];
+ while (pindex->pnext && pindex->pnext->GetBlockTime() + AUTO_CHECKPOINT_MIN_SPAN <= GetAdjustedTime())
+ pindex = pindex->pnext;
+ return pindex->GetBlockHash();
+ }
+
// ppcoin: automatic checkpoint (represented by height of checkpoint)
int nAutoCheckpoint = 0;
int nBranchPoint = 0; // branch point to alternative branch
extern CCriticalSection cs_hashSyncCheckpoint;
bool AcceptPendingSyncCheckpoint(uint256 hashAcceptedBlock);
+ uint256 AutoSelectSyncCheckpoint();
// ppcoin: automatic checkpoint
extern int nAutoCheckpoint;