Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Readd nPooledTx and nLastBlockTx in a reasonable way.

  • Loading branch information...
commit af10d0d65f527d39a2b9c6e994b58a2d02e058f2 1 parent 164f2d1
@TheBlueMatt authored
Showing with 35 additions and 15 deletions.
  1. +29 −15 src/bitcoinrpc.cpp
  2. +5 −0 src/main.cpp
  3. +1 −0  src/main.h
View
44 src/bitcoinrpc.cpp
@@ -43,6 +43,9 @@ static std::string strRPCUserColonPass;
static int64 nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;
+static CBlock* pLastBlockReturned;
+static CCriticalSection cs_pLastBlockReturned;
+
extern Value dumpprivkey(const Array& params, bool fHelp);
extern Value importprivkey(const Array& params, bool fHelp);
@@ -367,12 +370,18 @@ Value getmininginfo(const Array& params, bool fHelp)
"Returns an object containing mining-related information.");
Object obj;
+ CRITICAL_BLOCK(cs_pLastBlockReturned)
+ {
+ if (pLastBlockReturned)
+ obj.push_back(Pair("currentblocktx",(uint64_t)pLastBlockReturned->vtx.size()));
+ }
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("generate", (bool)fGenerateBitcoins));
obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
+ obj.push_back(Pair("pooledtx", (uint64_t)GetPooledTxSize()));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
@@ -1753,6 +1762,7 @@ Value validateaddress(const Array& params, bool fHelp)
return ret;
}
+
Value getwork(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
@@ -1786,23 +1796,27 @@ Value getwork(const Array& params, bool fHelp)
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
{
- if (pindexPrev != pindexBest)
+ CRITICAL_BLOCK(cs_pLastBlockReturned)
{
- // Deallocate old blocks since they're obsolete now
- mapNewBlock.clear();
- BOOST_FOREACH(CBlock* pblock, vNewBlock)
- delete pblock;
- vNewBlock.clear();
+ if (pindexPrev != pindexBest)
+ {
+ // Deallocate old blocks since they're obsolete now
+ mapNewBlock.clear();
+ BOOST_FOREACH(CBlock* pblock, vNewBlock)
+ delete pblock;
+ vNewBlock.clear();
+ }
+ nTransactionsUpdatedLast = nTransactionsUpdated;
+ pindexPrev = pindexBest;
+ nStart = GetTime();
+
+ // Create new block
+ pblock = CreateNewBlock(reservekey);
+ pLastBlockReturned = pblock;
+ if (!pblock)
+ throw JSONRPCError(-7, "Out of memory");
+ vNewBlock.push_back(pblock);
}
- nTransactionsUpdatedLast = nTransactionsUpdated;
- pindexPrev = pindexBest;
- nStart = GetTime();
-
- // Create new block
- pblock = CreateNewBlock(reservekey);
- if (!pblock)
- throw JSONRPCError(-7, "Out of memory");
- vNewBlock.push_back(pblock);
}
// Update nTime
View
5 src/main.cpp
@@ -709,6 +709,11 @@ int CTxIndex::GetDepthInMainChain() const
return 1 + nBestHeight - pindex->nHeight;
}
+uint64_t GetPooledTxSize()
+{
+ return mapTransactions.size();
+}
+
View
1  src/main.h
@@ -106,6 +106,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
int GetNumBlocksOfPeers();
bool IsInitialBlockDownload();
std::string GetWarnings(std::string strFor);
+uint64_t GetPooledTxSize();
Please sign in to comment.
Something went wrong with that request. Please try again.