From 06ff1a2534ce6c36187d43a9317a92ec0e579d5e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 11 Feb 2018 18:16:57 +0300 Subject: [PATCH] Replace boost::lexical_cast with atoi Also cleanup existing atoi-s in Dash code --- src/init.cpp | 4 ++-- src/rpc/governance.cpp | 13 +++++-------- src/rpc/masternode.cpp | 4 ++-- src/wallet/wallet.cpp | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index eaffffbe6113c..2376172b2a778 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1772,10 +1772,10 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) LOCK(pwalletMain->cs_wallet); LogPrintf("Locking Masternodes:\n"); uint256 mnTxHash; - int outputIndex; + uint32_t outputIndex; for (const auto& mne : masternodeConfig.getEntries()) { mnTxHash.SetHex(mne.getTxHash()); - outputIndex = boost::lexical_cast(mne.getOutputIndex()); + outputIndex = (uint32_t)atoi(mne.getOutputIndex()); COutPoint outpoint = COutPoint(mnTxHash, outputIndex); // don't lock non-spendable outpoint (i.e. it's already spent or it's not from this wallet at all) if(pwalletMain->IsMine(CTxIn(outpoint)) != ISMINE_SPENDABLE) { diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index b4f1a8a00e6a7..3f7323f18a064 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -24,8 +24,6 @@ #include "wallet/wallet.h" #endif // ENABLE_WALLET -#include - UniValue gobject(const JSONRPCRequest& request) { std::string strCommand; @@ -144,8 +142,8 @@ UniValue gobject(const JSONRPCRequest& request) std::string strRevision = request.params[2].get_str(); std::string strTime = request.params[3].get_str(); - int nRevision = boost::lexical_cast(strRevision); - int nTime = boost::lexical_cast(strTime); + int nRevision = atoi(strRevision); + int64_t nTime = atoi64(strTime); std::string strData = request.params[4].get_str(); // CREATE A NEW COLLATERAL TRANSACTION FOR THIS SPECIFIC OBJECT @@ -230,8 +228,8 @@ UniValue gobject(const JSONRPCRequest& request) std::string strRevision = request.params[2].get_str(); std::string strTime = request.params[3].get_str(); - int nRevision = boost::lexical_cast(strRevision); - int nTime = boost::lexical_cast(strTime); + int nRevision = atoi(strRevision); + int64_t nTime = atoi64(strTime); std::string strData = request.params[4].get_str(); CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strData); @@ -817,8 +815,7 @@ UniValue gobject(const JSONRPCRequest& request) if (request.params.size() == 4) { uint256 txid = ParseHashV(request.params[2], "Masternode Collateral hash"); std::string strVout = request.params[3].get_str(); - uint32_t vout = boost::lexical_cast(strVout); - mnCollateralOutpoint = COutPoint(txid, vout); + mnCollateralOutpoint = COutPoint(txid, (uint32_t)atoi(strVout)); } // FIND OBJECT USER IS LOOKING FOR diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 1639ada04c0c1..4957de9fd4040 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -317,7 +317,7 @@ UniValue masternode(const JSONRPCRequest& request) for (const auto& mne : masternodeConfig.getEntries()) { std::string strError; - COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str()))); + COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), (uint32_t)atoi(mne.getOutputIndex())); CMasternode mn; bool fFound = mnodeman.Get(outpoint, mn); CMasternodeBroadcast mnb; @@ -365,7 +365,7 @@ UniValue masternode(const JSONRPCRequest& request) UniValue resultObj(UniValue::VOBJ); for (const auto& mne : masternodeConfig.getEntries()) { - COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str()))); + COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), (uint32_t)atoi(mne.getOutputIndex())); CMasternode mn; bool fFound = mnodeman.Get(outpoint, mn); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b25099bcfffe7..f24d3ac6627a3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3226,7 +3226,7 @@ bool CWallet::GetMasternodeOutpointAndKeys(COutPoint& outpointRet, CPubKey& pubK // Find specific vin uint256 txHash = uint256S(strTxHash); - int nOutputIndex = atoi(strOutputIndex.c_str()); + int nOutputIndex = atoi(strOutputIndex); for (const auto& out : vPossibleCoins) if(out.tx->GetHash() == txHash && out.i == nOutputIndex) // found it!