@@ -175,45 +175,8 @@ UniValue getdifficulty(const UniValue& params, bool fHelp)
175175 return GetDifficulty ();
176176}
177177
178-
179- UniValue getrawmempool (const UniValue& params, bool fHelp )
178+ UniValue mempoolToJSON (bool fVerbose = false )
180179{
181- if (fHelp || params.size () > 1 )
182- throw runtime_error (
183- " getrawmempool ( verbose )\n "
184- " \n Returns all transaction ids in memory pool as a json array of string transaction ids.\n "
185- " \n Arguments:\n "
186- " 1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n "
187- " \n Result: (for verbose = false):\n "
188- " [ (json array of string)\n "
189- " \" transactionid\" (string) The transaction id\n "
190- " ,...\n "
191- " ]\n "
192- " \n Result: (for verbose = true):\n "
193- " { (json object)\n "
194- " \" transactionid\" : { (json object)\n "
195- " \" size\" : n, (numeric) transaction size in bytes\n "
196- " \" fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + " \n "
197- " \" time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n "
198- " \" height\" : n, (numeric) block height when transaction entered pool\n "
199- " \" startingpriority\" : n, (numeric) priority when transaction entered pool\n "
200- " \" currentpriority\" : n, (numeric) transaction priority now\n "
201- " \" depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n "
202- " \" transactionid\" , (string) parent transaction id\n "
203- " ... ]\n "
204- " }, ...\n "
205- " }\n "
206- " \n Examples\n "
207- + HelpExampleCli (" getrawmempool" , " true" )
208- + HelpExampleRpc (" getrawmempool" , " true" )
209- );
210-
211- LOCK (cs_main);
212-
213- bool fVerbose = false ;
214- if (params.size () > 0 )
215- fVerbose = params[0 ].get_bool ();
216-
217180 if (fVerbose )
218181 {
219182 LOCK (mempool.cs );
@@ -261,6 +224,47 @@ UniValue getrawmempool(const UniValue& params, bool fHelp)
261224 }
262225}
263226
227+ UniValue getrawmempool (const UniValue& params, bool fHelp )
228+ {
229+ if (fHelp || params.size () > 1 )
230+ throw runtime_error (
231+ " getrawmempool ( verbose )\n "
232+ " \n Returns all transaction ids in memory pool as a json array of string transaction ids.\n "
233+ " \n Arguments:\n "
234+ " 1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n "
235+ " \n Result: (for verbose = false):\n "
236+ " [ (json array of string)\n "
237+ " \" transactionid\" (string) The transaction id\n "
238+ " ,...\n "
239+ " ]\n "
240+ " \n Result: (for verbose = true):\n "
241+ " { (json object)\n "
242+ " \" transactionid\" : { (json object)\n "
243+ " \" size\" : n, (numeric) transaction size in bytes\n "
244+ " \" fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + " \n "
245+ " \" time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n "
246+ " \" height\" : n, (numeric) block height when transaction entered pool\n "
247+ " \" startingpriority\" : n, (numeric) priority when transaction entered pool\n "
248+ " \" currentpriority\" : n, (numeric) transaction priority now\n "
249+ " \" depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n "
250+ " \" transactionid\" , (string) parent transaction id\n "
251+ " ... ]\n "
252+ " }, ...\n "
253+ " }\n "
254+ " \n Examples\n "
255+ + HelpExampleCli (" getrawmempool" , " true" )
256+ + HelpExampleRpc (" getrawmempool" , " true" )
257+ );
258+
259+ LOCK (cs_main);
260+
261+ bool fVerbose = false ;
262+ if (params.size () > 0 )
263+ fVerbose = params[0 ].get_bool ();
264+
265+ return mempoolToJSON (fVerbose );
266+ }
267+
264268UniValue getblockhash (const UniValue& params, bool fHelp )
265269{
266270 if (fHelp || params.size () != 1 )
@@ -757,6 +761,16 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
757761 return res;
758762}
759763
764+ UniValue mempoolInfoToJSON ()
765+ {
766+ UniValue ret (UniValue::VOBJ );
767+ ret.push_back (Pair (" size" , (int64_t ) mempool.size ()));
768+ ret.push_back (Pair (" bytes" , (int64_t ) mempool.GetTotalTxSize ()));
769+ ret.push_back (Pair (" usage" , (int64_t ) mempool.DynamicMemoryUsage ()));
770+
771+ return ret;
772+ }
773+
760774UniValue getmempoolinfo (const UniValue& params, bool fHelp )
761775{
762776 if (fHelp || params.size () != 0 )
@@ -774,12 +788,7 @@ UniValue getmempoolinfo(const UniValue& params, bool fHelp)
774788 + HelpExampleRpc (" getmempoolinfo" , " " )
775789 );
776790
777- UniValue ret (UniValue::VOBJ );
778- ret.push_back (Pair (" size" , (int64_t ) mempool.size ()));
779- ret.push_back (Pair (" bytes" , (int64_t ) mempool.GetTotalTxSize ()));
780- ret.push_back (Pair (" usage" , (int64_t ) mempool.DynamicMemoryUsage ()));
781-
782- return ret;
791+ return mempoolInfoToJSON ();
783792}
784793
785794UniValue invalidateblock (const UniValue& params, bool fHelp )
0 commit comments