Merge pull request #1502 from jgarzik/getrawmempool
RPC: add 'getrawmempool', listing all transaction ids in memory pool
This commit is contained in:
commit
cb1fcde2f4
3 changed files with 27 additions and 0 deletions
|
@ -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)
|
Value getblockhash(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
|
@ -2317,6 +2334,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||||
{ "sendfrom", &sendfrom, false },
|
{ "sendfrom", &sendfrom, false },
|
||||||
{ "sendmany", &sendmany, false },
|
{ "sendmany", &sendmany, false },
|
||||||
{ "addmultisigaddress", &addmultisigaddress, false },
|
{ "addmultisigaddress", &addmultisigaddress, false },
|
||||||
|
{ "getrawmempool", &getrawmempool, true },
|
||||||
{ "getblock", &getblock, false },
|
{ "getblock", &getblock, false },
|
||||||
{ "getblockhash", &getblockhash, false },
|
{ "getblockhash", &getblockhash, false },
|
||||||
{ "gettransaction", &gettransaction, false },
|
{ "gettransaction", &gettransaction, false },
|
||||||
|
|
|
@ -652,7 +652,15 @@ bool CTxMemPool::remove(CTransaction &tx)
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1604,6 +1604,7 @@ public:
|
||||||
bool fCheckInputs, bool* pfMissingInputs);
|
bool fCheckInputs, bool* pfMissingInputs);
|
||||||
bool addUnchecked(CTransaction &tx);
|
bool addUnchecked(CTransaction &tx);
|
||||||
bool remove(CTransaction &tx);
|
bool remove(CTransaction &tx);
|
||||||
|
void queryHashes(std::vector<uint256>& vtxid);
|
||||||
|
|
||||||
unsigned long size()
|
unsigned long size()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue