mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
cli, refactor: deduplicate NetworkStringToId()
This commit is contained in:
parent
be82139b2a
commit
fdbfd250fb
1 changed files with 8 additions and 16 deletions
|
@ -259,6 +259,14 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx)
|
|||
reply->error = err;
|
||||
}
|
||||
|
||||
static int8_t NetworkStringToId(const std::string& str)
|
||||
{
|
||||
for (size_t i = 0; i < NETWORKS.size(); ++i) {
|
||||
if (str == NETWORKS[i]) return i;
|
||||
}
|
||||
return UNKNOWN_NETWORK;
|
||||
}
|
||||
|
||||
/** Class that handles the conversion from a command-line to a JSON-RPC request,
|
||||
* as well as converting back to a JSON object that can be shown as result.
|
||||
*/
|
||||
|
@ -273,15 +281,6 @@ public:
|
|||
/** Process addrinfo requests */
|
||||
class AddrinfoRequestHandler : public BaseRequestHandler
|
||||
{
|
||||
private:
|
||||
int8_t NetworkStringToId(const std::string& str) const
|
||||
{
|
||||
for (size_t i = 0; i < NETWORKS.size(); ++i) {
|
||||
if (str == NETWORKS[i]) return i;
|
||||
}
|
||||
return UNKNOWN_NETWORK;
|
||||
}
|
||||
|
||||
public:
|
||||
UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override
|
||||
{
|
||||
|
@ -396,13 +395,6 @@ private:
|
|||
std::array<std::array<uint16_t, NETWORKS.size() + 1>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total)
|
||||
uint8_t m_block_relay_peers_count{0};
|
||||
uint8_t m_manual_peers_count{0};
|
||||
int8_t NetworkStringToId(const std::string& str) const
|
||||
{
|
||||
for (size_t i = 0; i < NETWORKS.size(); ++i) {
|
||||
if (str == NETWORKS[i]) return i;
|
||||
}
|
||||
return UNKNOWN_NETWORK;
|
||||
}
|
||||
uint8_t m_details_level{0}; //!< Optional user-supplied arg to set dashboard details level
|
||||
bool DetailsRequested() const { return m_details_level; }
|
||||
bool IsAddressSelected() const { return m_details_level == 2 || m_details_level == 4; }
|
||||
|
|
Loading…
Add table
Reference in a new issue