Skip to content

Commit

Permalink
Replace boost::lexical_cast<int> with atoi (dashpay#1926)
Browse files Browse the repository at this point in the history
Also cleanup existing atoi-s in Dash code
  • Loading branch information
UdjinM6 authored and CryptoCentric committed Mar 2, 2019
1 parent 37d2a70 commit f23b405
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1805,10 +1805,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<unsigned int>(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) {
Expand Down
13 changes: 5 additions & 8 deletions src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "wallet/wallet.h"
#endif // ENABLE_WALLET

#include <boost/lexical_cast.hpp>

UniValue gobject(const JSONRPCRequest& request)
{
std::string strCommand;
Expand Down Expand Up @@ -145,8 +143,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<int>(strRevision);
int nTime = boost::lexical_cast<int>(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
Expand Down Expand Up @@ -231,8 +229,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<int>(strRevision);
int nTime = boost::lexical_cast<int>(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);
Expand Down Expand Up @@ -818,8 +816,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<uint32_t>(strVout);
mnCollateralOutpoint = COutPoint(txid, vout);
mnCollateralOutpoint = COutPoint(txid, (uint32_t)atoi(strVout));
}

// FIND OBJECT USER IS LOOKING FOR
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,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;
Expand Down Expand Up @@ -366,7 +366,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);

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3228,7 +3228,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!
Expand Down

0 comments on commit f23b405

Please sign in to comment.