aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bitcoinrpc.cpp18
-rw-r--r--src/init.cpp7
-rw-r--r--src/main.cpp11
-rw-r--r--src/main.h1
-rw-r--r--src/net.h3
-rw-r--r--src/util.cpp1
-rw-r--r--src/util.h1
7 files changed, 40 insertions, 2 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 8c3a615fd1..9dd6774984 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -2194,6 +2194,23 @@ Value getmemorypool(const Array& params, bool fHelp)
}
}
+Value getrawmempool(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 0)
+ throw runtime_error(
+ "getrawmempool\n"
+ "Returns all transaction ids in memory pool.");
+
+ vector<uint256> vtxid;
+ mempool.queryHashes(vtxid);
+
+ Array a;
+ BOOST_FOREACH(const uint256& hash, vtxid)
+ a.push_back(hash.ToString());
+
+ return a;
+}
+
Value getblockhash(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
@@ -2317,6 +2334,7 @@ static const CRPCCommand vRPCCommands[] =
{ "sendfrom", &sendfrom, false },
{ "sendmany", &sendmany, false },
{ "addmultisigaddress", &addmultisigaddress, false },
+ { "getrawmempool", &getrawmempool, true },
{ "getblock", &getblock, false },
{ "getblockhash", &getblockhash, false },
{ "gettransaction", &gettransaction, false },
diff --git a/src/init.cpp b/src/init.cpp
index 4ab7bdc429..21c32a6d67 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -358,6 +358,13 @@ bool AppInit2()
// ********************************************************* Step 3: parameter-to-internal-flags
fDebug = GetBoolArg("-debug");
+
+ // -debug implies fDebug*
+ if (fDebug)
+ fDebugNet = true;
+ else
+ fDebugNet = GetBoolArg("-debugnet");
+
bitdb.SetDetach(GetBoolArg("-detachdb", false));
#if !defined(WIN32) && !defined(QT_GUI)
diff --git a/src/main.cpp b/src/main.cpp
index e301ee7c7e..27802a4985 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -652,7 +652,15 @@ bool CTxMemPool::remove(CTransaction &tx)
return true;
}
+void CTxMemPool::queryHashes(std::vector<uint256>& vtxid)
+{
+ vtxid.clear();
+ LOCK(cs);
+ vtxid.reserve(mapTx.size());
+ for (map<uint256, CTransaction>::iterator mi = mapTx.begin(); mi != mapTx.end(); ++mi)
+ vtxid.push_back((*mi).first);
+}
@@ -3142,7 +3150,8 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
const CInv& inv = (*pto->mapAskFor.begin()).second;
if (!AlreadyHave(txdb, inv))
{
- printf("sending getdata: %s\n", inv.ToString().c_str());
+ if (fDebugNet)
+ printf("sending getdata: %s\n", inv.ToString().c_str());
vGetData.push_back(inv);
if (vGetData.size() >= 1000)
{
diff --git a/src/main.h b/src/main.h
index 29c9a8bce3..bb094ad3c7 100644
--- a/src/main.h
+++ b/src/main.h
@@ -1604,6 +1604,7 @@ public:
bool fCheckInputs, bool* pfMissingInputs);
bool addUnchecked(CTransaction &tx);
bool remove(CTransaction &tx);
+ void queryHashes(std::vector<uint256>& vtxid);
unsigned long size()
{
diff --git a/src/net.h b/src/net.h
index c9c965722e..f059c7a448 100644
--- a/src/net.h
+++ b/src/net.h
@@ -296,7 +296,8 @@ public:
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64& nRequestTime = mapAlreadyAskedFor[inv];
- printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
+ if (fDebugNet)
+ printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
// Make sure not to reuse time indexes to keep things in the same order
int64 nNow = (GetTime() - 1) * 1000000;
diff --git a/src/util.cpp b/src/util.cpp
index b07c9c1b7e..4b1c1ae116 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -58,6 +58,7 @@ using namespace std;
map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
+bool fDebugNet = false;
bool fPrintToConsole = false;
bool fPrintToDebugger = false;
bool fRequestShutdown = false;
diff --git a/src/util.h b/src/util.h
index c9b2b2f17c..21bec68ae0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -105,6 +105,7 @@ inline void Sleep(int64 n)
extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
+extern bool fDebugNet;
extern bool fPrintToConsole;
extern bool fPrintToDebugger;
extern bool fRequestShutdown;