CBlockIndex* pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint];
if (!pindexCheckpoint->IsInMainChain())
{
- txdb.TxnBegin();
- if (!Reorganize(txdb, pindexCheckpoint))
+ CBlock block;
+ if (!block.ReadFromDisk(pindexCheckpoint))
+ return error("AcceptPendingSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
+ if (!block.SetBestChain(txdb, pindexCheckpoint))
{
- txdb.TxnAbort();
hashInvalidCheckpoint = hashPendingCheckpoint;
- return error("AcceptPendingSyncCheckpoint: Reorganize failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
+ return error("AcceptPendingSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
}
}
txdb.Close();
if (mapBlockIndex.count(hash) && !mapBlockIndex[hash]->IsInMainChain())
{
// checkpoint block accepted but not yet in main chain
- printf("ResetSyncCheckpoint: Reorganize to hardened checkpoint %s\n", hash.ToString().c_str());
+ printf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString().c_str());
CTxDB txdb;
- txdb.TxnBegin();
- if (!Reorganize(txdb, mapBlockIndex[hash]))
+ CBlock block;
+ if (!block.ReadFromDisk(mapBlockIndex[hash]))
+ return error("ResetSyncCheckpoint: ReadFromDisk failed for hardened checkpoint %s", hash.ToString().c_str());
+ if (!block.SetBestChain(txdb, mapBlockIndex[hash]))
{
- txdb.TxnAbort();
- return error("ResetSyncCheckpoint: Reorganize failed for hardened checkpoint %s", hash.ToString().c_str());
+ return error("ResetSyncCheckpoint: SetBestChain failed for hardened checkpoint %s", hash.ToString().c_str());
}
txdb.Close();
}
if (!pindexCheckpoint->IsInMainChain())
{
// checkpoint chain received but not yet main chain
- txdb.TxnBegin();
- if (!Reorganize(txdb, pindexCheckpoint))
+ CBlock block;
+ if (!block.ReadFromDisk(pindexCheckpoint))
+ return error("ProcessSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashCheckpoint.ToString().c_str());
+ if (!block.SetBestChain(txdb, pindexCheckpoint))
{
- txdb.TxnAbort();
Checkpoints::hashInvalidCheckpoint = hashCheckpoint;
- return error("ProcessSyncCheckpoint: Reorganize failed for sync checkpoint %s", hashCheckpoint.ToString().c_str());
+ return error("ProcessSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashCheckpoint.ToString().c_str());
}
}
txdb.Close();
int GetNumBlocksOfPeers();
bool IsInitialBlockDownload();
std::string GetWarnings(std::string strFor);
-bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew);
uint256 WantedByOrphan(const CBlock* pblockOrphan);
const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake);
void BitcoinMiner(CWallet *pwallet, bool fProofOfStake);