mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 03:03:58 +01:00
Merge #10742: scripted-diff: Use scoped enumerations (C++11, "enum class")
1f45e21 scripted-diff: Convert 11 enums into scoped enums (C++11) (practicalswift)
Pull request description:
Rationale (from Bjarne Stroustrup's ["C++11 FAQ"](http://www.stroustrup.com/C++11FAQ.html#enum)):
>
> The enum classes ("new enums", "strong enums") address three problems with traditional C++ enumerations:
>
> * conventional enums implicitly convert to int, causing errors when someone does not want an enumeration to act as an integer.
> * conventional enums export their enumerators to the surrounding scope, causing name clashes.
> * the underlying type of an enum cannot be specified, causing confusion, compatibility problems, and makes forward declaration impossible.
>
> The new enums are "enum class" because they combine aspects of traditional enumerations (names values) with aspects of classes (scoped members and absence of conversions).
Tree-SHA512: 9656e1cf4c3cabd4378c7a38d0c2eaf79e4a54d204a3c5762330840e55ee7e141e188a3efb2b4daf0ef3110bbaff80d8b9253abf2a9b015cdc4d60b49ac2b914
This commit is contained in:
@@ -522,7 +522,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
{
|
||||
CWalletScanState wss;
|
||||
bool fNoncriticalErrors = false;
|
||||
DBErrors result = DB_LOAD_OK;
|
||||
DBErrors result = DBErrors::LOAD_OK;
|
||||
|
||||
LOCK(pwallet->cs_wallet);
|
||||
try {
|
||||
@@ -530,7 +530,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
if (batch.Read((std::string)"minversion", nMinVersion))
|
||||
{
|
||||
if (nMinVersion > CLIENT_VERSION)
|
||||
return DB_TOO_NEW;
|
||||
return DBErrors::TOO_NEW;
|
||||
pwallet->LoadMinVersion(nMinVersion);
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
if (!pcursor)
|
||||
{
|
||||
LogPrintf("Error getting wallet database cursor\n");
|
||||
return DB_CORRUPT;
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
while (true)
|
||||
@@ -553,7 +553,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
else if (ret != 0)
|
||||
{
|
||||
LogPrintf("Error reading next record from wallet database\n");
|
||||
return DB_CORRUPT;
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
// Try to be tolerant of single corrupt records:
|
||||
@@ -563,7 +563,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
// losing keys is considered a catastrophic error, anything else
|
||||
// we assume the user can live with:
|
||||
if (IsKeyType(strType) || strType == "defaultkey")
|
||||
result = DB_CORRUPT;
|
||||
result = DBErrors::CORRUPT;
|
||||
else
|
||||
{
|
||||
// Leave other errors alone, if we try to fix them we might make things worse.
|
||||
@@ -582,15 +582,15 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
throw;
|
||||
}
|
||||
catch (...) {
|
||||
result = DB_CORRUPT;
|
||||
result = DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
if (fNoncriticalErrors && result == DB_LOAD_OK)
|
||||
result = DB_NONCRITICAL_ERROR;
|
||||
if (fNoncriticalErrors && result == DBErrors::LOAD_OK)
|
||||
result = DBErrors::NONCRITICAL_ERROR;
|
||||
|
||||
// Any wallet corruption at all: skip any rewriting or
|
||||
// upgrading, we don't want to make it worse.
|
||||
if (result != DB_LOAD_OK)
|
||||
if (result != DBErrors::LOAD_OK)
|
||||
return result;
|
||||
|
||||
LogPrintf("nFileVersion = %d\n", wss.nFileVersion);
|
||||
@@ -607,7 +607,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
|
||||
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
|
||||
if (wss.fIsEncrypted && (wss.nFileVersion == 40000 || wss.nFileVersion == 50000))
|
||||
return DB_NEED_REWRITE;
|
||||
return DBErrors::NEED_REWRITE;
|
||||
|
||||
if (wss.nFileVersion < CLIENT_VERSION) // Update
|
||||
WriteVersion(CLIENT_VERSION);
|
||||
@@ -626,14 +626,14 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
|
||||
DBErrors CWalletDB::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWalletTx>& vWtx)
|
||||
{
|
||||
DBErrors result = DB_LOAD_OK;
|
||||
DBErrors result = DBErrors::LOAD_OK;
|
||||
|
||||
try {
|
||||
int nMinVersion = 0;
|
||||
if (batch.Read((std::string)"minversion", nMinVersion))
|
||||
{
|
||||
if (nMinVersion > CLIENT_VERSION)
|
||||
return DB_TOO_NEW;
|
||||
return DBErrors::TOO_NEW;
|
||||
}
|
||||
|
||||
// Get cursor
|
||||
@@ -641,7 +641,7 @@ DBErrors CWalletDB::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWal
|
||||
if (!pcursor)
|
||||
{
|
||||
LogPrintf("Error getting wallet database cursor\n");
|
||||
return DB_CORRUPT;
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
while (true)
|
||||
@@ -655,7 +655,7 @@ DBErrors CWalletDB::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWal
|
||||
else if (ret != 0)
|
||||
{
|
||||
LogPrintf("Error reading next record from wallet database\n");
|
||||
return DB_CORRUPT;
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
std::string strType;
|
||||
@@ -677,7 +677,7 @@ DBErrors CWalletDB::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWal
|
||||
throw;
|
||||
}
|
||||
catch (...) {
|
||||
result = DB_CORRUPT;
|
||||
result = DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -689,7 +689,7 @@ DBErrors CWalletDB::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uin
|
||||
std::vector<uint256> vTxHash;
|
||||
std::vector<CWalletTx> vWtx;
|
||||
DBErrors err = FindWalletTx(vTxHash, vWtx);
|
||||
if (err != DB_LOAD_OK) {
|
||||
if (err != DBErrors::LOAD_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -716,9 +716,9 @@ DBErrors CWalletDB::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uin
|
||||
}
|
||||
|
||||
if (delerror) {
|
||||
return DB_CORRUPT;
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
return DB_LOAD_OK;
|
||||
return DBErrors::LOAD_OK;
|
||||
}
|
||||
|
||||
DBErrors CWalletDB::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||
@@ -726,16 +726,16 @@ DBErrors CWalletDB::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||
// build list of wallet TXs
|
||||
std::vector<uint256> vTxHash;
|
||||
DBErrors err = FindWalletTx(vTxHash, vWtx);
|
||||
if (err != DB_LOAD_OK)
|
||||
if (err != DBErrors::LOAD_OK)
|
||||
return err;
|
||||
|
||||
// erase each wallet TX
|
||||
for (uint256& hash : vTxHash) {
|
||||
if (!EraseTx(hash))
|
||||
return DB_CORRUPT;
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
return DB_LOAD_OK;
|
||||
return DBErrors::LOAD_OK;
|
||||
}
|
||||
|
||||
void MaybeCompactWalletDB()
|
||||
|
||||
Reference in New Issue
Block a user