diff options
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r-- | src/walletdb.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp index e102df9720..81a21443a1 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -203,7 +203,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssKey >> hash; CWalletTx& wtx = pwallet->mapWallet[hash]; ssValue >> wtx; - if (wtx.CheckTransaction() && (wtx.GetHash() == hash)) + CValidationState state; + if (wtx.CheckTransaction(state) && (wtx.GetHash() == hash) && state.IsValid()) wtx.BindWallet(pwallet); else { @@ -238,8 +239,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str()); //printf(" %12"PRI64d" %s %s %s\n", // wtx.vout[0].nValue, - // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(), - // wtx.hashBlock.ToString().substr(0,20).c_str(), + // DateTimeStrFormat("%Y-%m-%d %H:%M:%S", wtx.GetBlockTime()).c_str(), + // wtx.hashBlock.ToString().c_str(), // wtx.mapValue["message"].c_str()); } else if (strType == "acentry") @@ -450,8 +451,10 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) } pcursor->close(); } - catch (...) - { + catch (boost::thread_interrupted) { + throw; + } + catch (...) { result = DB_CORRUPT; } @@ -481,12 +484,11 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) return result; } -void ThreadFlushWalletDB(void* parg) +void ThreadFlushWalletDB(const string& strFile) { // Make this thread recognisable as the wallet flushing thread RenameThread("bitcoin-wallet"); - const string& strFile = ((const string*)parg)[0]; static bool fOneThread; if (fOneThread) return; @@ -497,9 +499,9 @@ void ThreadFlushWalletDB(void* parg) unsigned int nLastSeen = nWalletDBUpdated; unsigned int nLastFlushed = nWalletDBUpdated; int64 nLastWalletUpdate = GetTime(); - while (!fShutdown) + while (true) { - Sleep(500); + MilliSleep(500); if (nLastSeen != nWalletDBUpdated) { @@ -521,8 +523,9 @@ void ThreadFlushWalletDB(void* parg) mi++; } - if (nRefCount == 0 && !fShutdown) + if (nRefCount == 0) { + boost::this_thread::interruption_point(); map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile); if (mi != bitdb.mapFileUseCount.end()) { @@ -547,7 +550,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest) { if (!wallet.fFileBacked) return false; - while (!fShutdown) + while (true) { { LOCK(bitdb.cs_db); @@ -578,7 +581,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest) } } } - Sleep(100); + MilliSleep(100); } return false; } @@ -619,11 +622,11 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) bool fSuccess = allOK; Db* pdbCopy = new Db(&dbenv.dbenv, 0); - int ret = pdbCopy->open(NULL, // Txn pointer + int ret = pdbCopy->open(NULL, // Txn pointer filename.c_str(), // Filename - "main", // Logical db name - DB_BTREE, // Database type - DB_CREATE, // Flags + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags 0); if (ret > 0) { |