return error("CTxDB::LoadBlockIndex() : hashSyncCheckpoint not loaded");
printf("LoadBlockIndex(): synchronized checkpoint %s\n", Checkpoints::hashSyncCheckpoint.ToString().c_str());
- // ppcoin: if checkpoint master key changed must reset sync-checkpoint
- string strPubKey = "";
- if (!ReadCheckpointPubKey(strPubKey) || strPubKey != CSyncCheckpoint::strMasterPubKey)
- {
- // write checkpoint master key to db
- TxnBegin();
- WriteCheckpointPubKey(CSyncCheckpoint::strMasterPubKey);
- if (!TxnCommit())
- return error("CTxDB::LoadBlockIndex() : failed to write new checkpoint master key");
- if (!Checkpoints::ResetSyncCheckpoint())
- return error("CTxDB::LoadBlockIndex() : failed to reset sync-checkpoint");
- }
-
// Load nBestInvalidTrust, OK if it doesn't exist
ReadBestInvalidTrust(nBestInvalidTrust);
return error("LoadBlockIndex() : failed to init sync checkpoint");
}
+ // ppcoin: if checkpoint master key changed must reset sync-checkpoint
+ {
+ CTxDB txdb;
+ string strPubKey = "";
+ if (!txdb.ReadCheckpointPubKey(strPubKey) || strPubKey != CSyncCheckpoint::strMasterPubKey)
+ {
+ // write checkpoint master key to db
+ txdb.TxnBegin();
+ if (!txdb.WriteCheckpointPubKey(CSyncCheckpoint::strMasterPubKey))
+ return error("LoadBlockIndex() : failed to write new checkpoint master key to db");
+ if (!txdb.TxnCommit())
+ return error("LoadBlockIndex() : failed to commit new checkpoint master key to db");
+ if (!Checkpoints::ResetSyncCheckpoint())
+ return error("LoadBlockIndex() : failed to reset sync-checkpoint");
+ }
+ txdb.Close();
+ }
+
return true;
}