From: Sunny King Date: Thu, 5 Jul 2012 16:53:36 +0000 (+0100) Subject: PPCoin: Fix a startup issue writing checkpoint master key by 90f58617 X-Git-Tag: v0.4.0-unstable~135 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=4ba55965ffcb1ee951d60d592fa2ed94e6d0b051 PPCoin: Fix a startup issue writing checkpoint master key by 90f58617 --- diff --git a/src/db.cpp b/src/db.cpp index 2d6293d..2fec183 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -594,19 +594,6 @@ bool CTxDB::LoadBlockIndex() 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); diff --git a/src/main.cpp b/src/main.cpp index 4409dd2..ab9026b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1847,6 +1847,24 @@ bool LoadBlockIndex(bool fAllowNew) 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; }