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:
+20
-20
@@ -727,11 +727,11 @@ DBErrors CWallet::ReorderTransactions()
|
||||
if (pwtx)
|
||||
{
|
||||
if (!walletdb.WriteTx(*pwtx))
|
||||
return DB_LOAD_FAIL;
|
||||
return DBErrors::LOAD_FAIL;
|
||||
}
|
||||
else
|
||||
if (!walletdb.WriteAccountingEntry(pacentry->nEntryNo, *pacentry))
|
||||
return DB_LOAD_FAIL;
|
||||
return DBErrors::LOAD_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -751,16 +751,16 @@ DBErrors CWallet::ReorderTransactions()
|
||||
if (pwtx)
|
||||
{
|
||||
if (!walletdb.WriteTx(*pwtx))
|
||||
return DB_LOAD_FAIL;
|
||||
return DBErrors::LOAD_FAIL;
|
||||
}
|
||||
else
|
||||
if (!walletdb.WriteAccountingEntry(pacentry->nEntryNo, *pacentry))
|
||||
return DB_LOAD_FAIL;
|
||||
return DBErrors::LOAD_FAIL;
|
||||
}
|
||||
}
|
||||
walletdb.WriteOrderPosNext(nOrderPosNext);
|
||||
|
||||
return DB_LOAD_OK;
|
||||
return DBErrors::LOAD_OK;
|
||||
}
|
||||
|
||||
int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb)
|
||||
@@ -3146,7 +3146,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
||||
|
||||
fFirstRunRet = false;
|
||||
DBErrors nLoadWalletRet = CWalletDB(*dbw,"cr+").LoadWallet(this);
|
||||
if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||
if (nLoadWalletRet == DBErrors::NEED_REWRITE)
|
||||
{
|
||||
if (dbw->Rewrite("\x04pool"))
|
||||
{
|
||||
@@ -3162,12 +3162,12 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
||||
// This wallet is in its first run if all of these are empty
|
||||
fFirstRunRet = mapKeys.empty() && mapCryptedKeys.empty() && mapWatchKeys.empty() && setWatchOnly.empty() && mapScripts.empty();
|
||||
|
||||
if (nLoadWalletRet != DB_LOAD_OK)
|
||||
if (nLoadWalletRet != DBErrors::LOAD_OK)
|
||||
return nLoadWalletRet;
|
||||
|
||||
uiInterface.LoadWallet(this);
|
||||
|
||||
return DB_LOAD_OK;
|
||||
return DBErrors::LOAD_OK;
|
||||
}
|
||||
|
||||
DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut)
|
||||
@@ -3177,7 +3177,7 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
|
||||
for (uint256 hash : vHashOut)
|
||||
mapWallet.erase(hash);
|
||||
|
||||
if (nZapSelectTxRet == DB_NEED_REWRITE)
|
||||
if (nZapSelectTxRet == DBErrors::NEED_REWRITE)
|
||||
{
|
||||
if (dbw->Rewrite("\x04pool"))
|
||||
{
|
||||
@@ -3190,19 +3190,19 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
|
||||
}
|
||||
}
|
||||
|
||||
if (nZapSelectTxRet != DB_LOAD_OK)
|
||||
if (nZapSelectTxRet != DBErrors::LOAD_OK)
|
||||
return nZapSelectTxRet;
|
||||
|
||||
MarkDirty();
|
||||
|
||||
return DB_LOAD_OK;
|
||||
return DBErrors::LOAD_OK;
|
||||
|
||||
}
|
||||
|
||||
DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||
{
|
||||
DBErrors nZapWalletTxRet = CWalletDB(*dbw,"cr+").ZapWalletTx(vWtx);
|
||||
if (nZapWalletTxRet == DB_NEED_REWRITE)
|
||||
if (nZapWalletTxRet == DBErrors::NEED_REWRITE)
|
||||
{
|
||||
if (dbw->Rewrite("\x04pool"))
|
||||
{
|
||||
@@ -3216,10 +3216,10 @@ DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||
}
|
||||
}
|
||||
|
||||
if (nZapWalletTxRet != DB_LOAD_OK)
|
||||
if (nZapWalletTxRet != DBErrors::LOAD_OK)
|
||||
return nZapWalletTxRet;
|
||||
|
||||
return DB_LOAD_OK;
|
||||
return DBErrors::LOAD_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -3931,7 +3931,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
|
||||
|
||||
std::unique_ptr<CWallet> tempWallet = MakeUnique<CWallet>(name, CWalletDBWrapper::Create(path));
|
||||
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
|
||||
if (nZapWalletRet != DB_LOAD_OK) {
|
||||
if (nZapWalletRet != DBErrors::LOAD_OK) {
|
||||
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3943,23 +3943,23 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
|
||||
bool fFirstRun = true;
|
||||
CWallet *walletInstance = new CWallet(name, CWalletDBWrapper::Create(path));
|
||||
DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
|
||||
if (nLoadWalletRet != DB_LOAD_OK)
|
||||
if (nLoadWalletRet != DBErrors::LOAD_OK)
|
||||
{
|
||||
if (nLoadWalletRet == DB_CORRUPT) {
|
||||
if (nLoadWalletRet == DBErrors::CORRUPT) {
|
||||
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
|
||||
return nullptr;
|
||||
}
|
||||
else if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
|
||||
else if (nLoadWalletRet == DBErrors::NONCRITICAL_ERROR)
|
||||
{
|
||||
InitWarning(strprintf(_("Error reading %s! All keys read correctly, but transaction data"
|
||||
" or address book entries might be missing or incorrect."),
|
||||
walletFile));
|
||||
}
|
||||
else if (nLoadWalletRet == DB_TOO_NEW) {
|
||||
else if (nLoadWalletRet == DBErrors::TOO_NEW) {
|
||||
InitError(strprintf(_("Error loading %s: Wallet requires newer version of %s"), walletFile, _(PACKAGE_NAME)));
|
||||
return nullptr;
|
||||
}
|
||||
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||
else if (nLoadWalletRet == DBErrors::NEED_REWRITE)
|
||||
{
|
||||
InitError(strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)));
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user