Add minversion to wallet.
This commit is contained in:
parent
9390431ce4
commit
7ec552676c
15
src/db.cpp
15
src/db.cpp
@ -670,7 +670,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CWalletDB::LoadWallet(CWallet* pwallet)
|
int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
{
|
{
|
||||||
pwallet->vchDefaultKey.clear();
|
pwallet->vchDefaultKey.clear();
|
||||||
int nFileVersion = 0;
|
int nFileVersion = 0;
|
||||||
@ -690,7 +690,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
// Get cursor
|
// Get cursor
|
||||||
Dbc* pcursor = GetCursor();
|
Dbc* pcursor = GetCursor();
|
||||||
if (!pcursor)
|
if (!pcursor)
|
||||||
return false;
|
return DB_CORRUPT;
|
||||||
|
|
||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
@ -701,7 +701,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
if (ret == DB_NOTFOUND)
|
if (ret == DB_NOTFOUND)
|
||||||
break;
|
break;
|
||||||
else if (ret != 0)
|
else if (ret != 0)
|
||||||
return false;
|
return DB_CORRUPT;
|
||||||
|
|
||||||
// Unserialize
|
// Unserialize
|
||||||
// Taking advantage of the fact that pair serialization
|
// Taking advantage of the fact that pair serialization
|
||||||
@ -809,6 +809,13 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
if (strKey == "addrProxy") ssValue >> addrProxy;
|
if (strKey == "addrProxy") ssValue >> addrProxy;
|
||||||
if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
|
if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
|
||||||
}
|
}
|
||||||
|
else if (strType == "minversion")
|
||||||
|
{
|
||||||
|
int nMinVersion = 0;
|
||||||
|
ssValue >> nMinVersion;
|
||||||
|
if (nMinVersion > VERSION)
|
||||||
|
return DB_TOO_NEW;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pcursor->close();
|
pcursor->close();
|
||||||
}
|
}
|
||||||
@ -839,7 +846,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return DB_LOAD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadFlushWalletDB(void* parg)
|
void ThreadFlushWalletDB(void* parg)
|
||||||
|
9
src/db.h
9
src/db.h
@ -342,6 +342,13 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum DBErrors
|
||||||
|
{
|
||||||
|
DB_LOAD_OK,
|
||||||
|
DB_CORRUPT,
|
||||||
|
DB_TOO_NEW
|
||||||
|
};
|
||||||
|
|
||||||
class CWalletDB : public CDB
|
class CWalletDB : public CDB
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -450,7 +457,7 @@ public:
|
|||||||
int64 GetAccountCreditDebit(const std::string& strAccount);
|
int64 GetAccountCreditDebit(const std::string& strAccount);
|
||||||
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
|
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
|
||||||
|
|
||||||
bool LoadWallet(CWallet* pwallet);
|
int LoadWallet(CWallet* pwallet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
src/init.cpp
10
src/init.cpp
@ -387,8 +387,16 @@ bool AppInit2(int argc, char* argv[])
|
|||||||
nStart = GetTimeMillis();
|
nStart = GetTimeMillis();
|
||||||
bool fFirstRun;
|
bool fFirstRun;
|
||||||
pwalletMain = new CWallet("wallet.dat");
|
pwalletMain = new CWallet("wallet.dat");
|
||||||
if (!pwalletMain->LoadWallet(fFirstRun))
|
int nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun);
|
||||||
|
if (nLoadWalletRet != DB_LOAD_OK)
|
||||||
|
{
|
||||||
|
if (nLoadWalletRet == DB_CORRUPT)
|
||||||
|
strErrors += _("Error loading wallet.dat: Wallet corrupted \n");
|
||||||
|
else if (nLoadWalletRet == DB_TOO_NEW)
|
||||||
|
strErrors += _("Error loading wallet.dat: Wallet requires newer version of Bitcoin \n");
|
||||||
|
else
|
||||||
strErrors += _("Error loading wallet.dat \n");
|
strErrors += _("Error loading wallet.dat \n");
|
||||||
|
}
|
||||||
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||||
|
|
||||||
RegisterWallet(pwalletMain);
|
RegisterWallet(pwalletMain);
|
||||||
|
@ -958,8 +958,9 @@ bool CWallet::LoadWallet(bool& fFirstRunRet)
|
|||||||
if (!fFileBacked)
|
if (!fFileBacked)
|
||||||
return false;
|
return false;
|
||||||
fFirstRunRet = false;
|
fFirstRunRet = false;
|
||||||
if (!CWalletDB(strWalletFile,"cr+").LoadWallet(this))
|
int nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this);
|
||||||
return false;
|
if (nLoadWalletRet != DB_LOAD_OK)
|
||||||
|
return nLoadWalletRet;
|
||||||
fFirstRunRet = vchDefaultKey.empty();
|
fFirstRunRet = vchDefaultKey.empty();
|
||||||
|
|
||||||
if (!mapKeys.count(vchDefaultKey))
|
if (!mapKeys.count(vchDefaultKey))
|
||||||
|
Loading…
Reference in New Issue
Block a user