From e66ec79b18717bf83b7dbbe54f844b4463dabdeb Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Sun, 1 Nov 2009 01:16:51 +0000 Subject: move debug.log and db.log to data dir, portable GetDataDir, optimize GetBalance, fix repaint bogdown, -addnode and -? switches --- main.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index fcfd33d134..a0258cf2ce 100644 --- a/main.h +++ b/main.h @@ -34,7 +34,6 @@ extern int nBestHeight; extern uint256 hashBestChain; extern CBlockIndex* pindexBest; extern unsigned int nTransactionsUpdated; -extern string strSetDataDir; extern int nDropMessagesTest; // Settings @@ -50,7 +49,6 @@ extern int nLimitProcessors; -string GetAppDir(); bool CheckDiskSpace(int64 nAdditionalBytes=0); FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); FILE* AppendBlockFile(unsigned int& nFileRet); @@ -405,10 +403,10 @@ public: { // Time based nLockTime implemented in 0.1.6, // do not use time based until most 0.1.5 nodes have upgraded. - if (nBlockTime == 0) - nBlockTime = GetAdjustedTime(); if (nLockTime == 0) return true; + if (nBlockTime == 0) + nBlockTime = GetAdjustedTime(); if (nLockTime < (nLockTime < 500000000 ? nBestHeight : nBlockTime)) return true; foreach(const CTxIn& txin, vin) @@ -627,6 +625,8 @@ public: // memory only mutable bool fMerkleVerified; + mutable bool fGetCreditCached; + mutable int64 nGetCreditCached; CMerkleTx() @@ -644,14 +644,22 @@ public: hashBlock = 0; nIndex = -1; fMerkleVerified = false; + fGetCreditCached = false; + nGetCreditCached = 0; } - int64 GetCredit() const + int64 GetCredit(bool fUseCache=false) const { // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; - return CTransaction::GetCredit(); + + // GetBalance can assume transactions in mapWallet won't change + if (fUseCache && fGetCreditCached) + return nGetCreditCached; + nGetCreditCached = CTransaction::GetCredit(); + fGetCreditCached = true; + return nGetCreditCached; } IMPLEMENT_SERIALIZE -- cgit v1.2.3