diff options
| author | MarcoFalke <[email protected]> | 2020-07-15 21:29:41 +0200 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2020-08-02 21:32:36 +0200 |
| commit | fa89ca9b5bd334813fd7e7edb202c56b35076e8d (patch) | |
| tree | bb160f22ce43ace7f87a76de050e222f13a24758 /src | |
| parent | rpc: Treat all args after a hidden arg as hidden as well (diff) | |
| download | discoin-fa89ca9b5bd334813fd7e7edb202c56b35076e8d.tar.xz discoin-fa89ca9b5bd334813fd7e7edb202c56b35076e8d.zip | |
refactor: Use C++11 range based for loops to simplify rpc code
Diffstat (limited to 'src')
| -rw-r--r-- | src/rpc/blockchain.cpp | 6 | ||||
| -rw-r--r-- | src/rpc/mining.cpp | 6 | ||||
| -rw-r--r-- | src/rpc/misc.cpp | 6 | ||||
| -rw-r--r-- | src/rpc/net.cpp | 6 | ||||
| -rw-r--r-- | src/rpc/rawtransaction.cpp | 6 | ||||
| -rw-r--r-- | src/rpc/server.cpp | 9 |
6 files changed, 17 insertions, 22 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index f27373b57..868ff88d0 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2407,7 +2407,7 @@ static const CRPCCommand commands[] = { "hidden", "dumptxoutset", &dumptxoutset, {"path"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto& c : commands) { + t.appendCommand(c.name, &c); + } } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index fee6a893e..c357d6f5b 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1200,7 +1200,7 @@ static const CRPCCommand commands[] = { "hidden", "estimaterawfee", &estimaterawfee, {"conf_target", "threshold"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto& c : commands) { + t.appendCommand(c.name, &c); + } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 53d38f4e1..eee6f7943 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -619,7 +619,7 @@ static const CRPCCommand commands[] = { "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto& c : commands) { + t.appendCommand(c.name, &c); + } } diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 9981ea35d..4c0cfb8ba 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -796,7 +796,7 @@ static const CRPCCommand commands[] = { "network", "getnodeaddresses", &getnodeaddresses, {"count"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto& c : commands) { + t.appendCommand(c.name, &c); + } } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 70caf6009..a9f5d3cf8 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1821,7 +1821,7 @@ static const CRPCCommand commands[] = { "blockchain", "verifytxoutproof", &verifytxoutproof, {"proof"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto& c : commands) { + t.appendCommand(c.name, &c); + } } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index e5f6b1b9f..9c8e7fe04 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -256,13 +256,8 @@ static const CRPCCommand vRPCCommands[] = CRPCTable::CRPCTable() { - unsigned int vcidx; - for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++) - { - const CRPCCommand *pcmd; - - pcmd = &vRPCCommands[vcidx]; - mapCommands[pcmd->name].push_back(pcmd); + for (const auto& c : vRPCCommands) { + appendCommand(c.name, &c); } } |