Skip to content

Commit 8152d3f

Browse files
committed
Merge #9476: [refactor] Remove using namespace <xxx> from rpc/ & script/ sources
8cbfc4e Refactor: Remove using namespace <xxx> from script/ (Karl-Johan Alm) f3c264e Refactor: Remove using namespace <xxx> from rpc/ (Karl-Johan Alm) Tree-SHA512: 407e80eeda0b8e1df22c5fcba33572e117542fde83c67357f6c2d98fa60bcc7b21bb88ad9a1ee59062fbec17fadaa4836b69e8e6d18188b4027b794357634467
2 parents c047b16 + 8cbfc4e commit 8152d3f

File tree

13 files changed

+192
-218
lines changed

13 files changed

+192
-218
lines changed

src/rpc/blockchain.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include <mutex>
3030
#include <condition_variable>
31-
using namespace std;
3231

3332
struct CUpdatedBlock
3433
{
@@ -154,7 +153,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
154153
UniValue getblockcount(const JSONRPCRequest& request)
155154
{
156155
if (request.fHelp || request.params.size() != 0)
157-
throw runtime_error(
156+
throw std::runtime_error(
158157
"getblockcount\n"
159158
"\nReturns the number of blocks in the longest blockchain.\n"
160159
"\nResult:\n"
@@ -171,7 +170,7 @@ UniValue getblockcount(const JSONRPCRequest& request)
171170
UniValue getbestblockhash(const JSONRPCRequest& request)
172171
{
173172
if (request.fHelp || request.params.size() != 0)
174-
throw runtime_error(
173+
throw std::runtime_error(
175174
"getbestblockhash\n"
176175
"\nReturns the hash of the best (tip) block in the longest blockchain.\n"
177176
"\nResult:\n"
@@ -198,7 +197,7 @@ void RPCNotifyBlockChange(bool ibd, const CBlockIndex * pindex)
198197
UniValue waitfornewblock(const JSONRPCRequest& request)
199198
{
200199
if (request.fHelp || request.params.size() > 1)
201-
throw runtime_error(
200+
throw std::runtime_error(
202201
"waitfornewblock (timeout)\n"
203202
"\nWaits for a specific new block and returns useful info about it.\n"
204203
"\nReturns the current block on timeout or exit.\n"
@@ -236,7 +235,7 @@ UniValue waitfornewblock(const JSONRPCRequest& request)
236235
UniValue waitforblock(const JSONRPCRequest& request)
237236
{
238237
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
239-
throw runtime_error(
238+
throw std::runtime_error(
240239
"waitforblock <blockhash> (timeout)\n"
241240
"\nWaits for a specific new block and returns useful info about it.\n"
242241
"\nReturns the current block on timeout or exit.\n"
@@ -278,7 +277,7 @@ UniValue waitforblock(const JSONRPCRequest& request)
278277
UniValue waitforblockheight(const JSONRPCRequest& request)
279278
{
280279
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
281-
throw runtime_error(
280+
throw std::runtime_error(
282281
"waitforblockheight <height> (timeout)\n"
283282
"\nWaits for (at least) block height and returns the height and hash\n"
284283
"of the current tip.\n"
@@ -320,7 +319,7 @@ UniValue waitforblockheight(const JSONRPCRequest& request)
320319
UniValue getdifficulty(const JSONRPCRequest& request)
321320
{
322321
if (request.fHelp || request.params.size() != 0)
323-
throw runtime_error(
322+
throw std::runtime_error(
324323
"getdifficulty\n"
325324
"\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
326325
"\nResult:\n"
@@ -368,15 +367,15 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
368367
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors()));
369368
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
370369
const CTransaction& tx = e.GetTx();
371-
set<string> setDepends;
370+
std::set<std::string> setDepends;
372371
BOOST_FOREACH(const CTxIn& txin, tx.vin)
373372
{
374373
if (mempool.exists(txin.prevout.hash))
375374
setDepends.insert(txin.prevout.hash.ToString());
376375
}
377376

378377
UniValue depends(UniValue::VARR);
379-
BOOST_FOREACH(const string& dep, setDepends)
378+
BOOST_FOREACH(const std::string& dep, setDepends)
380379
{
381380
depends.push_back(dep);
382381
}
@@ -401,7 +400,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
401400
}
402401
else
403402
{
404-
vector<uint256> vtxid;
403+
std::vector<uint256> vtxid;
405404
mempool.queryHashes(vtxid);
406405

407406
UniValue a(UniValue::VARR);
@@ -415,7 +414,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
415414
UniValue getrawmempool(const JSONRPCRequest& request)
416415
{
417416
if (request.fHelp || request.params.size() > 1)
418-
throw runtime_error(
417+
throw std::runtime_error(
419418
"getrawmempool ( verbose )\n"
420419
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
421420
"\nArguments:\n"
@@ -446,7 +445,7 @@ UniValue getrawmempool(const JSONRPCRequest& request)
446445
UniValue getmempoolancestors(const JSONRPCRequest& request)
447446
{
448447
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
449-
throw runtime_error(
448+
throw std::runtime_error(
450449
"getmempoolancestors txid (verbose)\n"
451450
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n"
452451
"\nArguments:\n"
@@ -510,7 +509,7 @@ UniValue getmempoolancestors(const JSONRPCRequest& request)
510509
UniValue getmempooldescendants(const JSONRPCRequest& request)
511510
{
512511
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
513-
throw runtime_error(
512+
throw std::runtime_error(
514513
"getmempooldescendants txid (verbose)\n"
515514
"\nIf txid is in the mempool, returns all in-mempool descendants.\n"
516515
"\nArguments:\n"
@@ -574,7 +573,7 @@ UniValue getmempooldescendants(const JSONRPCRequest& request)
574573
UniValue getmempoolentry(const JSONRPCRequest& request)
575574
{
576575
if (request.fHelp || request.params.size() != 1) {
577-
throw runtime_error(
576+
throw std::runtime_error(
578577
"getmempoolentry txid\n"
579578
"\nReturns mempool data for given transaction\n"
580579
"\nArguments:\n"
@@ -607,7 +606,7 @@ UniValue getmempoolentry(const JSONRPCRequest& request)
607606
UniValue getblockhash(const JSONRPCRequest& request)
608607
{
609608
if (request.fHelp || request.params.size() != 1)
610-
throw runtime_error(
609+
throw std::runtime_error(
611610
"getblockhash height\n"
612611
"\nReturns hash of block in best-block-chain at height provided.\n"
613612
"\nArguments:\n"
@@ -632,7 +631,7 @@ UniValue getblockhash(const JSONRPCRequest& request)
632631
UniValue getblockheader(const JSONRPCRequest& request)
633632
{
634633
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
635-
throw runtime_error(
634+
throw std::runtime_error(
636635
"getblockheader \"hash\" ( verbose )\n"
637636
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
638637
"If verbose is true, returns an Object with information about blockheader <hash>.\n"
@@ -691,7 +690,7 @@ UniValue getblockheader(const JSONRPCRequest& request)
691690
UniValue getblock(const JSONRPCRequest& request)
692691
{
693692
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
694-
throw runtime_error(
693+
throw std::runtime_error(
695694
"getblock \"blockhash\" ( verbose )\n"
696695
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
697696
"If verbose is true, returns an Object with information about block <hash>.\n"
@@ -818,7 +817,7 @@ static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
818817
UniValue pruneblockchain(const JSONRPCRequest& request)
819818
{
820819
if (request.fHelp || request.params.size() != 1)
821-
throw runtime_error(
820+
throw std::runtime_error(
822821
"pruneblockchain\n"
823822
"\nArguments:\n"
824823
"1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp\n"
@@ -867,7 +866,7 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
867866
UniValue gettxoutsetinfo(const JSONRPCRequest& request)
868867
{
869868
if (request.fHelp || request.params.size() != 0)
870-
throw runtime_error(
869+
throw std::runtime_error(
871870
"gettxoutsetinfo\n"
872871
"\nReturns statistics about the unspent transaction output set.\n"
873872
"Note this call may take some time.\n"
@@ -907,7 +906,7 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
907906
UniValue gettxout(const JSONRPCRequest& request)
908907
{
909908
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
910-
throw runtime_error(
909+
throw std::runtime_error(
911910
"gettxout \"txid\" n ( include_mempool )\n"
912911
"\nReturns details about an unspent transaction output.\n"
913912
"\nArguments:\n"
@@ -989,7 +988,7 @@ UniValue verifychain(const JSONRPCRequest& request)
989988
int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL);
990989
int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
991990
if (request.fHelp || request.params.size() > 2)
992-
throw runtime_error(
991+
throw std::runtime_error(
993992
"verifychain ( checklevel nblocks )\n"
994993
"\nVerifies blockchain database.\n"
995994
"\nArguments:\n"
@@ -1075,7 +1074,7 @@ void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name,
10751074
UniValue getblockchaininfo(const JSONRPCRequest& request)
10761075
{
10771076
if (request.fHelp || request.params.size() != 0)
1078-
throw runtime_error(
1077+
throw std::runtime_error(
10791078
"getblockchaininfo\n"
10801079
"Returns an object containing various state info regarding blockchain processing.\n"
10811080
"\nResult:\n"
@@ -1168,7 +1167,7 @@ struct CompareBlocksByHeight
11681167
UniValue getchaintips(const JSONRPCRequest& request)
11691168
{
11701169
if (request.fHelp || request.params.size() != 0)
1171-
throw runtime_error(
1170+
throw std::runtime_error(
11721171
"getchaintips\n"
11731172
"Return information about all known tips in the block tree,"
11741173
" including the main chain as well as orphaned branches.\n"
@@ -1201,7 +1200,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
12011200
LOCK(cs_main);
12021201

12031202
/*
1204-
* Idea: the set of chain tips is chainActive.tip, plus orphan blocks which do not have another orphan building off of them.
1203+
* Idea: the set of chain tips is chainActive.tip, plus orphan blocks which do not have another orphan building off of them.
12051204
* Algorithm:
12061205
* - Make one pass through mapBlockIndex, picking out the orphan blocks, and also storing a set of the orphan block's pprev pointers.
12071206
* - Iterate through the orphan blocks. If the block isn't pointed to by another orphan, it is a chain tip.
@@ -1240,7 +1239,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
12401239
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
12411240
obj.push_back(Pair("branchlen", branchLen));
12421241

1243-
string status;
1242+
std::string status;
12441243
if (chainActive.Contains(block)) {
12451244
// This block is part of the currently active chain.
12461245
status = "active";
@@ -1284,7 +1283,7 @@ UniValue mempoolInfoToJSON()
12841283
UniValue getmempoolinfo(const JSONRPCRequest& request)
12851284
{
12861285
if (request.fHelp || request.params.size() != 0)
1287-
throw runtime_error(
1286+
throw std::runtime_error(
12881287
"getmempoolinfo\n"
12891288
"\nReturns details on the active state of the TX memory pool.\n"
12901289
"\nResult:\n"
@@ -1306,7 +1305,7 @@ UniValue getmempoolinfo(const JSONRPCRequest& request)
13061305
UniValue preciousblock(const JSONRPCRequest& request)
13071306
{
13081307
if (request.fHelp || request.params.size() != 1)
1309-
throw runtime_error(
1308+
throw std::runtime_error(
13101309
"preciousblock \"blockhash\"\n"
13111310
"\nTreats a block as if it were received before others with the same work.\n"
13121311
"\nA later preciousblock call can override the effect of an earlier one.\n"
@@ -1344,7 +1343,7 @@ UniValue preciousblock(const JSONRPCRequest& request)
13441343
UniValue invalidateblock(const JSONRPCRequest& request)
13451344
{
13461345
if (request.fHelp || request.params.size() != 1)
1347-
throw runtime_error(
1346+
throw std::runtime_error(
13481347
"invalidateblock \"blockhash\"\n"
13491348
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
13501349
"\nArguments:\n"
@@ -1382,7 +1381,7 @@ UniValue invalidateblock(const JSONRPCRequest& request)
13821381
UniValue reconsiderblock(const JSONRPCRequest& request)
13831382
{
13841383
if (request.fHelp || request.params.size() != 1)
1385-
throw runtime_error(
1384+
throw std::runtime_error(
13861385
"reconsiderblock \"blockhash\"\n"
13871386
"\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
13881387
"This can be used to undo the effects of invalidateblock.\n"

src/rpc/client.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
1414
#include <univalue.h>
1515

16-
using namespace std;
17-
1816
class CRPCConvertParam
1917
{
2018
public:
@@ -168,7 +166,7 @@ UniValue ParseNonRFCJSONValue(const std::string& strVal)
168166
UniValue jVal;
169167
if (!jVal.read(std::string("[")+strVal+std::string("]")) ||
170168
!jVal.isArray() || jVal.size()!=1)
171-
throw runtime_error(string("Error parsing JSON:")+strVal);
169+
throw std::runtime_error(std::string("Error parsing JSON:")+strVal);
172170
return jVal[0];
173171
}
174172

src/rpc/mining.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
#include <univalue.h>
3232

33-
using namespace std;
34-
3533
/**
3634
* Return average network hashes per second based on the last 'lookup' blocks,
3735
* or from the last difficulty change if 'lookup' is nonpositive.
@@ -77,7 +75,7 @@ UniValue GetNetworkHashPS(int lookup, int height) {
7775
UniValue getnetworkhashps(const JSONRPCRequest& request)
7876
{
7977
if (request.fHelp || request.params.size() > 2)
80-
throw runtime_error(
78+
throw std::runtime_error(
8179
"getnetworkhashps ( nblocks height )\n"
8280
"\nReturns the estimated network hashes per second based on the last n blocks.\n"
8381
"Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
@@ -149,7 +147,7 @@ UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nG
149147
UniValue generate(const JSONRPCRequest& request)
150148
{
151149
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
152-
throw runtime_error(
150+
throw std::runtime_error(
153151
"generate nblocks ( maxtries )\n"
154152
"\nMine up to nblocks blocks immediately (before the RPC call returns)\n"
155153
"\nArguments:\n"
@@ -185,7 +183,7 @@ UniValue generate(const JSONRPCRequest& request)
185183
UniValue generatetoaddress(const JSONRPCRequest& request)
186184
{
187185
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
188-
throw runtime_error(
186+
throw std::runtime_error(
189187
"generatetoaddress nblocks address (maxtries)\n"
190188
"\nMine blocks immediately to a specified address (before the RPC call returns)\n"
191189
"\nArguments:\n"
@@ -208,7 +206,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request)
208206
CBitcoinAddress address(request.params[1].get_str());
209207
if (!address.IsValid())
210208
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
211-
209+
212210
boost::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript());
213211
coinbaseScript->reserveScript = GetScriptForDestination(address.Get());
214212

@@ -218,7 +216,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request)
218216
UniValue getmininginfo(const JSONRPCRequest& request)
219217
{
220218
if (request.fHelp || request.params.size() != 0)
221-
throw runtime_error(
219+
throw std::runtime_error(
222220
"getmininginfo\n"
223221
"\nReturns a json object containing mining-related information."
224222
"\nResult:\n"
@@ -259,7 +257,7 @@ UniValue getmininginfo(const JSONRPCRequest& request)
259257
UniValue prioritisetransaction(const JSONRPCRequest& request)
260258
{
261259
if (request.fHelp || request.params.size() != 2)
262-
throw runtime_error(
260+
throw std::runtime_error(
263261
"prioritisetransaction <txid> <fee delta>\n"
264262
"Accepts the transaction into mined blocks at a higher (or lower) priority\n"
265263
"\nArguments:\n"
@@ -315,7 +313,7 @@ std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
315313
UniValue getblocktemplate(const JSONRPCRequest& request)
316314
{
317315
if (request.fHelp || request.params.size() > 1)
318-
throw runtime_error(
316+
throw std::runtime_error(
319317
"getblocktemplate ( TemplateRequest )\n"
320318
"\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
321319
"It returns data needed to construct a block to work on.\n"
@@ -553,7 +551,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
553551
UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");
554552

555553
UniValue transactions(UniValue::VARR);
556-
map<uint256, int64_t> setTxIndex;
554+
std::map<uint256, int64_t> setTxIndex;
557555
int i = 0;
558556
for (const auto& it : pblock->vtx) {
559557
const CTransaction& tx = *it;
@@ -712,7 +710,7 @@ class submitblock_StateCatcher : public CValidationInterface
712710
UniValue submitblock(const JSONRPCRequest& request)
713711
{
714712
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
715-
throw runtime_error(
713+
throw std::runtime_error(
716714
"submitblock \"hexdata\" ( \"jsonparametersobject\" )\n"
717715
"\nAttempts to submit new block to network.\n"
718716
"The 'jsonparametersobject' parameter is currently ignored.\n"
@@ -777,7 +775,7 @@ UniValue submitblock(const JSONRPCRequest& request)
777775
UniValue estimatefee(const JSONRPCRequest& request)
778776
{
779777
if (request.fHelp || request.params.size() != 1)
780-
throw runtime_error(
778+
throw std::runtime_error(
781779
"estimatefee nblocks\n"
782780
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
783781
"confirmation within nblocks blocks. Uses virtual transaction size of transaction\n"
@@ -811,7 +809,7 @@ UniValue estimatefee(const JSONRPCRequest& request)
811809
UniValue estimatesmartfee(const JSONRPCRequest& request)
812810
{
813811
if (request.fHelp || request.params.size() != 1)
814-
throw runtime_error(
812+
throw std::runtime_error(
815813
"estimatesmartfee nblocks\n"
816814
"\nWARNING: This interface is unstable and may disappear or change!\n"
817815
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"

0 commit comments

Comments
 (0)