aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-25 04:35:01 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-25 04:35:01 +0000
commitfa2a0338d3f8b1c3a1d75bff39ff42e436cee0dc (patch)
tree3b7788ae10dc2507e48c100f39a94c92ab9af70d /main.cpp
parente39dfe8ea64a360978db0239fbd6ea4ef24de55d (diff)
fix display of new generated coins, fix assertion in bitcoinminer
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@17 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/main.cpp b/main.cpp
index de5a5939e1..dbdee70211 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1129,9 +1129,6 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
}
}
- // Notify UI to update prev block coinbase if it was ours
- vWalletUpdated.push_back(hashBestChain);
-
// New best link
hashBestChain = hash;
pindexBest = pindexNew;
@@ -1143,10 +1140,18 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
txdb.TxnCommit();
txdb.Close();
- // Relay wallet transactions that haven't gotten in yet
if (pindexNew == pindexBest)
+ {
+ // Relay wallet transactions that haven't gotten in yet
RelayWalletTransactions();
+ // Notify UI to display prev block's coinbase if it was ours
+ static uint256 hashPrevBestCoinBase;
+ CRITICAL_BLOCK(cs_mapWallet)
+ vWalletUpdated.push_back(hashPrevBestCoinBase);
+ hashPrevBestCoinBase = vtx[0].GetHash();
+ }
+
MainFrameRepaint();
return true;
}
@@ -2074,13 +2079,8 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else
{
// Ignore unknown commands for extensibility
- printf("ProcessMessage(%s) : Ignored unknown message\n", strCommand.c_str());
}
-
- if (!vRecv.empty())
- printf("ProcessMessage(%s) : %d extra bytes\n", strCommand.c_str(), vRecv.size());
-
return true;
}
@@ -2349,7 +2349,7 @@ bool BitcoinMiner()
}
pblock->nBits = nBits;
pblock->vtx[0].vout[0].nValue = pblock->GetBlockValue(nFees);
- printf("\n\nRunning BitcoinMiner with %d transactions in block\n", pblock->vtx.size());
+ printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());
//
@@ -2408,20 +2408,17 @@ bool BitcoinMiner()
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
CRITICAL_BLOCK(cs_main)
{
- if (pindexPrev != pindexBest)
+ if (pindexPrev == pindexBest)
{
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
- break;
+ // Save key
+ if (!AddKey(key))
+ return false;
+ key.MakeNewKey();
+
+ // Process this block the same as if we had received it from another node
+ if (!ProcessBlock(NULL, pblock.release()))
+ printf("ERROR in BitcoinMiner, ProcessBlock, block not accepted\n");
}
-
- // Save key
- if (!AddKey(key))
- return false;
- key.MakeNewKey();
-
- // Process this block the same as if we had received it from another node
- if (!ProcessBlock(NULL, pblock.release()))
- printf("ERROR in BitcoinMiner, ProcessBlock, block not accepted\n");
}
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
@@ -2439,8 +2436,10 @@ bool BitcoinMiner()
break;
if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)
break;
- if (!fGenerateBitcoins)
+ if (vNodes.empty())
break;
+ if (!fGenerateBitcoins)
+ return true;
if (fLimitProcessors && vnThreadsRunning[3] > nLimitProcessors)
return true;
tmp.block.nTime = pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());