From 2b6cecc4294ffe658745e299252d243b508893ae Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 17 Aug 2015 14:14:38 +0200 Subject: [PATCH] Simplify and use jsToInt() --- libdevcore/CommonJS.h | 4 +--- libweb3jsonrpc/WebThreeStubServerBase.cpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libdevcore/CommonJS.h b/libdevcore/CommonJS.h index 58938d2b2..893de2a7a 100644 --- a/libdevcore/CommonJS.h +++ b/libdevcore/CommonJS.h @@ -113,9 +113,7 @@ inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } inline int jsToInt(std::string const& _s) { - if (_s.size() > 2 && _s.substr(0, 2).compare("0x") == 0) - return std::stoi(_s, nullptr, 16); - return std::stoi(_s, nullptr, 10); + return std::stoi(_s, nullptr, 0); } inline std::string jsToDecimal(std::string const& _s) diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index 429636ac4..94fbc6477 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -782,7 +782,7 @@ bool WebThreeStubServerBase::eth_submitWork(string const& _nonce, string const&, bool WebThreeStubServerBase::eth_submitHashrate(string const& _hashes, string const& _id) { - client()->submitExternalHashrate(stoi(_hashes, nullptr, 0), jsToFixed<32>(_id)); + client()->submitExternalHashrate(jsToInt(_hashes), jsToFixed<32>(_id)); return true; }