diff --git a/src/ripple/basics/utility/PlatformMacros.h b/src/ripple/basics/utility/PlatformMacros.h index 90fe8f67f..6d7f7d359 100644 --- a/src/ripple/basics/utility/PlatformMacros.h +++ b/src/ripple/basics/utility/PlatformMacros.h @@ -25,26 +25,8 @@ namespace ripple { -// -// VFALCO DEPRECATED, this should all be removed. -// - -template -inline -std::enable_if_t< - (std::is_integral::value || std::is_enum::value) && - (std::is_integral::value || std::is_enum::value), -bool> -is_bit_set(X const x, Y const y) -{ - if (x & y) - return true; - return false; -} - // VFALCO TODO Clean this stuff up. Remove as much as possible // DEPRECATED -#define nothing() do {} while (0) #define RIPPLE_ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0])) } // ripple diff --git a/src/ripple/module/app/ledger/Ledger.cpp b/src/ripple/module/app/ledger/Ledger.cpp index 0e53c37f2..684d3ac74 100644 --- a/src/ripple/module/app/ledger/Ledger.cpp +++ b/src/ripple/module/app/ledger/Ledger.cpp @@ -1070,7 +1070,8 @@ Json::Value Ledger::getJson (int options) { Json::Value ledger (Json::objectValue); - bool bFull = is_bit_set (options, LEDGER_JSON_FULL); + bool const bFull (options & LEDGER_JSON_FULL); + bool const bExpand (options & LEDGER_JSON_EXPAND); ScopedLockType sl (mLock); @@ -1106,7 +1107,7 @@ Json::Value Ledger::getJson (int options) ledger[jss::closed] = false; } - if (mTransactionMap && (bFull || is_bit_set (options, LEDGER_JSON_DUMP_TXRP))) + if (mTransactionMap && (bFull || options & LEDGER_JSON_DUMP_TXRP)) { Json::Value& txns = (ledger[jss::transactions] = Json::arrayValue); SHAMapTreeNode::TNType type; @@ -1114,7 +1115,7 @@ Json::Value Ledger::getJson (int options) for (SHAMapItem::pointer item = mTransactionMap->peekFirstItem (type); !!item; item = mTransactionMap->peekNextItem (item->getTag (), type)) { - if (bFull || is_bit_set (options, LEDGER_JSON_EXPAND)) + if (bFull || bExpand) { if (type == SHAMapTreeNode::tnTRANSACTION_NM) { @@ -1147,10 +1148,10 @@ Json::Value Ledger::getJson (int options) } - if (mAccountStateMap && (bFull || is_bit_set (options, LEDGER_JSON_DUMP_STATE))) + if (mAccountStateMap && (bFull || options & LEDGER_JSON_DUMP_STATE)) { Json::Value& state = (ledger[jss::accountState] = Json::arrayValue); - if (bFull || is_bit_set (options, LEDGER_JSON_EXPAND)) + if (bFull || bExpand) visitStateItems(std::bind(stateItemFullAppender, std::ref(state), std::placeholders::_1)); else diff --git a/src/ripple/module/app/ledger/LedgerEntrySet.cpp b/src/ripple/module/app/ledger/LedgerEntrySet.cpp index 2baf4ed1d..28f65a24b 100644 --- a/src/ripple/module/app/ledger/LedgerEntrySet.cpp +++ b/src/ripple/module/app/ledger/LedgerEntrySet.cpp @@ -842,14 +842,10 @@ TER LedgerEntrySet::dirDelete ( else if (bKeepRoot) { // If root overflowed and not allowed to delete overflowed root node. - - nothing (); } else if (uNodePrevious != uNodeNext) { // Have more than 2 nodes. Can't delete root node. - - nothing (); } else { @@ -868,8 +864,6 @@ TER LedgerEntrySet::dirDelete ( else { // Have an entry, can't delete root node. - - nothing (); } } } @@ -916,8 +910,6 @@ TER LedgerEntrySet::dirDelete ( { // Not allowed to delete last node as root was overflowed. // Or, have pervious entries preventing complete delete. - - nothing (); } else { @@ -936,8 +928,6 @@ TER LedgerEntrySet::dirDelete ( else { // Root has an entry, can't delete. - - nothing (); } } } @@ -1196,36 +1186,31 @@ LedgerEntrySet::rippleQualityIn (const uint160& uToAccountID, const uint160& uCurrencyID, SField::ref sfLow, SField::ref sfHigh) { - std::uint32_t uQuality = QUALITY_ONE; - SLE::pointer sleRippleState; + std::uint32_t uQuality (QUALITY_ONE); if (uToAccountID == uFromAccountID) + return uQuality; + + SLE::pointer sleRippleState (entryCache (ltRIPPLE_STATE, + Ledger::getRippleStateIndex (uToAccountID, uFromAccountID, uCurrencyID))); + + if (sleRippleState) { - nothing (); + SField::ref sfField = uToAccountID < uFromAccountID ? sfLow : sfHigh; + + uQuality = sleRippleState->isFieldPresent (sfField) + ? sleRippleState->getFieldU32 (sfField) + : QUALITY_ONE; + + if (!uQuality) + uQuality = 1; // Avoid divide by zero. } else { - sleRippleState = entryCache (ltRIPPLE_STATE, - Ledger::getRippleStateIndex (uToAccountID, uFromAccountID, uCurrencyID)); - - if (sleRippleState) - { - SField::ref sfField = uToAccountID < uFromAccountID ? sfLow : sfHigh; - - uQuality = sleRippleState->isFieldPresent (sfField) - ? sleRippleState->getFieldU32 (sfField) - : QUALITY_ONE; - - if (!uQuality) - uQuality = 1; // Avoid divide by zero. - } - else - { - // XXX Ideally, catch no before this. So we can assert to be stricter. - uQuality = QUALITY_ONE; - } + // XXX Ideally, catch no before this. So we can assert to be stricter. + uQuality = QUALITY_ONE; } - + WriteLog (lsTRACE, LedgerEntrySet) << "rippleQuality: " << (sfLow == sfLowQualityIn ? "in" : "out") << " uToAccountID=" << RippleAddress::createHumanAccountID (uToAccountID) << @@ -1234,8 +1219,6 @@ LedgerEntrySet::rippleQualityIn (const uint160& uToAccountID, " bLine=" << std::boolalpha << !!sleRippleState << " uQuality=" << (uQuality / 1000000000.0); - // assert(uToAccountID == uFromAccountID || !!sleRippleState); - return uQuality; } @@ -1541,14 +1524,14 @@ TER LedgerEntrySet::rippleCredit (const uint160& uSenderID, const uint160& uRece " amount=" << saAmount.getFullText () << " after=" << saBalance.getFullText (); - bool bDelete = false; - std::uint32_t uFlags; + std::uint32_t const uFlags (sleRippleState->getFieldU32 (sfFlags)); + bool bDelete = false; // YYY Could skip this if rippling in reverse. if (saBefore > zero // Sender balance was positive. && saBalance <= zero // Sender is zero or negative. - && is_bit_set ((uFlags = sleRippleState->getFieldU32 (sfFlags)), !bSenderHigh ? lsfLowReserve : lsfHighReserve) // Sender reserve is set. - && !is_bit_set (uFlags, !bSenderHigh ? lsfLowNoRipple : lsfHighNoRipple) + && (uFlags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve)) // Sender reserve is set. + && !(uFlags & (!bSenderHigh ? lsfLowNoRipple : lsfHighNoRipple)) && !sleRippleState->getFieldAmount (!bSenderHigh ? sfLowLimit : sfHighLimit) // Sender trust limit is 0. && !sleRippleState->getFieldU32 (!bSenderHigh ? sfLowQualityIn : sfHighQualityIn) // Sender quality in is 0. && !sleRippleState->getFieldU32 (!bSenderHigh ? sfLowQualityOut : sfHighQualityOut)) // Sender quality out is 0. @@ -1561,7 +1544,7 @@ TER LedgerEntrySet::rippleCredit (const uint160& uSenderID, const uint160& uRece sleRippleState->setFieldU32 (sfFlags, uFlags & (!bSenderHigh ? ~lsfLowReserve : ~lsfHighReserve)); // Clear reserve flag. bDelete = !saBalance // Balance is zero. - && !is_bit_set (uFlags, bSenderHigh ? lsfLowReserve : lsfHighReserve); // Receiver reserve is clear. + && !(uFlags & (bSenderHigh ? lsfLowReserve : lsfHighReserve)); // Receiver reserve is clear. } if (bSenderHigh) @@ -1635,15 +1618,14 @@ TER LedgerEntrySet::rippleSend (const uint160& uSenderID, const uint160& uReceiv TER LedgerEntrySet::accountSend (const uint160& uSenderID, const uint160& uReceiverID, const STAmount& saAmount) { - TER terResult = tesSUCCESS; + TER terResult = tesSUCCESS; assert (saAmount >= zero); if (!saAmount || (uSenderID == uReceiverID)) - { - nothing (); - } - else if (saAmount.isNative ()) + return tesSUCCESS; + + if (saAmount.isNative ()) { // XRP send which does not check reserve and can do pure adjustment. SLE::pointer sleSender = !!uSenderID @@ -1674,7 +1656,7 @@ TER LedgerEntrySet::accountSend (const uint160& uSenderID, const uint160& uRecei { if (sleSender->getFieldAmount (sfBalance) < saAmount) { - terResult = is_bit_set (mParams, tapOPEN_LEDGER) + terResult = (mParams & tapOPEN_LEDGER) ? telFAILED_PROCESSING : tecFAILED_PROCESSING; } @@ -1704,7 +1686,7 @@ TER LedgerEntrySet::accountSend (const uint160& uSenderID, const uint160& uRecei } else { - STAmount saActual; + STAmount saActual; WriteLog (lsTRACE, LedgerEntrySet) << "accountSend: " << RippleAddress::createHumanAccountID (uSenderID) << @@ -1712,7 +1694,7 @@ TER LedgerEntrySet::accountSend (const uint160& uSenderID, const uint160& uRecei " : " << saAmount.getFullText (); - terResult = rippleSend (uSenderID, uReceiverID, saAmount, saActual); + terResult = rippleSend (uSenderID, uReceiverID, saAmount, saActual); } return terResult; diff --git a/src/ripple/module/app/ledger/LedgerMaster.cpp b/src/ripple/module/app/ledger/LedgerMaster.cpp index 97adf499a..e5e421e89 100644 --- a/src/ripple/module/app/ledger/LedgerMaster.cpp +++ b/src/ripple/module/app/ledger/LedgerMaster.cpp @@ -1076,7 +1076,6 @@ public: if (!acq->isDone ()) { - nothing (); } else if (acq->isComplete () && !acq->isFailed ()) { diff --git a/src/ripple/module/app/main/Main.cpp b/src/ripple/module/app/main/Main.cpp index 801c3c0d5..2bb4a2526 100644 --- a/src/ripple/module/app/main/Main.cpp +++ b/src/ripple/module/app/main/Main.cpp @@ -209,21 +209,17 @@ int run (int argc, char** argv) iResult = 2; } - if (iResult) - { - nothing (); - } - else + if (!iResult) { // Parse options, if no error. try { po::store (po::command_line_parser (argc, argv) - .options (desc) // Parse options. - .positional (p) // Remainder as --parameters. - .run (), - vm); - po::notify (vm); // Invoke option notify functions. + .options (desc) // Parse options. + .positional (p) // Remainder as --parameters. + .run (), + vm); + po::notify (vm); // Invoke option notify functions. } catch (...) { @@ -231,11 +227,7 @@ int run (int argc, char** argv) } } - if (iResult) - { - nothing (); - } - else if (vm.count ("help")) + if (!iResult && vm.count ("help")) { iResult = 1; } diff --git a/src/ripple/module/app/misc/NetworkOPs.cpp b/src/ripple/module/app/misc/NetworkOPs.cpp index 7f499101f..7c02f30d4 100644 --- a/src/ripple/module/app/misc/NetworkOPs.cpp +++ b/src/ripple/module/app/misc/NetworkOPs.cpp @@ -806,14 +806,15 @@ Transaction::pointer NetworkOPsImp::submitTransactionSync (Transaction::ref tpTr Serializer s; tpTrans->getSTransaction ()->add (s); - Transaction::pointer tpTransNew = Transaction::sharedTransaction (s.getData (), true); + Transaction::pointer tpTransNew = Transaction::sharedTransaction (s.getData (), true); if (!tpTransNew) { // Could not construct transaction. - nothing (); + return tpTransNew; } - else if (tpTransNew->getSTransaction ()->isEquivalent (*tpTrans->getSTransaction ())) + + if (tpTransNew->getSTransaction ()->isEquivalent (*tpTrans->getSTransaction ())) { if (bSubmit) (void) NetworkOPsImp::processTransaction (tpTransNew, bAdmin, bLocal, bFailHard); @@ -2660,17 +2661,11 @@ void NetworkOPsImp::unsubAccount (std::uint64_t uSeq, ScopedLockType sl (mLock); - BOOST_FOREACH (const RippleAddress & naAccountID, vnaAccountIDs) + for (auto const& naAccountID : vnaAccountIDs) { - SubInfoMapType::iterator simIterator = subMap.find (naAccountID.getAccountID ()); + auto simIterator = subMap.find (naAccountID.getAccountID ()); - - if (simIterator == subMap.end ()) - { - // Not found. Done. - nothing (); - } - else + if (simIterator != subMap.end ()) { // Found simIterator->second.erase (uSeq); diff --git a/src/ripple/module/app/paths/CalcNode.cpp b/src/ripple/module/app/paths/CalcNode.cpp index 179f1f656..2fd64ba27 100644 --- a/src/ripple/module/app/paths/CalcNode.cpp +++ b/src/ripple/module/app/paths/CalcNode.cpp @@ -92,13 +92,12 @@ TER nodeRev ( : nodeOfferRev (rippleCalc, nodeIndex, pathState, bMultiQuality); // Do previous. - if (resultCode != tesSUCCESS) - // Error, don't continue. - nothing (); - else if (nodeIndex) + if (resultCode == tesSUCCESS && nodeIndex) + { // Continue in reverse. TODO(tom): remove unnecessary recursion. resultCode = nodeRev (rippleCalc, nodeIndex - 1, pathState, bMultiQuality); - + } + WriteLog (lsTRACE, RippleCalc) << "nodeRev< " << "nodeIndex=" << nodeIndex diff --git a/src/ripple/module/app/paths/CalcNodeAccountFwd.cpp b/src/ripple/module/app/paths/CalcNodeAccountFwd.cpp index 0e486e8c9..8ee68ce43 100644 --- a/src/ripple/module/app/paths/CalcNodeAccountFwd.cpp +++ b/src/ripple/module/app/paths/CalcNodeAccountFwd.cpp @@ -352,7 +352,6 @@ TER nodeAccountFwd ( // As the issuer, would only issue. // Don't need to actually deliver. As from delivering leave in // the issuer as limbo. - nothing (); } else { diff --git a/src/ripple/module/app/paths/CalcNodeAccountRev.cpp b/src/ripple/module/app/paths/CalcNodeAccountRev.cpp index 7c4310954..0eb06ede5 100644 --- a/src/ripple/module/app/paths/CalcNodeAccountRev.cpp +++ b/src/ripple/module/app/paths/CalcNodeAccountRev.cpp @@ -166,8 +166,6 @@ TER nodeAccountRev ( { // ^ --> ACCOUNT --> account|offer // Nothing to do, there is no previous to adjust. - - nothing (); } else if (previousNodeIsAccount && nextNodeIsAccount) { diff --git a/src/ripple/module/app/paths/CalcNodeDeliverFwd.cpp b/src/ripple/module/app/paths/CalcNodeDeliverFwd.cpp index 0b49c083a..e79072b35 100644 --- a/src/ripple/module/app/paths/CalcNodeDeliverFwd.cpp +++ b/src/ripple/module/app/paths/CalcNodeDeliverFwd.cpp @@ -93,7 +93,6 @@ TER nodeDeliverFwd ( if (resultCode != tesSUCCESS) { - nothing (); } else if (!uOfferIndex) { diff --git a/src/ripple/module/app/paths/Node.cpp b/src/ripple/module/app/paths/Node.cpp index d93e1d8f1..02668b100 100644 --- a/src/ripple/module/app/paths/Node.cpp +++ b/src/ripple/module/app/paths/Node.cpp @@ -37,14 +37,28 @@ Json::Value Node::getJson () const jvNode["type"] = uFlags; - if (isAccount() || !!uAccountID) - jvFlags.append (!isAccount() == !!uAccountID ? "account" : "-account"); + bool const hasCurrency (uCurrencyID != zero); + bool const hasAccount (uAccountID != zero); + bool const hasIssuer (uIssuerID != zero); - if (is_bit_set (uFlags, STPathElement::typeCurrency) || !!uCurrencyID) - jvFlags.append (!!is_bit_set (uFlags, STPathElement::typeCurrency) == !!uCurrencyID ? "currency" : "-currency"); + if (isAccount() || hasAccount) + { + jvFlags.append (!isAccount() == hasAccount ? "account" : "-account"); + } - if (is_bit_set (uFlags, STPathElement::typeIssuer) || !!uIssuerID) - jvFlags.append (!!is_bit_set (uFlags, STPathElement::typeIssuer) == !!uIssuerID ? "issuer" : "-issuer"); + if (uFlags & STPathElement::typeCurrency || hasCurrency) + { + jvFlags.append ((uFlags & STPathElement::typeCurrency) && hasCurrency + ? "currency" + : "-currency"); + } + + if (uFlags & STPathElement::typeIssuer || hasIssuer) + { + jvFlags.append ((uFlags & STPathElement::typeIssuer) && hasIssuer + ? "issuer" + : "-issuer"); + } jvNode["flags"] = jvFlags; diff --git a/src/ripple/module/app/paths/Node.h b/src/ripple/module/app/paths/Node.h index b86b137d1..c6e0dac51 100644 --- a/src/ripple/module/app/paths/Node.h +++ b/src/ripple/module/app/paths/Node.h @@ -29,7 +29,7 @@ struct Node inline bool isAccount() const { - return is_bit_set (uFlags, STPathElement::typeAccount); + return (uFlags & STPathElement::typeAccount); } Json::Value getJson () const; diff --git a/src/ripple/module/app/paths/PathRequest.cpp b/src/ripple/module/app/paths/PathRequest.cpp index 40ac7d5fc..3217283f9 100644 --- a/src/ripple/module/app/paths/PathRequest.cpp +++ b/src/ripple/module/app/paths/PathRequest.cpp @@ -164,12 +164,14 @@ bool PathRequest::isValid (RippleLineCache::ref crCache) } else { - bool includeXRP = !is_bit_set (asDst->peekSLE ().getFlags(), lsfDisallowXRP); - boost::unordered_set usDestCurrID = - usAccountDestCurrencies (raDstAccount, crCache, includeXRP); + bool const disallowXRP ( + asDst->peekSLE ().getFlags() & lsfDisallowXRP); - BOOST_FOREACH (const uint160 & uCurrency, usDestCurrID) - jvDestCur.append (STAmount::createHumanCurrency (uCurrency)); + boost::unordered_set usDestCurrID = + usAccountDestCurrencies (raDstAccount, crCache, !disallowXRP); + + for (auto const& currency : usDestCurrID) + jvDestCur.append (STAmount::createHumanCurrency (currency)); jvStatus["destination_tag"] = (asDst->peekSLE ().getFlags () & lsfRequireDestTag) != 0; } diff --git a/src/ripple/module/app/paths/PathState.cpp b/src/ripple/module/app/paths/PathState.cpp index 3231e4309..02da0c82e 100644 --- a/src/ripple/module/app/paths/PathState.cpp +++ b/src/ripple/module/app/paths/PathState.cpp @@ -140,13 +140,13 @@ TER PathState::pushNode ( auto const& previousNode = bFirst ? path::Node () : nodes_.back (); // true, iff node is a ripple account. false, iff node is an offer node. - const bool bAccount = is_bit_set (iType, STPathElement::typeAccount); + const bool bAccount (iType & STPathElement::typeAccount); // Is currency specified for the output of the current node? - const bool bCurrency = is_bit_set (iType, STPathElement::typeCurrency); + const bool bCurrency (iType & STPathElement::typeCurrency); // Issuer is specified for the output of the current node. - const bool bIssuer = is_bit_set (iType, STPathElement::typeIssuer); + const bool bIssuer (iType & STPathElement::typeIssuer); TER resultCode = tesSUCCESS; @@ -206,8 +206,6 @@ TER PathState::pushNode ( if (bFirst) { // The first node is always correct as is. - - nothing (); } else if (!uAccountID) { @@ -273,8 +271,8 @@ TER PathState::pushNode ( resultCode = terNO_ACCOUNT; } - else if ((is_bit_set (sleBck->getFieldU32 (sfFlags), lsfRequireAuth) - && !is_bit_set (sleRippleState->getFieldU32 (sfFlags), (bHigh ? lsfHighAuth : lsfLowAuth))) + else if (sleBck->getFieldU32 (sfFlags) & lsfRequireAuth + && !(sleRippleState->getFieldU32 (sfFlags) & (bHigh ? lsfHighAuth : lsfLowAuth)) && sleRippleState->getFieldAmount(sfBalance) == zero) // CHECKME { WriteLog (lsWARNING, RippleCalc) << "pushNode: delay: can't receive IOUs from issuer without auth."; @@ -559,10 +557,10 @@ void PathState::checkNoRipple ( terStatus = terNO_LINE; } else if ( - is_bit_set (sleIn->getFieldU32 (sfFlags), - (secondAccount > firstAccount) ? lsfHighNoRipple : lsfLowNoRipple) && - is_bit_set (sleOut->getFieldU32 (sfFlags), - (secondAccount > thirdAccount) ? lsfHighNoRipple : lsfLowNoRipple)) + sleIn->getFieldU32 (sfFlags) & + ((secondAccount > firstAccount) ? lsfHighNoRipple : lsfLowNoRipple) && + sleOut->getFieldU32 (sfFlags) & + ((secondAccount > thirdAccount) ? lsfHighNoRipple : lsfLowNoRipple)) { WriteLog (lsINFO, RippleCalc) << "Path violates noRipple constraint between " << RippleAddress::createHumanAccountID (firstAccount) << ", " << diff --git a/src/ripple/module/app/paths/Pathfinder.cpp b/src/ripple/module/app/paths/Pathfinder.cpp index 145795383..039002362 100644 --- a/src/ripple/module/app/paths/Pathfinder.cpp +++ b/src/ripple/module/app/paths/Pathfinder.cpp @@ -495,16 +495,20 @@ int Pathfinder::getPathsOut (RippleCurrency const& currencyID, const uint160& ac RippleState* rspEntry = (RippleState*) item.get (); if (currencyID != rspEntry->getLimit ().getCurrency ()) - nothing (); + { + } else if (rspEntry->getBalance () <= zero && (!rspEntry->getLimitPeer () || -rspEntry->getBalance () >= rspEntry->getLimitPeer () || (bAuthRequired && !rspEntry->getAuth ()))) - nothing (); + { + } else if (isDstCurrency && (dstAccount == rspEntry->getAccountIDPeer ())) count += 10000; // count a path to the destination extra else if (rspEntry->getNoRipplePeer ()) - nothing (); // This probably isn't a useful path out + { + // This probably isn't a useful path out + } else ++count; } @@ -593,9 +597,12 @@ STPathSet& Pathfinder::getPaths(PathType_t const& type, bool addComplete) bool Pathfinder::isNoRipple (const uint160& setByID, const uint160& setOnID, const uint160& currencyID) { - SLE::pointer sleRipple = mLedger->getSLEi (Ledger::getRippleStateIndex (setByID, setOnID, currencyID)); - return sleRipple && - is_bit_set (sleRipple->getFieldU32 (sfFlags), (setByID > setOnID) ? lsfHighNoRipple : lsfLowNoRipple); + SLE::pointer sleRipple = mLedger->getSLEi ( + Ledger::getRippleStateIndex (setByID, setOnID, currencyID)); + + auto const flag ((setByID > setOnID) ? lsfHighNoRipple : lsfLowNoRipple); + + return sleRipple && (sleRipple->getFieldU32 (sfFlags) & flag); } // Does this path end on an account-to-account link whose last account @@ -608,7 +615,7 @@ bool Pathfinder::isNoRippleOut (const STPath& currentPath) // Last link must be an account STPathElement const& endElement = *(currentPath.end() - 1); - if (!is_bit_set(endElement.getNodeType(), STPathElement::typeAccount)) + if (!(endElement.getNodeType() & STPathElement::typeAccount)) return false; // What account are we leaving? @@ -647,16 +654,16 @@ void Pathfinder::addLink( SLE::pointer sleEnd = mLedger->getSLEi(Ledger::getAccountRootIndex(uEndAccount)); if (sleEnd) { - bool const bRequireAuth = is_bit_set(sleEnd->getFieldU32(sfFlags), lsfRequireAuth); - bool const bIsEndCurrency = (uEndCurrency == mDstAmount.getCurrency()); - bool const bIsNoRippleOut = isNoRippleOut (currentPath); + bool const bRequireAuth (sleEnd->getFieldU32(sfFlags) & lsfRequireAuth); + bool const bIsEndCurrency (uEndCurrency == mDstAmount.getCurrency()); + bool const bIsNoRippleOut (isNoRippleOut (currentPath)); AccountItems& rippleLines (mRLCache->getRippleLines(uEndAccount)); std::vector< std::pair > candidates; candidates.reserve(rippleLines.getItems().size()); - BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems()) + for(auto item : rippleLines.getItems()) { RippleState const& rspEntry = * reinterpret_cast(item.get()); uint160 const& acctID = rspEntry.getAccountIDPeer(); diff --git a/src/ripple/module/app/paths/RippleState.h b/src/ripple/module/app/paths/RippleState.h index fca59a727..d5e146245 100644 --- a/src/ripple/module/app/paths/RippleState.h +++ b/src/ripple/module/app/paths/RippleState.h @@ -59,22 +59,22 @@ public: // True, Provided auth to peer. bool getAuth () const { - return is_bit_set (mFlags, mViewLowest ? lsfLowAuth : lsfHighAuth); + return mFlags & (mViewLowest ? lsfLowAuth : lsfHighAuth); } bool getAuthPeer () const { - return is_bit_set (mFlags, !mViewLowest ? lsfLowAuth : lsfHighAuth); + return mFlags & (!mViewLowest ? lsfLowAuth : lsfHighAuth); } bool getNoRipple () const { - return is_bit_set (mFlags, mViewLowest ? lsfLowNoRipple : lsfHighNoRipple); + return mFlags & (mViewLowest ? lsfLowNoRipple : lsfHighNoRipple); } bool getNoRipplePeer () const { - return is_bit_set (mFlags, !mViewLowest ? lsfLowNoRipple : lsfHighNoRipple); + return mFlags & (!mViewLowest ? lsfLowNoRipple : lsfHighNoRipple); } const STAmount& getBalance () const @@ -95,6 +95,7 @@ public: std::uint32_t getQualityIn () const { return ((std::uint32_t) (mViewLowest ? mLowQualityIn : mHighQualityIn)); + return ((std::uint32_t) (mViewLowest ? mLowQualityIn : mHighQualityIn)); } std::uint32_t getQualityOut () const diff --git a/src/ripple/module/app/peers/UniqueNodeList.cpp b/src/ripple/module/app/peers/UniqueNodeList.cpp index 42ee7b511..db2748e89 100644 --- a/src/ripple/module/app/peers/UniqueNodeList.cpp +++ b/src/ripple/module/app/peers/UniqueNodeList.cpp @@ -811,7 +811,7 @@ private: { if (db->getNull ("PublicKey")) { - nothing (); // We ignore entries we don't have public keys for. + // We ignore entries we don't have public keys for. } else { @@ -1130,11 +1130,7 @@ private: && (mtpScoreNext.is_not_a_date_time () // Timer is not fine. || mtpScoreNext < mtpFetchUpdated + boost::posix_time::seconds (SCORE_DELAY_SECONDS)); - if (!bCanScore) - { - nothing (); - } - else if (bNow || bDirty) + if (bCanScore && (bNow || bDirty)) { // Need to update or set timer. double const secondsFromNow = bNow ? 0 : SCORE_DELAY_SECONDS; diff --git a/src/ripple/module/app/transactors/Change.cpp b/src/ripple/module/app/transactors/Change.cpp index c2db690de..a6e9e1a86 100644 --- a/src/ripple/module/app/transactors/Change.cpp +++ b/src/ripple/module/app/transactors/Change.cpp @@ -80,7 +80,7 @@ TER Change::preCheck () return temBAD_SRC_ACCOUNT; } - if (is_bit_set (mParams, tapOPEN_LEDGER)) + if (mParams & tapOPEN_LEDGER) { m_journal.warning << "Change transaction against open ledger"; return temINVALID; diff --git a/src/ripple/module/app/transactors/CreateOffer.cpp b/src/ripple/module/app/transactors/CreateOffer.cpp index 0991822b3..6865cfc47 100644 --- a/src/ripple/module/app/transactors/CreateOffer.cpp +++ b/src/ripple/module/app/transactors/CreateOffer.cpp @@ -58,12 +58,12 @@ CreateOffer::checkAcceptAsset(core::AssetRef asset) const "delay: can't receive IOUs from non-existent issuer: " << RippleAddress::createHumanAccountID (asset.issuer); - return is_bit_set (mParams, tapRETRY) + return (mParams & tapRETRY) ? terNO_ACCOUNT : tecNO_ISSUER; } - if (is_bit_set (issuerAccount->getFieldU32 (sfFlags), lsfRequireAuth)) + if (issuerAccount->getFieldU32 (sfFlags) & lsfRequireAuth) { SLE::pointer const trustLine (mEngine->entryCache ( ltRIPPLE_STATE, Ledger::getRippleStateIndex ( @@ -71,7 +71,7 @@ CreateOffer::checkAcceptAsset(core::AssetRef asset) const if (!trustLine) { - return is_bit_set (mParams, tapRETRY) + return (mParams & tapRETRY) ? terNO_LINE : tecNO_LINE; } @@ -81,16 +81,15 @@ CreateOffer::checkAcceptAsset(core::AssetRef asset) const // ordering. Determine which entry we need to access. bool const canonical_gt (mTxnAccountID > asset.issuer); - bool const need_auth (is_bit_set ( - trustLine->getFieldU32 (sfFlags), - (canonical_gt ? lsfLowAuth : lsfHighAuth))); + bool const need_auth (trustLine->getFieldU32 (sfFlags) & + (canonical_gt ? lsfLowAuth : lsfHighAuth)); if (need_auth) { if (m_journal.debug) m_journal.debug << "delay: can't receive IOUs from issuer without auth."; - return is_bit_set (mParams, tapRETRY) + return (mParams & tapRETRY) ? terNO_AUTH : tecNO_AUTH; } @@ -107,10 +106,10 @@ CreateOffer::doApply () std::uint32_t const uTxFlags = mTxn.getFlags (); - bool const bPassive = is_bit_set (uTxFlags, tfPassive); - bool const bImmediateOrCancel = is_bit_set (uTxFlags, tfImmediateOrCancel); - bool const bFillOrKill = is_bit_set (uTxFlags, tfFillOrKill); - bool const bSell = is_bit_set (uTxFlags, tfSell); + bool const bPassive (uTxFlags & tfPassive); + bool const bImmediateOrCancel (uTxFlags & tfImmediateOrCancel); + bool const bFillOrKill (uTxFlags & tfFillOrKill); + bool const bSell (uTxFlags & tfSell); STAmount saTakerPays = mTxn.getFieldAmount (sfTakerPays); STAmount saTakerGets = mTxn.getFieldAmount (sfTakerGets); @@ -290,7 +289,7 @@ CreateOffer::doApply () terResult = checkAcceptAsset (core::Asset (uPaysCurrency, uPaysIssuerID)); bool crossed = false; - bool const bOpenLedger = is_bit_set (mParams, tapOPEN_LEDGER); + bool const bOpenLedger (mParams & tapOPEN_LEDGER); if (terResult == tesSUCCESS) { @@ -377,7 +376,6 @@ CreateOffer::doApply () bImmediateOrCancel) // Do not persist. { // Complete as is. - nothing (); } else if (mPriorBalance.getNValue () < accountReserve) { @@ -406,7 +404,6 @@ CreateOffer::doApply () // something. // Consider the offer unfunded. Treat as tesSUCCESS. - nothing (); } } else diff --git a/src/ripple/module/app/transactors/CreateOfferLegacy.cpp b/src/ripple/module/app/transactors/CreateOfferLegacy.cpp index bf0fa8e47..5eab41165 100644 --- a/src/ripple/module/app/transactors/CreateOfferLegacy.cpp +++ b/src/ripple/module/app/transactors/CreateOfferLegacy.cpp @@ -677,10 +677,10 @@ TER CreateOfferLegacy::doApply () "OfferCreate> " << mTxn.getJson (0); std::uint32_t const uTxFlags = mTxn.getFlags (); - bool const bPassive = is_bit_set (uTxFlags, tfPassive); - bool const bImmediateOrCancel = is_bit_set (uTxFlags, tfImmediateOrCancel); - bool const bFillOrKill = is_bit_set (uTxFlags, tfFillOrKill); - bool const bSell = is_bit_set (uTxFlags, tfSell); + bool const bPassive (uTxFlags & tfPassive); + bool const bImmediateOrCancel (uTxFlags & tfImmediateOrCancel); + bool const bFillOrKill (uTxFlags & tfFillOrKill); + bool const bSell (uTxFlags & tfSell); STAmount saTakerPays = mTxn.getFieldAmount (sfTakerPays); STAmount saTakerGets = mTxn.getFieldAmount (sfTakerGets); @@ -852,9 +852,9 @@ TER CreateOfferLegacy::doApply () "delay: can't receive IOUs from non-existent issuer: " << RippleAddress::createHumanAccountID (uPaysIssuerID); - terResult = is_bit_set (mParams, tapRETRY) ? terNO_ACCOUNT : tecNO_ISSUER; + terResult = (mParams & tapRETRY) ? terNO_ACCOUNT : tecNO_ISSUER; } - else if (is_bit_set (sleTakerPays->getFieldU32 (sfFlags), lsfRequireAuth)) + else if (sleTakerPays->getFieldU32 (sfFlags) & lsfRequireAuth) { SLE::pointer sleRippleState (mEngine->entryCache ( ltRIPPLE_STATE, @@ -869,16 +869,16 @@ TER CreateOfferLegacy::doApply () if (!sleRippleState) { - terResult = is_bit_set (mParams, tapRETRY) + terResult = (mParams & tapRETRY) ? terNO_LINE : tecNO_LINE; } - else if (!is_bit_set (sleRippleState->getFieldU32 (sfFlags), (canonical_gt ? lsfLowAuth : lsfHighAuth))) + else if (!(sleRippleState->getFieldU32 (sfFlags) & (canonical_gt ? lsfLowAuth : lsfHighAuth))) { m_journal.debug << "delay: can't receive IOUs from issuer without auth."; - terResult = is_bit_set (mParams, tapRETRY) ? terNO_AUTH : tecNO_AUTH; + terResult = (mParams & tapRETRY) ? terNO_AUTH : tecNO_AUTH; } } } @@ -886,7 +886,7 @@ TER CreateOfferLegacy::doApply () STAmount saPaid; STAmount saGot; bool bUnfunded = false; - const bool bOpenLedger = is_bit_set (mParams, tapOPEN_LEDGER); + const bool bOpenLedger = (mParams & tapOPEN_LEDGER); if ((tesSUCCESS == terResult) && !bExpired) { @@ -958,12 +958,10 @@ TER CreateOfferLegacy::doApply () if (tesSUCCESS != terResult) { // Fail as is. - nothing (); } else if (bExpired) { // nothing to do - nothing (); } else if (saTakerPays < zero || saTakerGets < zero) { @@ -986,7 +984,6 @@ TER CreateOfferLegacy::doApply () || bUnfunded) // Consider unfunded. { // Complete as is. - nothing (); } else if (mPriorBalance.getNValue () < mEngine->getLedger ()->getReserve (sleCreator->getFieldU32 (sfOwnerCount) + 1)) { @@ -1016,7 +1013,6 @@ TER CreateOfferLegacy::doApply () // something. // Consider the offer unfunded. Treat as tesSUCCESS. - nothing (); } } else diff --git a/src/ripple/module/app/transactors/Payment.cpp b/src/ripple/module/app/transactors/Payment.cpp index 62d7c86e4..9c5b7f63d 100644 --- a/src/ripple/module/app/transactors/Payment.cpp +++ b/src/ripple/module/app/transactors/Payment.cpp @@ -25,9 +25,9 @@ TER Payment::doApply () { // Ripple if source or destination is non-native or if there are paths. std::uint32_t const uTxFlags = mTxn.getFlags (); - bool const bPartialPayment = is_bit_set (uTxFlags, tfPartialPayment); - bool const bLimitQuality = is_bit_set (uTxFlags, tfLimitQuality); - bool const bNoRippleDirect = is_bit_set (uTxFlags, tfNoRippleDirect); + bool const bPartialPayment (uTxFlags & tfPartialPayment); + bool const bLimitQuality (uTxFlags & tfLimitQuality); + bool const bNoRippleDirect (uTxFlags & tfNoRippleDirect); bool const bPaths = mTxn.isFieldPresent (sfPaths); bool const bMax = mTxn.isFieldPresent (sfSendMax); uint160 const uDstAccountID = mTxn.getFieldAccount160 (sfDestination); @@ -168,7 +168,7 @@ TER Payment::doApply () // Another transaction could create the account and then this transaction would succeed. return tecNO_DST; } - else if (is_bit_set (mParams, tapOPEN_LEDGER) && bPartialPayment) + else if (mParams & tapOPEN_LEDGER && bPartialPayment) { // You cannot fund an account with a partial payment. // Make retry work smaller, by rejecting this. @@ -238,7 +238,7 @@ TER Payment::doApply () try { - bool const openLedger = is_bit_set (mParams, tapOPEN_LEDGER); + bool const openLedger = (mParams & tapOPEN_LEDGER); bool const tooManyPaths = spsPaths.size () > MaxPathSize; terResult = openLedger && tooManyPaths @@ -257,7 +257,7 @@ TER Payment::doApply () bLimitQuality, bNoRippleDirect, // Always compute for finalizing ledger. false, // Not standalone, delete unfundeds. - is_bit_set (mParams, tapOPEN_LEDGER)); + openLedger); // Not standalone means: If we discover an offer that's unfunded, we // should delete it as soon as we can. diff --git a/src/ripple/module/app/transactors/SetAccount.cpp b/src/ripple/module/app/transactors/SetAccount.cpp index eec0be68b..12455293e 100644 --- a/src/ripple/module/app/transactors/SetAccount.cpp +++ b/src/ripple/module/app/transactors/SetAccount.cpp @@ -53,23 +53,23 @@ TER SetAccount::doApply () return temINVALID_FLAG; } - if (bSetRequireAuth && !is_bit_set (uFlagsIn, lsfRequireAuth)) + if (bSetRequireAuth && !(uFlagsIn & lsfRequireAuth)) { if (!mEngine->view().dirIsEmpty (Ledger::getOwnerDirIndex (mTxnAccountID))) { m_journal.trace << "Retry: Owner directory not empty."; - return is_bit_set(mParams, tapRETRY) ? terOWNERS : tecOWNERS; + return (mParams & tapRETRY) ? terOWNERS : tecOWNERS; } m_journal.trace << "Set RequireAuth."; uFlagsOut |= lsfRequireAuth; } - if (bClearRequireAuth && is_bit_set (uFlagsIn, lsfRequireAuth)) + if (bClearRequireAuth && (uFlagsIn & lsfRequireAuth)) { m_journal.trace << "Clear RequireAuth."; - uFlagsOut &= ~lsfRequireAuth; + uFlagsOut &= ~lsfRequireAuth; } // @@ -82,13 +82,13 @@ TER SetAccount::doApply () return temINVALID_FLAG; } - if (bSetRequireDest && !is_bit_set (uFlagsIn, lsfRequireDestTag)) + if (bSetRequireDest && !(uFlagsIn & lsfRequireDestTag)) { m_journal.trace << "Set lsfRequireDestTag."; uFlagsOut |= lsfRequireDestTag; } - if (bClearRequireDest && is_bit_set (uFlagsIn, lsfRequireDestTag)) + if (bClearRequireDest && (uFlagsIn & lsfRequireDestTag)) { m_journal.trace << "Clear lsfRequireDestTag."; uFlagsOut &= ~lsfRequireDestTag; @@ -104,13 +104,13 @@ TER SetAccount::doApply () return temINVALID_FLAG; } - if (bSetDisallowXRP && !is_bit_set (uFlagsIn, lsfDisallowXRP)) + if (bSetDisallowXRP && !(uFlagsIn & lsfDisallowXRP)) { m_journal.trace << "Set lsfDisallowXRP."; uFlagsOut |= lsfDisallowXRP; } - if (bClearDisallowXRP && is_bit_set (uFlagsIn, lsfDisallowXRP)) + if (bClearDisallowXRP && (uFlagsIn & lsfDisallowXRP)) { m_journal.trace << "Clear lsfDisallowXRP."; uFlagsOut &= ~lsfDisallowXRP; @@ -126,7 +126,7 @@ TER SetAccount::doApply () return temINVALID_FLAG; } - if ((uSetFlag == asfDisableMaster) && !is_bit_set (uFlagsIn, lsfDisableMaster)) + if ((uSetFlag == asfDisableMaster) && !(uFlagsIn & lsfDisableMaster)) { if (!mTxnAccount->isFieldPresent (sfRegularKey)) return tecNO_REGULAR_KEY; @@ -135,7 +135,7 @@ TER SetAccount::doApply () uFlagsOut |= lsfDisableMaster; } - if ((uClearFlag == asfDisableMaster) && is_bit_set (uFlagsIn, lsfDisableMaster)) + if ((uClearFlag == asfDisableMaster) && (uFlagsIn & lsfDisableMaster)) { m_journal.trace << "Clear lsfDisableMaster."; uFlagsOut &= ~lsfDisableMaster; diff --git a/src/ripple/module/app/transactors/SetTrust.cpp b/src/ripple/module/app/transactors/SetTrust.cpp index 2c1da26a8..9aa203f8f 100644 --- a/src/ripple/module/app/transactors/SetTrust.cpp +++ b/src/ripple/module/app/transactors/SetTrust.cpp @@ -54,11 +54,11 @@ TER SetTrust::doApply () return temINVALID_FLAG; } - bool const bSetAuth = is_bit_set (uTxFlags, tfSetfAuth); - bool const bSetNoRipple = is_bit_set (uTxFlags, tfSetNoRipple); - bool const bClearNoRipple = is_bit_set (uTxFlags, tfClearNoRipple); + bool const bSetAuth = (uTxFlags & tfSetfAuth); + bool const bSetNoRipple = (uTxFlags & tfSetNoRipple); + bool const bClearNoRipple = (uTxFlags & tfClearNoRipple); - if (bSetAuth && !is_bit_set (mTxnAccount->getFieldU32 (sfFlags), lsfRequireAuth)) + if (bSetAuth && !(mTxnAccount->getFieldU32 (sfFlags) & lsfRequireAuth)) { m_journal.trace << "Retry: Auth not required."; @@ -235,11 +235,11 @@ TER SetTrust::doApply () if (bSetNoRipple && !bClearNoRipple && (bHigh ? saHighBalance : saLowBalance) >= zero) { - uFlagsOut |= (bHigh ? lsfHighNoRipple : lsfLowNoRipple); + uFlagsOut |= (bHigh ? lsfHighNoRipple : lsfLowNoRipple); } else if (bClearNoRipple && !bSetNoRipple) { - uFlagsOut &= ~(bHigh ? lsfHighNoRipple : lsfLowNoRipple); + uFlagsOut &= ~(bHigh ? lsfHighNoRipple : lsfLowNoRipple); } if (QUALITY_ONE == uLowQualityOut) uLowQualityOut = 0; @@ -248,25 +248,25 @@ TER SetTrust::doApply () bool const bLowReserveSet = uLowQualityIn || uLowQualityOut || - is_bit_set (uFlagsOut, lsfLowNoRipple) || + (uFlagsOut & lsfLowNoRipple) || !!saLowLimit || saLowBalance > zero; bool const bLowReserveClear = !bLowReserveSet; bool const bHighReserveSet = uHighQualityIn || uHighQualityOut || - is_bit_set (uFlagsOut, lsfHighNoRipple) || + (uFlagsOut & lsfHighNoRipple) || !!saHighLimit || saHighBalance > zero; bool const bHighReserveClear = !bHighReserveSet; bool const bDefault = bLowReserveClear && bHighReserveClear; - bool const bLowReserved = is_bit_set (uFlagsIn, lsfLowReserve); - bool const bHighReserved = is_bit_set (uFlagsIn, lsfHighReserve); + bool const bLowReserved = (uFlagsIn & lsfLowReserve); + bool const bHighReserved = (uFlagsIn & lsfHighReserve); bool bReserveIncrease = false; if (bSetAuth) { - uFlagsOut |= (bHigh ? lsfHighAuth : lsfLowAuth); + uFlagsOut |= (bHigh ? lsfHighAuth : lsfLowAuth); } if (bLowReserveSet && !bLowReserved) @@ -274,10 +274,10 @@ TER SetTrust::doApply () // Set reserve for low account. mEngine->view ().ownerCountAdjust (uLowAccountID, 1, sleLowAccount); - uFlagsOut |= lsfLowReserve; + uFlagsOut |= lsfLowReserve; if (!bHigh) - bReserveIncrease = true; + bReserveIncrease = true; } if (bLowReserveClear && bLowReserved) @@ -285,7 +285,7 @@ TER SetTrust::doApply () // Clear reserve for low account. mEngine->view ().ownerCountAdjust (uLowAccountID, -1, sleLowAccount); - uFlagsOut &= ~lsfLowReserve; + uFlagsOut &= ~lsfLowReserve; } if (bHighReserveSet && !bHighReserved) @@ -293,7 +293,7 @@ TER SetTrust::doApply () // Set reserve for high account. mEngine->view ().ownerCountAdjust (uHighAccountID, 1, sleHighAccount); - uFlagsOut |= lsfHighReserve; + uFlagsOut |= lsfHighReserve; if (bHigh) bReserveIncrease = true; @@ -304,7 +304,7 @@ TER SetTrust::doApply () // Clear reserve for high account. mEngine->view ().ownerCountAdjust (uHighAccountID, -1, sleHighAccount); - uFlagsOut &= ~lsfHighReserve; + uFlagsOut &= ~lsfHighReserve; } if (uFlagsIn != uFlagsOut) @@ -314,7 +314,7 @@ TER SetTrust::doApply () { // Delete. - terResult = mEngine->view ().trustDelete (sleRippleState, uLowAccountID, uHighAccountID); + terResult = mEngine->view ().trustDelete (sleRippleState, uLowAccountID, uHighAccountID); } else if (bReserveIncrease && mPriorBalance.getNValue () < uReserveCreate) // Reserve is not scaled by load. @@ -324,26 +324,25 @@ TER SetTrust::doApply () // Another transaction could provide XRP to the account and then // this transaction would succeed. - terResult = tecINSUF_RESERVE_LINE; + terResult = tecINSUF_RESERVE_LINE; } else { mEngine->entryModify (sleRippleState); - m_journal.trace << - "Modify ripple line"; + m_journal.trace << "Modify ripple line"; } } // Line does not exist. - else if (!saLimitAmount // Setting default limit. - && (!bQualityIn || !uQualityIn) // Not setting quality in or setting default quality in. - && (!bQualityOut || !uQualityOut)) // Not setting quality out or setting default quality out. + else if (!saLimitAmount // Setting default limit. + && (!bQualityIn || !uQualityIn) // Not setting quality in or setting default quality in. + && (!bQualityOut || !uQualityOut)) // Not setting quality out or setting default quality out. { m_journal.trace << "Redundant: Setting non-existent ripple line to defaults."; return tecNO_LINE_REDUNDANT; } - else if (mPriorBalance.getNValue () < uReserveCreate) // Reserve is not scaled by load. + else if (mPriorBalance.getNValue () < uReserveCreate) // Reserve is not scaled by load. { m_journal.trace << "Delay transaction: Line does not exist. Insufficent reserve to create line."; diff --git a/src/ripple/module/app/transactors/Transactor.cpp b/src/ripple/module/app/transactors/Transactor.cpp index 16f265b64..47c7a4f6f 100644 --- a/src/ripple/module/app/transactors/Transactor.cpp +++ b/src/ripple/module/app/transactors/Transactor.cpp @@ -84,7 +84,7 @@ Transactor::Transactor ( void Transactor::calculateFee () { mFeeDue = STAmount (mEngine->getLedger ()->scaleFeeLoad ( - calculateBaseFee (), is_bit_set (mParams, tapADMIN))); + calculateBaseFee (), mParams & tapADMIN)); } std::uint64_t Transactor::calculateBaseFee () @@ -100,7 +100,7 @@ TER Transactor::payFee () return temBAD_AMOUNT; // Only check fee is sufficient when the ledger is open. - if (is_bit_set (mParams, tapOPEN_LEDGER) && saPaid < mFeeDue) + if ((mParams & tapOPEN_LEDGER) && saPaid < mFeeDue) { m_journal.trace << "Insufficient fee paid: " << saPaid.getText () << "/" << mFeeDue.getText (); @@ -139,12 +139,11 @@ TER Transactor::checkSig () // Authorized to continue. mSigMaster = true; if (mTxnAccount->isFlag(lsfDisableMaster)) - return tefMASTER_DISABLED; + return tefMASTER_DISABLED; } else if (mHasAuthKey && mSigningPubKey.getAccountID () == mTxnAccount->getFieldAccount160 (sfRegularKey)) { // Authorized to continue. - nothing (); } else if (mHasAuthKey) { @@ -232,7 +231,8 @@ TER Transactor::preCheck () // Consistency: really signed. if (!mTxn.isKnownGood ()) { - if (mTxn.isKnownBad () || (!is_bit_set (mParams, tapNO_CHECK_SIGN) && !mTxn.checkSign (mSigningPubKey))) + if (mTxn.isKnownBad () || + (!(mParams & tapNO_CHECK_SIGN) && !mTxn.checkSign (mSigningPubKey))) { mTxn.setBad (); m_journal.warning << "apply: Invalid transaction (bad signature)"; diff --git a/src/ripple/module/app/tx/TransactionEngine.cpp b/src/ripple/module/app/tx/TransactionEngine.cpp index af362655a..57a59bafd 100644 --- a/src/ripple/module/app/tx/TransactionEngine.cpp +++ b/src/ripple/module/app/tx/TransactionEngine.cpp @@ -127,7 +127,7 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans if (isTesSuccess (terResult)) didApply = true; - else if (isTecClaim (terResult) && !is_bit_set (params, tapRETRY)) + else if (isTecClaim (terResult) && !(params & tapRETRY)) { // only claim the transaction fee WriteLog (lsDEBUG, TransactionEngine) << "Reprocessing to only claim fee"; @@ -188,7 +188,7 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans Serializer s; txn.add (s); - if (is_bit_set (params, tapOPEN_LEDGER)) + if (params & tapOPEN_LEDGER) { if (!mLedger->addTransaction (txID, s)) { @@ -216,7 +216,7 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans mTxnAccount.reset (); mNodes.clear (); - if (!is_bit_set (params, tapOPEN_LEDGER) && isTemMalformed (terResult)) + if (!(params & tapOPEN_LEDGER) && isTemMalformed (terResult)) { // XXX Malformed or failed transaction in closed ledger must bow out. } diff --git a/src/ripple/module/core/functional/Config.cpp b/src/ripple/module/core/functional/Config.cpp index bbcc131c9..bf36e6142 100644 --- a/src/ripple/module/core/functional/Config.cpp +++ b/src/ripple/module/core/functional/Config.cpp @@ -198,7 +198,6 @@ void Config::setup (const std::string& strConf, bool bQuiet) || (!getenv ("HOME") && (!getenv ("XDG_CONFIG_HOME") || !getenv ("XDG_DATA_HOME")))) { // Current working directory is fine, put dbs in a subdir. - nothing (); } else { diff --git a/src/ripple/module/data/protocol/RippleAddress.cpp b/src/ripple/module/data/protocol/RippleAddress.cpp index b893568de..e5b82c72b 100644 --- a/src/ripple/module/data/protocol/RippleAddress.cpp +++ b/src/ripple/module/data/protocol/RippleAddress.cpp @@ -597,7 +597,6 @@ Blob RippleAddress::accountPrivateEncrypt (const RippleAddress& naPublicTo, Blob } catch (...) { - nothing (); } } @@ -628,7 +627,6 @@ Blob RippleAddress::accountPrivateDecrypt (const RippleAddress& naPublicFrom, Bl } catch (...) { - nothing (); } } @@ -802,12 +800,10 @@ bool RippleAddress::setSeedGeneric (const std::string& strText) else if (setSeed (strText)) { // Log::out() << "Recognized seed."; - nothing (); } else if (1 == setSeed1751 (strText)) { // Log::out() << "Recognized 1751 seed."; - nothing (); } else { diff --git a/src/ripple/module/net/basics/HTTPClient.cpp b/src/ripple/module/net/basics/HTTPClient.cpp index 6897da4f9..6321bcb2b 100644 --- a/src/ripple/module/net/basics/HTTPClient.cpp +++ b/src/ripple/module/net/basics/HTTPClient.cpp @@ -207,7 +207,7 @@ public: // Timer canceled because deadline no longer needed. WriteLog (lsTRACE, HTTPClient) << "Deadline cancelled."; - nothing (); // Aborter is done. + // Aborter is done. } else if (ecResult) { @@ -441,8 +441,6 @@ public: if (mShutdown) { WriteLog (lsTRACE, HTTPClient) << "Complete."; - - nothing (); } else { diff --git a/src/ripple/module/net/basics/SNTPClient.cpp b/src/ripple/module/net/basics/SNTPClient.cpp index ddad789f0..cf79b1bd7 100644 --- a/src/ripple/module/net/basics/SNTPClient.cpp +++ b/src/ripple/module/net/basics/SNTPClient.cpp @@ -152,7 +152,8 @@ public: void queryAll () { while (doQuery ()) - nothing (); + { + } } bool getOffset (int& offset) diff --git a/src/ripple/module/net/rpc/RPCCall.cpp b/src/ripple/module/net/rpc/RPCCall.cpp index e956fc488..ae26f0817 100644 --- a/src/ripple/module/net/rpc/RPCCall.cpp +++ b/src/ripple/module/net/rpc/RPCCall.cpp @@ -166,7 +166,6 @@ private: if (1 == iParams) { - nothing (); } else if (2 == iParams) { @@ -235,7 +234,6 @@ private: if (1 == iParams) { - nothing (); } else if (2 == iParams) { diff --git a/src/ripple/module/overlay/impl/PeerImp.h b/src/ripple/module/overlay/impl/PeerImp.h index b41874a90..e540e00b1 100644 --- a/src/ripple/module/overlay/impl/PeerImp.h +++ b/src/ripple/module/overlay/impl/PeerImp.h @@ -1516,13 +1516,13 @@ private: if (! getApp().getHashRouter ().addSuppressionPeer (txID, m_shortId, flags)) { // we have seen this transaction recently - if (is_bit_set (flags, SF_BAD)) + if (flags & SF_BAD) { charge (Resource::feeInvalidSignature); return; } - if (!is_bit_set (flags, SF_RETRY)) + if (!(flags & SF_RETRY)) return; } @@ -2635,7 +2635,7 @@ private: return; } - bool needCheck = ! is_bit_set (flags, SF_SIGGOOD); + bool const needCheck = !(flags & SF_SIGGOOD); Transaction::pointer tx = std::make_shared (stx, needCheck); @@ -2648,7 +2648,8 @@ private: else getApp().getHashRouter ().setFlag (stx->getTransactionID (), SF_SIGGOOD); - getApp().getOPs ().processTransaction (tx, is_bit_set (flags, SF_TRUSTED), false, false); + bool const trusted (flags & SF_TRUSTED); + getApp().getOPs ().processTransaction (tx, trusted, false, false); #ifndef TRUST_NETWORK } diff --git a/src/ripple/module/rpc/handlers/Subscribe.cpp b/src/ripple/module/rpc/handlers/Subscribe.cpp index 1a7addd03..88ce399a6 100644 --- a/src/ripple/module/rpc/handlers/Subscribe.cpp +++ b/src/ripple/module/rpc/handlers/Subscribe.cpp @@ -85,7 +85,6 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT if (!params.isMember ("streams")) { - nothing (); } else if (!params["streams"].isArray ()) { @@ -136,7 +135,6 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT if (!params.isMember (strAccountsProposed)) { - nothing (); } else if (!params[strAccountsProposed].isArray ()) { @@ -158,8 +156,6 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT if (!params.isMember ("accounts")) { - nothing (); - } else if (!params["accounts"].isArray ()) { @@ -184,7 +180,6 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT bool bHaveMasterLock = true; if (!params.isMember ("books")) { - nothing (); } else if (!params["books"].isArray ()) { diff --git a/src/ripple/module/rpc/handlers/Unsubscribe.cpp b/src/ripple/module/rpc/handlers/Unsubscribe.cpp index ef4d24c58..05f6ae569 100644 --- a/src/ripple/module/rpc/handlers/Unsubscribe.cpp +++ b/src/ripple/module/rpc/handlers/Unsubscribe.cpp @@ -119,7 +119,6 @@ Json::Value RPCHandler::doUnsubscribe (Json::Value params, Resource::Charge& loa if (!params.isMember ("books")) { - nothing (); } else if (!params["books"].isArray ()) { diff --git a/src/ripple/module/rpc/impl/AccountFromString.cpp b/src/ripple/module/rpc/impl/AccountFromString.cpp index 922a39328..97f186c85 100644 --- a/src/ripple/module/rpc/impl/AccountFromString.cpp +++ b/src/ripple/module/rpc/impl/AccountFromString.cpp @@ -65,7 +65,6 @@ Json::Value accountFromString (Ledger::ref lrLedger, RippleAddress& naAccount, if (!sleGen) { // Didn't find a generator map, assume it is a master generator. - nothing (); } else {