diff --git a/src/ripple_app/consensus/LedgerConsensus.cpp b/src/ripple_app/consensus/LedgerConsensus.cpp index e6b91921c2..6d994e2547 100644 --- a/src/ripple_app/consensus/LedgerConsensus.cpp +++ b/src/ripple_app/consensus/LedgerConsensus.cpp @@ -51,33 +51,33 @@ public: , mCurrentMSeconds (0) , mClosePercent (0) , mHaveCloseTimeConsensus (false) - , mConsensusStartTime + , mConsensusStartTime (boost::posix_time::microsec_clock::universal_time ()) { WriteLog (lsDEBUG, LedgerConsensus) << "Creating consensus object"; - WriteLog (lsTRACE, LedgerConsensus) + WriteLog (lsTRACE, LedgerConsensus) << "LCL:" << previousLedger->getHash () << ", ct=" << closeTime; mPreviousProposers = getApp().getOPs ().getPreviousProposers (); mPreviousMSeconds = getApp().getOPs ().getPreviousConvergeTime (); assert (mPreviousMSeconds); mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution ( - mPreviousLedger->getCloseResolution (), - mPreviousLedger->getCloseAgree (), + mPreviousLedger->getCloseResolution (), + mPreviousLedger->getCloseAgree (), previousLedger->getLedgerSeq () + 1); - if (mValPublic.isSet () && mValPrivate.isSet () + if (mValPublic.isSet () && mValPrivate.isSet () && !getApp().getOPs ().isNeedNetworkLedger ()) { - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Entering consensus process, validating"; mValidating = true; - mProposing = + mProposing = getApp().getOPs ().getOperatingMode () == NetworkOPs::omFULL; } else { - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Entering consensus process, watching"; mProposing = mValidating = false; } @@ -92,10 +92,10 @@ public: if (!mHaveCorrectLCL) { // mProposing = mValidating = false; - WriteLog (lsINFO, LedgerConsensus) - << "Entering consensus with: " + WriteLog (lsINFO, LedgerConsensus) + << "Entering consensus with: " << previousLedger->getHash (); - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Correct LCL is: " << prevLCLHash; } } @@ -239,26 +239,25 @@ public: return mPrevLedgerHash; } - /** Get a transaction tree, + /** Get a transaction tree, fetching it from the network is required and requested */ SHAMap::pointer getTransactionTree (uint256 const& hash, bool doAcquire) { - ripple::unordered_map::iterator it - = mAcquired.find (hash); + auto it = mAcquired.find (hash); if (it != mAcquired.end ()) return it->second; if (mState == lcsPRE_CLOSE) { - SHAMap::pointer currentMap + SHAMap::pointer currentMap = getApp().getLedgerMaster ().getCurrentLedger () ->peekTransactionMap (); if (currentMap->getHash () == hash) { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Map " << hash << " is our current"; currentMap = currentMap->snapShot (false); mapComplete (hash, currentMap, false); @@ -292,7 +291,7 @@ public: */ void mapComplete (uint256 const& hash, SHAMap::ref map, bool acquired) { - CondLog (acquired, lsINFO, LedgerConsensus) + CondLog (acquired, lsINFO, LedgerConsensus) << "We have acquired TXS " << hash; if (!map) @@ -300,15 +299,14 @@ public: // this is an invalid/corrupt map mAcquired[hash] = map; mAcquiring.erase (hash); - WriteLog (lsWARNING, LedgerConsensus) + WriteLog (lsWARNING, LedgerConsensus) << "A trusted node directed us to acquire an invalid TXN map"; return; } assert (hash == map->getHash ()); - ripple::unordered_map::iterator it - = mAcquired.find (hash); + auto it = mAcquired.find (hash); if (mAcquired.find (hash) != mAcquired.end ()) { @@ -322,16 +320,15 @@ public: mAcquired.erase (hash); } - if (mOurPosition && (!mOurPosition->isBowOut ()) + if (mOurPosition && (!mOurPosition->isBowOut ()) && (hash != mOurPosition->getCurrentHash ())) { // this could create disputed transactions - ripple::unordered_map::iterator it2 - = mAcquired.find (mOurPosition->getCurrentHash ()); + auto it2 = mAcquired.find (mOurPosition->getCurrentHash ()); if (it2 != mAcquired.end ()) { - assert ((it2->first == mOurPosition->getCurrentHash ()) + assert ((it2->first == mOurPosition->getCurrentHash ()) && it2->second); mCompares.insert(hash); createDisputes (it2->second, map); @@ -340,7 +337,7 @@ public: assert (false); // We don't have our own position?! } else - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Not ready to create disputes"; mAcquired[hash] = map; @@ -348,7 +345,7 @@ public: // Adjust tracking for each peer that takes this position std::vector peers; - BOOST_FOREACH (u160_prop_pair & it, mPeerPositions) + for (auto& it : mPeerPositions) { if (it.second->getCurrentHash () == map->getHash ()) peers.push_back (it.second->getPeerID ()); @@ -360,8 +357,8 @@ public: } else { - CondLog (acquired, lsWARNING, LedgerConsensus) - << "By the time we got the map " + CondLog (acquired, lsWARNING, LedgerConsensus) + << "By the time we got the map " << hash << " no peers were proposing it"; } @@ -378,7 +375,7 @@ public: if (mAcquired.find (hash) != mAcquired.end ()) return false; - BOOST_FOREACH (u160_prop_pair & it, mPeerPositions) + for (auto const& it : mPeerPositions) { if (it.second->getCurrentHash () == hash) return true; @@ -400,13 +397,10 @@ public: priorLedger = mPreviousLedger->getParentHash (); // don't jump back ripple::unordered_map vals = - getApp().getValidations ().getCurrentValidations + getApp().getValidations ().getCurrentValidations (favoredLedger, priorLedger); - typedef std::map::value_type u256_cvc_pair; - - BOOST_FOREACH (u256_cvc_pair & it, vals) + for (auto& it : vals) { if ((it.second.first > netLgrCount) || ((it.second.first == netLgrCount) && (it.first == mPrevLedgerHash))) @@ -443,21 +437,23 @@ public: status = "unknown"; } - WriteLog (lsWARNING, LedgerConsensus) - << "View of consensus changed during " << status + WriteLog (lsWARNING, LedgerConsensus) + << "View of consensus changed during " << status << " (" << netLgrCount << ") status=" - << status << ", " + << status << ", " << (mHaveCorrectLCL ? "CorrectLCL" : "IncorrectLCL"); - WriteLog (lsWARNING, LedgerConsensus) << mPrevLedgerHash + WriteLog (lsWARNING, LedgerConsensus) << mPrevLedgerHash << " to " << netLgr; - WriteLog (lsWARNING, LedgerConsensus) + WriteLog (lsWARNING, LedgerConsensus) << mPreviousLedger->getJson (0); if (ShouldLog (lsDEBUG, LedgerConsensus)) { - BOOST_FOREACH (u256_cvc_pair & it, vals) - WriteLog (lsDEBUG, LedgerConsensus) - << "V: " << it.first << ", " << it.second.first; + for (auto& it : vals) + { + WriteLog (lsDEBUG, LedgerConsensus) + << "V: " << it.first << ", " << it.second.first; + } } if (mHaveCorrectLCL) @@ -541,7 +537,7 @@ public: checkLCL (); mCurrentMSeconds = - (boost::posix_time::microsec_clock::universal_time () + (boost::posix_time::microsec_clock::universal_time () - mConsensusStartTime).total_milliseconds (); mClosePercent = mCurrentMSeconds * 100 / mPreviousMSeconds; @@ -577,11 +573,11 @@ public: void statePreClose () { // it is shortly before ledger close time - bool anyTransactions + bool anyTransactions = getApp().getLedgerMaster ().getCurrentLedger () ->peekTransactionMap ()->getHash ().isNonZero (); int proposersClosed = mPeerPositions.size (); - int proposersValidated + int proposersValidated = getApp().getValidations ().getTrustedValidationCount (mPrevLedgerHash); @@ -592,7 +588,7 @@ public: if (mHaveCorrectLCL && mPreviousLedger->getCloseAgree ()) { // we can use consensus timing - sinceClose = 1000 * (getApp().getOPs ().getCloseTimeNC () + sinceClose = 1000 * (getApp().getOPs ().getCloseTimeNC () - mPreviousLedger->getCloseTimeNC ()); idleInterval = 2 * mPreviousLedger->getCloseResolution (); @@ -601,7 +597,7 @@ public: } else { - sinceClose = 1000 * (getApp().getOPs ().getCloseTimeNC () + sinceClose = 1000 * (getApp().getOPs ().getCloseTimeNC () - getApp().getOPs ().getLastCloseTime ()); idleInterval = LEDGER_IDLE_INTERVAL; } @@ -630,13 +626,13 @@ public: if (!mHaveCloseTimeConsensus) { - CondLog (haveConsensus (false), lsINFO, LedgerConsensus) + CondLog (haveConsensus (false), lsINFO, LedgerConsensus) << "We have TX consensus but not CT consensus"; } else if (haveConsensus (true)) { - WriteLog (lsINFO, LedgerConsensus) - << "Converge cutoff (" << mPeerPositions.size () + WriteLog (lsINFO, LedgerConsensus) + << "Converge cutoff (" << mPeerPositions.size () << " participants)"; mState = lcsFINISHED; beginAccept (false); @@ -679,13 +675,10 @@ public: if (mCompares.count(it.second->getCurrentHash()) == 0) { // Make sure we have generated disputes uint256 hash = it.second->getCurrentHash(); - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "We have not compared to " << hash; - ripple::unordered_map::iterator - it1 = mAcquired.find (hash); - ripple::unordered_map::iterator - it2 = mAcquired.find - (mOurPosition->getCurrentHash ()); + auto it1 = mAcquired.find (hash); + auto it2 = mAcquired.find(mOurPosition->getCurrentHash ()); if ((it1 != mAcquired.end()) && (it2 != mAcquired.end()) && (it1->second) && (it2->second)) { @@ -699,11 +692,11 @@ public: int currentValidations = getApp().getValidations () .getNodesAfter (mPrevLedgerHash); - WriteLog (lsDEBUG, LedgerConsensus) - << "Checking for TX consensus: agree=" << agree + WriteLog (lsDEBUG, LedgerConsensus) + << "Checking for TX consensus: agree=" << agree << ", disagree=" << disagree; - return ContinuousLedgerTiming::haveConsensus (mPreviousProposers, + return ContinuousLedgerTiming::haveConsensus (mPreviousProposers, agree + disagree, agree, currentValidations , mPreviousMSeconds, mCurrentMSeconds, forReal, mConsensusFail); } @@ -716,7 +709,7 @@ public: if (mDeadNodes.find (peerID) != mDeadNodes.end ()) { - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Position from dead node: " << to_string (peerID); return false; } @@ -727,7 +720,7 @@ public: { assert (peerID == currentPosition->getPeerID ()); - if (newPosition->getProposeSeq () + if (newPosition->getProposeSeq () <= currentPosition->getProposeSeq ()) { return false; @@ -737,15 +730,15 @@ public: if (newPosition->getProposeSeq () == 0) { // new initial close time estimate - WriteLog (lsTRACE, LedgerConsensus) - << "Peer reports close time as " + WriteLog (lsTRACE, LedgerConsensus) + << "Peer reports close time as " << newPosition->getCloseTime (); ++mCloseTimes[newPosition->getCloseTime ()]; } else if (newPosition->getProposeSeq () == LedgerProposal::seqLeave) { // peer bows out - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Peer bows out: " << to_string (peerID); for (auto& it : mDisputes) it.second->unVote (peerID); @@ -756,11 +749,11 @@ public: WriteLog (lsTRACE, LedgerConsensus) << "Processing peer proposal " - << newPosition->getProposeSeq () << "/" + << newPosition->getProposeSeq () << "/" << newPosition->getCurrentHash (); currentPosition = newPosition; - SHAMap::pointer set + SHAMap::pointer set = getTransactionTree (newPosition->getCurrentHash (), true); if (set) @@ -770,7 +763,7 @@ public: } else { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Don't have tx set for peer"; // BOOST_FOREACH(u256_lct_pair& it, mDisputes) // it.second->unVote(peerID); @@ -788,14 +781,12 @@ public: return true; std::vector< boost::weak_ptr >& set = mPeerData[hashSet]; - BOOST_FOREACH (boost::weak_ptr& iit, set) + for (boost::weak_ptr& iit : set) if (iit.lock () == peer) return false; set.push_back (peer); - ripple::unordered_map::iterator acq - = mAcquiring.find (hashSet); + auto acq (mAcquiring.find (hashSet)); if (acq != mAcquiring.end ()) getApp().getJobQueue().addJob(jtTXN_DATA, "peerHasTxnData", @@ -810,18 +801,16 @@ public: , uint256 const& setHash, const std::list& nodeIDs , const std::list< Blob >& nodeData) { - ripple::unordered_map::iterator acq - = mAcquiring.find (setHash); + auto acq (mAcquiring.find (setHash)); if (acq == mAcquiring.end ()) { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Got TX data for set no longer acquiring: " << setHash; return SHAMapAddNode (); } // We must keep the set around during the function - TransactionAcquire::pointer set = acq->second; + TransactionAcquire::pointer set = acq->second; return set->takeNodes (nodeIDs, nodeData, peer); } @@ -848,7 +837,7 @@ private: { { - Application::ScopedLockType lock + Application::ScopedLockType lock (getApp ().getMasterLock ()); // put our set where others can get it later @@ -858,7 +847,7 @@ private: assert (set->getHash () == mOurPosition->getCurrentHash ()); // these are now obsolete - getApp().getOPs ().peekStoredProposals ().clear (); + getApp().getOPs ().peekStoredProposals ().clear (); std::uint32_t closeTime = roundCloseTime (mOurPosition->getCloseTime ()); bool closeTimeCorrect = true; @@ -870,29 +859,29 @@ private: closeTime = mPreviousLedger->getCloseTimeNC () + 1; } - WriteLog (lsDEBUG, LedgerConsensus) - << "Report: Prop=" << (mProposing ? "yes" : "no") - << " val=" << (mValidating ? "yes" : "no") - << " corLCL=" << (mHaveCorrectLCL ? "yes" : "no") + WriteLog (lsDEBUG, LedgerConsensus) + << "Report: Prop=" << (mProposing ? "yes" : "no") + << " val=" << (mValidating ? "yes" : "no") + << " corLCL=" << (mHaveCorrectLCL ? "yes" : "no") << " fail=" << (mConsensusFail ? "yes" : "no"); - WriteLog (lsDEBUG, LedgerConsensus) - << "Report: Prev = " << mPrevLedgerHash + WriteLog (lsDEBUG, LedgerConsensus) + << "Report: Prev = " << mPrevLedgerHash << ":" << mPreviousLedger->getLedgerSeq (); - WriteLog (lsDEBUG, LedgerConsensus) - << "Report: TxSt = " << set->getHash () + WriteLog (lsDEBUG, LedgerConsensus) + << "Report: TxSt = " << set->getHash () << ", close " << closeTime << (closeTimeCorrect ? "" : "X"); CanonicalTXSet failedTransactions (set->getHash ()); - Ledger::pointer newLCL + Ledger::pointer newLCL = boost::make_shared (false , boost::ref (*mPreviousLedger)); - // Set up to write SHAMap changes to our database, + // Set up to write SHAMap changes to our database, // perform updates, extract changes newLCL->peekTransactionMap ()->armDirty (); newLCL->peekAccountStateMap ()->armDirty (); - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Applying consensus set transactions to the" << " last closed ledger"; applyTransactions (set, newLCL, newLCL, failedTransactions, false); @@ -909,14 +898,14 @@ private: while ((fc = newLCL->peekAccountStateMap()->flushDirty ( *acctNodes, 256, hotACCOUNT_NODE, newLCL->getLedgerSeq ())) > 0) { - WriteLog (lsTRACE, LedgerConsensus) + WriteLog (lsTRACE, LedgerConsensus) << "Flushed " << fc << " dirty state nodes"; } while ((fc = newLCL->peekTransactionMap()->flushDirty ( *txnNodes, 256, hotTRANSACTION_NODE, newLCL->getLedgerSeq ())) > 0) { - WriteLog (lsTRACE, LedgerConsensus) + WriteLog (lsTRACE, LedgerConsensus) << "Flushed " << fc << " dirty transaction nodes"; } @@ -932,8 +921,8 @@ private: WriteLog (lsDEBUG, LedgerConsensus) << "Consensus built new ledger"; - WriteLog (lsDEBUG, LedgerConsensus) - << "Report: NewL = " << newLCL->getHash () + WriteLog (lsDEBUG, LedgerConsensus) + << "Report: NewL = " << newLCL->getHash () << ":" << newLCL->getLedgerSeq (); uint256 newLCLHash = newLCL->getHash (); @@ -942,7 +931,7 @@ private: if (mValidating && !mConsensusFail) { uint256 signingHash; - SerializedValidation::pointer v = + SerializedValidation::pointer v = boost::make_shared (newLCLHash, getApp().getOPs ().getValidationTimeNC () , mValPublic, mProposing); @@ -950,7 +939,7 @@ private: addLoad(v); if (((newLCL->getLedgerSeq () + 1) % 256) == 0) - // next ledger is flag ledger + // next ledger is flag ledger { m_feeVote.doValidation (newLCL, *v); getApp().getAmendmentTable ().doValidation (newLCL, *v); @@ -968,36 +957,36 @@ private: getApp ().overlay ().foreach (send_always ( boost::make_shared ( val, protocol::mtVALIDATION))); - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "CNF Val " << newLCLHash; } else - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "CNF newLCL " << newLCLHash; // See if we can accept a ledger as fully-validated getApp().getLedgerMaster().consensusBuilt (newLCL); - Ledger::pointer newOL = boost::make_shared + Ledger::pointer newOL = boost::make_shared (true, boost::ref (*newLCL)); - LedgerMaster::ScopedLockType sl + LedgerMaster::ScopedLockType sl (getApp().getLedgerMaster ().peekMutex ()); // Apply disputed transactions that didn't get in TransactionEngine engine (newOL); - BOOST_FOREACH (u256_lct_pair & it, mDisputes) + for (auto& it : mDisputes) { if (!it.second->getOurVote ()) { // we voted NO try { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Test applying disputed transaction that did" << " not get in"; SerializerIterator sit (it.second->peekTransaction ()); - SerializedTransaction::pointer txn - = boost::make_shared + SerializedTransaction::pointer txn + = boost::make_shared (boost::ref (sit)); if (applyTransaction (engine, txn, newOL, true, false)) @@ -1007,13 +996,13 @@ private: } catch (...) { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Failed to apply transaction we voted NO on"; } } } - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Applying transactions from current open ledger"; applyTransactions (getApp().getLedgerMaster ().getCurrentLedger ()->peekTransactionMap (), newOL, newLCL, @@ -1033,31 +1022,31 @@ private: { // see how close our close time is to other node's // close time reports - WriteLog (lsINFO, LedgerConsensus) - << "We closed at " + WriteLog (lsINFO, LedgerConsensus) + << "We closed at " << beast::lexicalCastThrow (mCloseTime); std::uint64_t closeTotal = mCloseTime; int closeCount = 1; - for (std::map::iterator it = mCloseTimes.begin () + for (auto it = mCloseTimes.begin () , end = mCloseTimes.end (); it != end; ++it) { // FIXME: Use median, not average - WriteLog (lsINFO, LedgerConsensus) - << beast::lexicalCastThrow (it->second) - << " time votes for " + WriteLog (lsINFO, LedgerConsensus) + << beast::lexicalCastThrow (it->second) + << " time votes for " << beast::lexicalCastThrow (it->first); closeCount += it->second; - closeTotal += static_cast + closeTotal += static_cast (it->first) * static_cast (it->second); } closeTotal += (closeCount / 2); closeTotal /= closeCount; - int offset = static_cast (closeTotal) + int offset = static_cast (closeTotal) - static_cast (mCloseTime); - WriteLog (lsINFO, LedgerConsensus) - << "Our close offset is estimated at " + WriteLog (lsINFO, LedgerConsensus) + << "Our close offset is estimated at " << offset << " (" << closeCount << ")"; getApp().getOPs ().closeTimeOffset (offset); } @@ -1068,15 +1057,13 @@ private: */ void startAcquiring (TransactionAcquire::pointer acquire) { - ripple::unordered_map< uint256, - std::vector< boost::weak_ptr > >::iterator it = - mPeerData.find (acquire->getHash ()); + auto it = mPeerData.find (acquire->getHash ()); if (it != mPeerData.end ()) { // Add any peers we already know have his transaction set std::vector< boost::weak_ptr >& peerList = it->second; - std::vector< boost::weak_ptr >::iterator pit + std::vector< boost::weak_ptr >::iterator pit = peerList.begin (); while (pit != peerList.end ()) @@ -1128,15 +1115,13 @@ private: if (m1->getHash() == m2->getHash()) return; - WriteLog (lsDEBUG, LedgerConsensus) << "createDisputes " + WriteLog (lsDEBUG, LedgerConsensus) << "createDisputes " << m1->getHash() << " to " << m2->getHash(); SHAMap::Delta differences; m1->compare (m2, differences, 16384); int dc = 0; - typedef std::map::value_type u256_diff_pair; - BOOST_FOREACH (u256_diff_pair & pos, differences) + for (auto& pos : differences) { ++dc; // create disputed transactions (from the ledger that has them) @@ -1160,7 +1145,7 @@ private: WriteLog (lsDEBUG, LedgerConsensus) << dc << " differences found"; } - /** Add a disputed transaction (one that at least one node wants + /** Add a disputed transaction (one that at least one node wants in the consensus set and at least one node does not) to our tracking */ void addDisputedTransaction (uint256 const& txID, Blob const& tx) @@ -1168,15 +1153,14 @@ private: if (mDisputes.find (txID) != mDisputes.end ()) return; - WriteLog (lsDEBUG, LedgerConsensus) << "Transaction " + WriteLog (lsDEBUG, LedgerConsensus) << "Transaction " << txID << " is disputed"; bool ourVote = false; if (mOurPosition) { - ripple::unordered_map::iterator mit - = mAcquired.find (mOurPosition->getCurrentHash ()); + auto mit (mAcquired.find (mOurPosition->getCurrentHash ())); if (mit != mAcquired.end ()) ourVote = mit->second->hasItem (txID); @@ -1184,14 +1168,13 @@ private: assert (false); // We don't have our own position? } - DisputedTx::pointer txn = boost::make_shared + DisputedTx::pointer txn = boost::make_shared (txID, tx, ourVote); mDisputes[txID] = txn; - BOOST_FOREACH (u160_prop_pair & pit, mPeerPositions) + for (auto& pit : mPeerPositions) { - ripple::unordered_map::const_iterator cit - = mAcquired.find (pit.second->getCurrentHash ()); + auto cit (mAcquired.find (pit.second->getCurrentHash ())); if ((cit != mAcquired.end ()) && cit->second) { @@ -1212,26 +1195,26 @@ private: } } - /** Adjust the counts on all disputed transactions based + /** Adjust the counts on all disputed transactions based on the set of peers taking this position */ void adjustCount (SHAMap::ref map, const std::vector& peers) { - BOOST_FOREACH (u256_lct_pair & it, mDisputes) + for (auto& it : mDisputes) { bool setHas = map->hasItem (it.second->getTransactionID ()); - BOOST_FOREACH (const uint160 & pit, peers) + for (auto const& pit : peers) it.second->setVote (pit, setHas); } } - + /** Make and send a proposal */ void propose () { WriteLog (lsTRACE, LedgerConsensus) << "We propose: " << - (mOurPosition->isBowOut () - ? std::string ("bowOut") + (mOurPosition->isBowOut () + ? std::string ("bowOut") : to_string (mOurPosition->getCurrentHash ())); protocol::TMProposeSet prop; @@ -1261,22 +1244,22 @@ private: msg.set_status (direct ? protocol::tsHAVE : protocol::tsCAN_GET); getApp ().overlay ().foreach (send_always ( boost::make_shared ( - msg, protocol::mtHAVE_SET))); + msg, protocol::mtHAVE_SET))); } /** Apply a set of transactions to a ledger */ void applyTransactions (SHAMap::ref set, Ledger::ref applyLedger, - Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, + Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr) { TransactionEngine engine (applyLedger); - for (SHAMapItem::pointer item = set->peekFirstItem (); !!item; + for (SHAMapItem::pointer item = set->peekFirstItem (); !!item; item = set->peekNextItem (item->getTag ())) if (!checkLedger->hasTransaction (item->getTag ())) { - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Processing candidate transaction: " << item->getTag (); #ifndef TRUST_NETWORK @@ -1284,11 +1267,11 @@ private: { #endif SerializerIterator sit (item->peekSerializer ()); - SerializedTransaction::pointer txn - = boost::make_shared + SerializedTransaction::pointer txn + = boost::make_shared (boost::ref (sit)); - if (applyTransaction (engine, txn, + if (applyTransaction (engine, txn, applyLedger, openLgr, true) == resultRetry) { failedTransactions.push_back (txn); @@ -1309,18 +1292,18 @@ private: for (int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass) { - WriteLog (lsDEBUG, LedgerConsensus) << "Pass: " << pass << " Txns: " - << failedTransactions.size () + WriteLog (lsDEBUG, LedgerConsensus) << "Pass: " << pass << " Txns: " + << failedTransactions.size () << (certainRetry ? " retriable" : " final"); changes = 0; - CanonicalTXSet::iterator it = failedTransactions.begin (); + auto it = failedTransactions.begin (); while (it != failedTransactions.end ()) { try { - switch (applyTransaction (engine, it->second, + switch (applyTransaction (engine, it->second, applyLedger, openLgr, certainRetry)) { case resultSuccess: @@ -1338,13 +1321,13 @@ private: } catch (...) { - WriteLog (lsWARNING, LedgerConsensus) + WriteLog (lsWARNING, LedgerConsensus) << "Transaction throws"; it = failedTransactions.erase (it); } } - WriteLog (lsDEBUG, LedgerConsensus) << "Pass: " + WriteLog (lsDEBUG, LedgerConsensus) << "Pass: " << pass << " finished " << changes << " changes"; // A non-retry pass made no changes @@ -1374,10 +1357,10 @@ private: if (getApp().getHashRouter ().setFlag (txn->getTransactionID () , SF_SIGGOOD)) { - parms = static_cast + parms = static_cast (parms | tapNO_CHECK_SIGN); } - WriteLog (lsDEBUG, LedgerConsensus) << "TXN " + WriteLog (lsDEBUG, LedgerConsensus) << "TXN " << txn->getTransactionID () << (openLedger ? " open" : " closed") << (retryAssured ? "/retry" : "/final"); @@ -1396,21 +1379,21 @@ private: if (didApply) { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Transaction success: " << transHuman (result); return resultSuccess; } - if (isTefFailure (result) || isTemMalformed + if (isTefFailure (result) || isTemMalformed (result) || isTelLocal (result)) { // failure - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Transaction failure: " << transHuman (result); return resultFail; } - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Transaction retry: " << transHuman (result); assert (!ledger->hasTransaction (txn->getTransactionID ())); return resultRetry; @@ -1430,7 +1413,7 @@ private: { return Ledger::roundCloseTime (closeTime, mCloseResolution); } - + /** Send a node status change message to our peers */ void statusChange (protocol::NodeEvent event, Ledger& ledger) @@ -1481,7 +1464,7 @@ private: && ((mPreviousLedger->getLedgerSeq () % 256) == 0)) { // previous ledger was flag ledger - SHAMap::pointer preSet + SHAMap::pointer preSet = initialLedger.peekTransactionMap ()->snapShot (true); m_feeVote.doVoting (mPreviousLedger, preSet); getApp().getAmendmentTable ().doVoting (mPreviousLedger, preSet); @@ -1506,26 +1489,26 @@ private: } else { - mOurPosition - = boost::make_shared + mOurPosition + = boost::make_shared (initialLedger.getParentHash (), txSet, mCloseTime); } - BOOST_FOREACH (u256_lct_pair & it, mDisputes) + for (auto& it : mDisputes) { it.second->setOurVote (initialLedger.hasTransaction (it.first)); } // if any peers have taken a contrary position, process disputes boost::unordered_set found; - BOOST_FOREACH (u160_prop_pair & it, mPeerPositions) + + for (auto& it : mPeerPositions) { uint256 set = it.second->getCurrentHash (); if (found.insert (set).second) { - ripple::unordered_map::iterator iit - = mAcquired.find (set); + auto iit (mAcquired.find (set)); if (iit != mAcquired.end ()) { @@ -1541,9 +1524,9 @@ private: void updateOurPositions () { - boost::posix_time::ptime peerCutoff + boost::posix_time::ptime peerCutoff = boost::posix_time::second_clock::universal_time (); - boost::posix_time::ptime ourCutoff + boost::posix_time::ptime ourCutoff = peerCutoff - boost::posix_time::seconds (PROPOSE_INTERVAL); peerCutoff -= boost::posix_time::seconds (PROPOSE_FRESHNESS); @@ -1553,19 +1536,18 @@ private: // Verify freshness of peer positions and compute close times std::map closeTimes; - ripple::unordered_map::iterator it - = mPeerPositions.begin (); + auto it = mPeerPositions.begin (); while (it != mPeerPositions.end ()) { if (it->second->isStale (peerCutoff)) { // proposal is stale - uint160 peerID = it->second->getPeerID (); - WriteLog (lsWARNING, LedgerConsensus) + auto const& peerID = it->second->getPeerID (); + WriteLog (lsWARNING, LedgerConsensus) << "Removing stale proposal from " << peerID; - BOOST_FOREACH (u256_lct_pair & it, mDisputes) - it.second->unVote (peerID); + for (auto& dt : mDisputes) + dt.second->unVote (peerID); it = mPeerPositions.erase (it); } else @@ -1576,9 +1558,9 @@ private: } } - BOOST_FOREACH (u256_lct_pair & it, mDisputes) + for (auto& it : mDisputes) { - // Because the threshold for inclusion increases, + // Because the threshold for inclusion increases, // time can change our position on a dispute if (it.second->updateVote (mClosePercent, mProposing)) { @@ -1630,7 +1612,7 @@ private: // Threshold for non-zero vote int threshVote = mPeerPositions.size (); // Threshold to declare consensus - int threshConsensus = mPeerPositions.size (); + int threshConsensus = mPeerPositions.size (); if (mProposing) { @@ -1639,9 +1621,9 @@ private: ++threshConsensus; } - threshVote = ((threshVote * neededWeight) + (neededWeight / 2)) + threshVote = ((threshVote * neededWeight) + (neededWeight / 2)) / 100; - threshConsensus = ((threshConsensus * AV_CT_CONSENSUS_PCT) + threshConsensus = ((threshConsensus * AV_CT_CONSENSUS_PCT) + (AV_CT_CONSENSUS_PCT / 2)) / 100; if (threshVote == 0) @@ -1650,21 +1632,21 @@ private: if (threshConsensus == 0) threshConsensus = 1; - WriteLog (lsINFO, LedgerConsensus) << "Proposers:" + WriteLog (lsINFO, LedgerConsensus) << "Proposers:" << mPeerPositions.size () << " nw:" << neededWeight << " thrV:" << threshVote << " thrC:" << threshConsensus; - for (std::map::iterator it = closeTimes.begin () + for (auto it = closeTimes.begin () , end = closeTimes.end (); it != end; ++it) { - WriteLog (lsDEBUG, LedgerConsensus) << "CCTime: seq" - << mPreviousLedger->getLedgerSeq () + 1 << ": " - << it->first << " has " << it->second << ", " + WriteLog (lsDEBUG, LedgerConsensus) << "CCTime: seq" + << mPreviousLedger->getLedgerSeq () + 1 << ": " + << it->first << " has " << it->second << ", " << threshVote << " required"; if (it->second >= threshVote) { - WriteLog (lsDEBUG, LedgerConsensus) + WriteLog (lsDEBUG, LedgerConsensus) << "Close time consensus reached: " << it->first; closeTime = it->first; threshVote = it->second; @@ -1674,28 +1656,28 @@ private: } } - CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConsensus) + CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConsensus) << "No CT consensus: Proposers:" << mPeerPositions.size () << " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:" << threshConsensus << " Pos:" << closeTime; } if (!changes && - ((closeTime != roundCloseTime (mOurPosition->getCloseTime ())) + ((closeTime != roundCloseTime (mOurPosition->getCloseTime ())) || mOurPosition->isStale (ourCutoff))) { // close time changed or our position is stale ourPosition = mAcquired[mOurPosition->getCurrentHash ()] ->snapShot (true); assert (ourPosition); - changes = true; // We pretend our position changed to force + changes = true; // We pretend our position changed to force } // a new proposal if (changes) { uint256 newHash = ourPosition->getHash (); - WriteLog (lsINFO, LedgerConsensus) - << "Position change: CTime " << closeTime + WriteLog (lsINFO, LedgerConsensus) + << "Position change: CTime " << closeTime << ", tx " << newHash; if (mOurPosition->changePosition (newHash, closeTime)) @@ -1708,32 +1690,30 @@ private: } } - /** If we radically changed our consensus context for some reason, + /** If we radically changed our consensus context for some reason, we need to replay recent proposals so that they're not lost. */ void playbackProposals () { ripple::unordered_map < uint160, - std::list > & storedProposals + std::list > & storedProposals = getApp().getOPs ().peekStoredProposals (); - for (ripple::unordered_map< uint160 - , std::list >::iterator it - = storedProposals.begin () + for (auto it = storedProposals.begin () , end = storedProposals.end (); it != end; ++it) { bool relay = false; - BOOST_FOREACH (LedgerProposal::ref proposal, it->second) + for (auto proposal : it->second) { if (proposal->hasSignature ()) { - // we have the signature but don't know the + // we have the signature but don't know the // ledger so couldn't verify proposal->setPrevLedger (mPrevLedgerHash); if (proposal->checkSign ()) { - WriteLog (lsINFO, LedgerConsensus) + WriteLog (lsINFO, LedgerConsensus) << "Applying stored proposal"; relay = peerPosition (proposal); } @@ -1743,12 +1723,12 @@ private: if (relay) { - WriteLog (lsWARNING, LedgerConsensus) + WriteLog (lsWARNING, LedgerConsensus) << "We should do delayed relay of this proposal," << " but we cannot"; } - #if 0 + #if 0 // FIXME: We can't do delayed relay because we don't have the signature std::set peers @@ -1764,7 +1744,7 @@ private: signature getApp ().overlay ().foreach (send_if_not ( boost::make_shared ( - set, protocol::mtPROPOSE_LEDGER), + set, protocol::mtPROPOSE_LEDGER), peer_in_set(peers))); } @@ -1780,7 +1760,7 @@ private: { checkOurValidation (); mState = lcsESTABLISH; - mConsensusStartTime + mConsensusStartTime = boost::posix_time::microsec_clock::universal_time (); mCloseTime = getApp().getOPs ().getCloseTimeNC (); getApp().getOPs ().setLastCloseTime (mCloseTime); @@ -1792,19 +1772,19 @@ private: void checkOurValidation () { // This only covers some cases - Fix for the case where we can't ever acquire the consensus ledger - if (!mHaveCorrectLCL || !mValPublic.isSet () - || !mValPrivate.isSet () + if (!mHaveCorrectLCL || !mValPublic.isSet () + || !mValPrivate.isSet () || getApp().getOPs ().isNeedNetworkLedger ()) { return; } - SerializedValidation::pointer lastVal + SerializedValidation::pointer lastVal = getApp().getOPs ().getLastValidation (); if (lastVal) { - if (lastVal->getFieldU32 (sfLedgerSequence) + if (lastVal->getFieldU32 (sfLedgerSequence) == mPreviousLedger->getLedgerSeq ()) { return; @@ -1814,15 +1794,15 @@ private: } uint256 signingHash; - SerializedValidation::pointer v + SerializedValidation::pointer v = boost::make_shared (mPreviousLedger->getHash () , getApp().getOPs ().getValidationTimeNC (), mValPublic, false); addLoad(v); v->setTrusted (); v->sign (signingHash, mValPrivate); - // FIXME: wrong supression - getApp().getHashRouter ().addSuppression (signingHash); + // FIXME: wrong supression + getApp().getHashRouter ().addSuppression (signingHash); getApp().getValidations ().addValidation (v, "localMissing"); Blob validation = v->getSigned (); protocol::TMValidation val; @@ -1840,18 +1820,18 @@ private: */ void beginAccept (bool synchronous) { - SHAMap::pointer consensusSet + SHAMap::pointer consensusSet = mAcquired[mOurPosition->getCurrentHash ()]; if (!consensusSet) { - WriteLog (lsFATAL, LedgerConsensus) + WriteLog (lsFATAL, LedgerConsensus) << "We don't have a consensus set"; abort (); return; } - getApp().getOPs ().newLCL + getApp().getOPs ().newLCL (mPeerPositions.size (), mCurrentMSeconds, mNewLedgerHash); if (synchronous) @@ -1859,7 +1839,7 @@ private: else { getApp().getJobQueue().addJob (jtACCEPT, "acceptLedger", - BIND_TYPE (&LedgerConsensusImp::accept, shared_from_this (), consensusSet)); + std::bind (&LedgerConsensusImp::accept, shared_from_this (), consensusSet)); } } @@ -1887,11 +1867,11 @@ private: // VFALCO TODO Rename these to look pretty enum LCState { - lcsPRE_CLOSE, // We haven't closed our ledger yet, + lcsPRE_CLOSE, // We haven't closed our ledger yet, // but others might have lcsESTABLISH, // Establishing consensus lcsFINISHED, // We have closed on a transaction set - lcsACCEPTED, // We have accepted/validated + lcsACCEPTED, // We have accepted/validated // a new last closed ledger }; diff --git a/src/ripple_app/data/DBInit.cpp b/src/ripple_app/data/DBInit.cpp index 49277b4cfc..cdaef47dde 100644 --- a/src/ripple_app/data/DBInit.cpp +++ b/src/ripple_app/data/DBInit.cpp @@ -61,7 +61,7 @@ const char* TxnDBInit[] = "END TRANSACTION;" }; -int TxnDBCount = NUMBER (TxnDBInit); +int TxnDBCount = std::extent::value; // Ledger database holds ledgers and ledger confirmations const char* LedgerDBInit[] = @@ -100,7 +100,7 @@ const char* LedgerDBInit[] = "END TRANSACTION;" }; -int LedgerDBCount = NUMBER (LedgerDBInit); +int LedgerDBCount = std::extent::value; // RPC database holds persistent data for RPC clients. const char* RpcDBInit[] = @@ -113,7 +113,7 @@ const char* RpcDBInit[] = );", }; -int RpcDBCount = NUMBER (RpcDBInit); +int RpcDBCount = std::extent::value; // NodeIdentity database holds local accounts and trusted nodes // VFALCO NOTE but its a table not a database, so...? @@ -273,13 +273,13 @@ const char* WalletDBInit[] = "END TRANSACTION;" }; -int WalletDBCount = NUMBER (WalletDBInit); +int WalletDBCount = std::extent::value; // Hash node database holds nodes indexed by hash // VFALCO TODO Remove this since it looks unused /* -int HashNodeDBCount = NUMBER (HashNodeDBInit); +int HashNodeDBCount = std::extent::value; */ // Net node database holds nodes seen on the network @@ -295,7 +295,7 @@ const char* NetNodeDBInit[] = );" }; -int NetNodeDBCount = NUMBER (NetNodeDBInit); +int NetNodeDBCount = std::extent::value; */ // This appears to be unused @@ -331,7 +331,7 @@ const char* PathFindDBInit[] = "CREATE INDEX ExTo ON Exchanges(To, Currency, Use);", }; -int PathFindDBCount = NUMBER (PathFindDBInit); +int PathFindDBCount = std::extent::value; */ } // ripple diff --git a/src/ripple_app/data/SqliteDatabase.cpp b/src/ripple_app/data/SqliteDatabase.cpp index c44362e19a..ae56f10d21 100644 --- a/src/ripple_app/data/SqliteDatabase.cpp +++ b/src/ripple_app/data/SqliteDatabase.cpp @@ -319,7 +319,7 @@ void SqliteDatabase::doHook (const char* db, int pages) if (mWalQ) { - mWalQ->addJob (jtWAL, std::string ("WAL:") + mHost, BIND_TYPE (&SqliteDatabase::runWal, this)); + mWalQ->addJob (jtWAL, std::string ("WAL:") + mHost, std::bind (&SqliteDatabase::runWal, this)); } else { diff --git a/src/ripple_app/ledger/InboundLedger.cpp b/src/ripple_app/ledger/InboundLedger.cpp index b35285a86b..2dcec348ca 100644 --- a/src/ripple_app/ledger/InboundLedger.cpp +++ b/src/ripple_app/ledger/InboundLedger.cpp @@ -259,8 +259,8 @@ void InboundLedger::onTimer (bool wasProgress, ScopedLockType&) mByHash = true; std::size_t pc = getPeerCount (); - WriteLog (lsDEBUG, InboundLedger) << - "No progress(" << pc << + WriteLog (lsDEBUG, InboundLedger) << + "No progress(" << pc << ") for ledger " << mHash; trigger (Peer::ptr ()); @@ -278,7 +278,7 @@ void InboundLedger::addPeers () if (vSize == 0) { - WriteLog (lsERROR, InboundLedger) << + WriteLog (lsERROR, InboundLedger) << "No peers to add for ledger acquisition"; return; } @@ -329,7 +329,7 @@ void InboundLedger::addPeers () } else if (mSeq != 0) { - if (m_journal.debug) m_journal.debug << + if (m_journal.debug) m_journal.debug << "Found " << found << " peer(s) with ledger " << mSeq; } else @@ -391,7 +391,8 @@ void InboundLedger::done () // We hold the PeerSet lock, so must dispatch getApp().getJobQueue ().addJob (jtLEDGER_DATA, "triggers", - BIND_TYPE (LADispatch, P_1, shared_from_this (), triggers)); + std::bind (LADispatch, std::placeholders::_1, shared_from_this (), + triggers)); } bool InboundLedger::addOnComplete ( @@ -1252,10 +1253,10 @@ Json::Value InboundLedger::getJson (int) if (mHaveBase && !mHaveState) { Json::Value hv (Json::arrayValue); - + // VFALCO Why 16? auto v = mLedger->getNeededAccountStateHashes (16, nullptr); - + for (auto const& h : v) { hv.append (to_string (h)); diff --git a/src/ripple_app/ledger/InboundLedgers.cpp b/src/ripple_app/ledger/InboundLedgers.cpp index a86481f6d2..eb714db2f8 100644 --- a/src/ripple_app/ledger/InboundLedgers.cpp +++ b/src/ripple_app/ledger/InboundLedgers.cpp @@ -25,7 +25,7 @@ class InboundLedgersImp , public beast::LeakChecked { public: - typedef std::pair u256_acq_pair; + typedef std::pair u256_acq_pair; // How long before we try again to acquire the same ledger static const int kReacquireIntervalSeconds = 300; @@ -171,7 +171,7 @@ public: if (packet.type () == protocol::liAS_NODE) { getApp().getJobQueue().addJob(jtLEDGER_DATA, "gotStaleData", - BIND_TYPE(&InboundLedgers::gotStaleData, this, packet_ptr)); + std::bind(&InboundLedgers::gotStaleData, this, packet_ptr)); } return false; @@ -180,7 +180,8 @@ public: // Stash the data for later processing and see if we need to dispatch if (ledger->gotData(boost::weak_ptr(peer), packet_ptr)) getApp().getJobQueue().addJob (jtLEDGER_DATA, "processLedgerData", - BIND_TYPE (&InboundLedgers::doLedgerData, this, P_1, hash)); + std::bind (&InboundLedgers::doLedgerData, this, + std::placeholders::_1, hash)); return true; } diff --git a/src/ripple_app/ledger/Ledger.cpp b/src/ripple_app/ledger/Ledger.cpp index a51f6762be..29e2b9cd85 100644 --- a/src/ripple_app/ledger/Ledger.cpp +++ b/src/ripple_app/ledger/Ledger.cpp @@ -624,7 +624,7 @@ bool Ledger::saveValidatedLedger (bool current) db->executeSQL (boost::str (deleteTrans1 % mLedgerSeq)); db->executeSQL (boost::str (deleteTrans2 % mLedgerSeq)); - BOOST_FOREACH (const AcceptedLedger::value_type & vt, aLedger->getMap ()) + for (auto const& vt : aLedger->getMap ()) { uint256 txID = vt.second->getTransactionID (); getApp().getMasterTransaction ().inLedger (txID, mLedgerSeq); @@ -676,8 +676,8 @@ bool Ledger::saveValidatedLedger (bool current) getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (addLedger % to_string (getHash ()) % mLedgerSeq % to_string (mParentHash) % - beast::lexicalCastThrow (mTotCoins) % mCloseTime % - mParentCloseTime % mCloseResolution % mCloseFlags % + beast::lexicalCastThrow (mTotCoins) % mCloseTime % + mParentCloseTime % mCloseResolution % mCloseFlags % to_string (mAccountHash) % to_string (mTransHash))); } @@ -1107,9 +1107,11 @@ Json::Value Ledger::getJson (int options) { Json::Value& state = (ledger[jss::accountState] = Json::arrayValue); if (bFull || is_bit_set (options, LEDGER_JSON_EXPAND)) - visitStateItems(BIND_TYPE(stateItemFullAppender, std::ref(state), P_1)); + visitStateItems(std::bind(stateItemFullAppender, std::ref(state), + std::placeholders::_1)); else - mAccountStateMap->visitLeaves(BIND_TYPE(stateItemTagAppender, std::ref(state), P_1)); + mAccountStateMap->visitLeaves(std::bind(stateItemTagAppender, + std::ref(state), std::placeholders::_1)); } return ledger; @@ -1233,7 +1235,7 @@ void Ledger::visitAccountItems (const uint160& accountID, std::functiongetType () != ltDIR_NODE)) return; - BOOST_FOREACH (uint256 const & uNode, ownerDir->getFieldV256 (sfIndexes).peekValue ()) + for (auto const& uNode : ownerDir->getFieldV256 (sfIndexes).peekValue ()) { func (getSLEi (uNode)); } @@ -1243,7 +1245,7 @@ void Ledger::visitAccountItems (const uint160& accountID, std::function function) try { if (mAccountStateMap) - mAccountStateMap->visitLeaves(BIND_TYPE(&visitHelper, std::ref(function), P_1)); + mAccountStateMap->visitLeaves(std::bind(&visitHelper, + std::ref(function), std::placeholders::_1)); } catch (SHAMapMissingNode&) { @@ -1919,12 +1922,14 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent) else if (isCurrent) { getApp().getJobQueue ().addJob (jtPUBLEDGER, "Ledger::pendSave", - BIND_TYPE (&Ledger::saveValidatedLedgerAsync, shared_from_this (), P_1, isCurrent)); + std::bind (&Ledger::saveValidatedLedgerAsync, shared_from_this (), + std::placeholders::_1, isCurrent)); } else { getApp().getJobQueue ().addJob (jtPUBOLDLEDGER, "Ledger::pendOldSave", - BIND_TYPE (&Ledger::saveValidatedLedgerAsync, shared_from_this (), P_1, isCurrent)); + std::bind (&Ledger::saveValidatedLedgerAsync, shared_from_this (), + std::placeholders::_1, isCurrent)); } return true; diff --git a/src/ripple_app/ledger/LedgerEntrySet.cpp b/src/ripple_app/ledger/LedgerEntrySet.cpp index 9e0000d11c..90d4d65e0e 100644 --- a/src/ripple_app/ledger/LedgerEntrySet.cpp +++ b/src/ripple_app/ledger/LedgerEntrySet.cpp @@ -71,7 +71,7 @@ void LedgerEntrySet::swapWith (LedgerEntrySet& e) // This is basically: copy-on-read. SLE::pointer LedgerEntrySet::getEntry (uint256 const& index, LedgerEntryAction& action) { - std::map::iterator it = mEntries.find (index); + auto it = mEntries.find (index); if (it == mEntries.end ()) { @@ -137,7 +137,7 @@ void LedgerEntrySet::entryCache (SLE::ref sle) { assert (mLedger); assert (sle->isMutable () || mImmutable); // Don't put an immutable SLE in a mutable LES - std::map::iterator it = mEntries.find (sle->getIndex ()); + auto it = mEntries.find (sle->getIndex ()); if (it == mEntries.end ()) { @@ -162,7 +162,7 @@ void LedgerEntrySet::entryCreate (SLE::ref sle) { assert (mLedger && !mImmutable); assert (sle->isMutable ()); - std::map::iterator it = mEntries.find (sle->getIndex ()); + auto it = mEntries.find (sle->getIndex ()); if (it == mEntries.end ()) { @@ -200,7 +200,7 @@ void LedgerEntrySet::entryModify (SLE::ref sle) { assert (sle->isMutable () && !mImmutable); assert (mLedger); - std::map::iterator it = mEntries.find (sle->getIndex ()); + auto it = mEntries.find (sle->getIndex ()); if (it == mEntries.end ()) { @@ -236,7 +236,7 @@ void LedgerEntrySet::entryDelete (SLE::ref sle) { assert (sle->isMutable () && !mImmutable); assert (mLedger); - std::map::iterator it = mEntries.find (sle->getIndex ()); + auto it = mEntries.find (sle->getIndex ()); if (it == mEntries.end ()) { @@ -271,11 +271,9 @@ void LedgerEntrySet::entryDelete (SLE::ref sle) bool LedgerEntrySet::hasChanges () { - typedef std::map::value_type u256_LES_pair; - BOOST_FOREACH (u256_LES_pair & it, mEntries) - - if (it.second.mAction != taaCACHED) - return true; + for (auto const& it : mEntries) + if (it.second.mAction != taaCACHED) + return true; return false; } @@ -360,7 +358,7 @@ Json::Value LedgerEntrySet::getJson (int) const SLE::pointer LedgerEntrySet::getForMod (uint256 const& node, Ledger::ref ledger, ripple::unordered_map& newMods) { - std::map::iterator it = mEntries.find (node); + auto it = mEntries.find (node); if (it != mEntries.end ()) { @@ -382,7 +380,7 @@ SLE::pointer LedgerEntrySet::getForMod (uint256 const& node, Ledger::ref ledger, return it->second.mEntry; } - ripple::unordered_map::iterator me = newMods.find (node); + auto me (newMods.find (node)); if (me != newMods.end ()) { @@ -467,8 +465,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index // Entries modified only as a result of building the transaction metadata ripple::unordered_map newMod; - typedef std::map::value_type u256_LES_pair; - BOOST_FOREACH (u256_LES_pair & it, mEntries) + for (auto& it : mEntries) { SField::ptr type = &sfGeneric; @@ -508,8 +505,9 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index if ((type == &sfModifiedNode) && (*curNode == *origNode)) continue; - std::uint16_t nodeType = curNode ? curNode->getFieldU16 (sfLedgerEntryType) - : origNode->getFieldU16 (sfLedgerEntryType); + std::uint16_t nodeType = curNode + ? curNode->getFieldU16 (sfLedgerEntryType) + : origNode->getFieldU16 (sfLedgerEntryType); mSet.setAffectedNode (it.first, *type, nodeType); @@ -519,7 +517,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index threadOwners (origNode, mLedger, newMod); // thread transaction to owners STObject prevs (sfPreviousFields); - BOOST_FOREACH (const SerializedType & obj, *origNode) + for (auto const& obj : *origNode) { // go through the original node for modified fields saved on modification if (obj.getFName ().shouldMeta (SField::sMD_ChangeOrig) && !curNode->hasMatchingEntry (obj)) @@ -530,7 +528,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index mSet.getAffectedNode (it.first).addObject (prevs); STObject finals (sfFinalFields); - BOOST_FOREACH (const SerializedType & obj, *curNode) + for (auto const& obj : *curNode) { // go through the final node for final fields if (obj.getFName ().shouldMeta (SField::sMD_Always | SField::sMD_DeleteFinal)) @@ -548,7 +546,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index threadTx (curNode, mLedger, newMod); STObject prevs (sfPreviousFields); - BOOST_FOREACH (const SerializedType & obj, *origNode) + for (auto const& obj : *origNode) { // search the original node for values saved on modify if (obj.getFName ().shouldMeta (SField::sMD_ChangeOrig) && !curNode->hasMatchingEntry (obj)) @@ -559,7 +557,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index mSet.getAffectedNode (it.first).addObject (prevs); STObject finals (sfFinalFields); - BOOST_FOREACH (const SerializedType & obj, *curNode) + for (auto const& obj : *curNode) { // search the final node for values saved always if (obj.getFName ().shouldMeta (SField::sMD_Always | SField::sMD_ChangeNew)) @@ -578,7 +576,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index threadTx (curNode, mLedger, newMod); STObject news (sfNewFields); - BOOST_FOREACH (const SerializedType & obj, *curNode) + for (auto const& obj : *curNode) { // save non-default values if (!obj.isDefault () && obj.getFName ().shouldMeta (SField::sMD_Create | SField::sMD_Always)) @@ -592,8 +590,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index } // add any new modified nodes to the modification set - typedef std::map::value_type u256_sle_pair; - BOOST_FOREACH (u256_sle_pair & it, newMod) + for (auto& it : newMod) entryModify (it.second); mSet.addRaw (s, result, index); @@ -730,7 +727,7 @@ TER LedgerEntrySet::dirAdd ( svIndexes.peekValue ().push_back (uLedgerIndex); // Append entry. sleNode->setFieldV256 (sfIndexes, svIndexes); // Save entry. - WriteLog (lsTRACE, LedgerEntrySet) << + WriteLog (lsTRACE, LedgerEntrySet) << "dirAdd: creating: root: " << to_string (uRootIndex); WriteLog (lsTRACE, LedgerEntrySet) << "dirAdd: appending: Entry: " << to_string (uLedgerIndex); @@ -777,11 +774,10 @@ TER LedgerEntrySet::dirDelete ( } } - STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes); - std::vector& vuiIndexes = svIndexes.peekValue (); - std::vector::iterator it; + STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes); + std::vector& vuiIndexes = svIndexes.peekValue (); - it = std::find (vuiIndexes.begin (), vuiIndexes.end (), uLedgerIndex); + auto it = std::find (vuiIndexes.begin (), vuiIndexes.end (), uLedgerIndex); if (vuiIndexes.end () == it) { @@ -797,7 +793,8 @@ TER LedgerEntrySet::dirDelete ( { // Go the extra mile. Even if entry not in node, try the next node. - return dirDelete (bKeepRoot, uNodeDir + 1, uRootIndex, uLedgerIndex, bStable, true); + return dirDelete (bKeepRoot, uNodeDir + 1, uRootIndex, uLedgerIndex, + bStable, true); } else { @@ -1123,7 +1120,7 @@ STAmount LedgerEntrySet::rippleOwed (const uint160& uToAccountID, const uint160& saBalance.clear (uCurrencyID, uToAccountID); WriteLog (lsDEBUG, LedgerEntrySet) << "rippleOwed:" << - " No credit line between " << + " No credit line between " << RippleAddress::createHumanAccountID (uFromAccountID) << " and " << RippleAddress::createHumanAccountID (uToAccountID) << " for " << STAmount::createHumanCurrency (uCurrencyID); @@ -1167,7 +1164,7 @@ std::uint32_t LedgerEntrySet::rippleTransferRate (const uint160& uIssuerID) SLE::pointer sleAccount (entryCache ( ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uIssuerID))); - std::uint32_t uQuality = + std::uint32_t uQuality = sleAccount && sleAccount->isFieldPresent (sfTransferRate) ? sleAccount->getFieldU32 (sfTransferRate) : QUALITY_ONE; @@ -1208,7 +1205,7 @@ LedgerEntrySet::rippleQualityIn (const uint160& uToAccountID, } else { - sleRippleState = entryCache (ltRIPPLE_STATE, + sleRippleState = entryCache (ltRIPPLE_STATE, Ledger::getRippleStateIndex (uToAccountID, uFromAccountID, uCurrencyID)); if (sleRippleState) @@ -1360,11 +1357,11 @@ STAmount LedgerEntrySet::rippleTransferFee ( { // NIKB use STAmount::saFromRate STAmount saTransitRate ( - CURRENCY_ONE, ACCOUNT_ONE, + CURRENCY_ONE, ACCOUNT_ONE, static_cast (uTransitRate), -9); STAmount saTransferTotal = STAmount::multiply ( - saAmount, saTransitRate, + saAmount, saTransitRate, saAmount.getCurrency (), saAmount.getIssuer ()); STAmount saTransferFee = saTransferTotal - saAmount; @@ -1403,7 +1400,9 @@ TER LedgerEntrySet::trustCreate ( uLowNode, Ledger::getOwnerDirIndex (uLowAccountID), sleRippleState->getIndex (), - BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, uLowAccountID)); + std::bind (&Ledger::ownerDirDescriber, + std::placeholders::_1, std::placeholders::_2, + uLowAccountID)); if (tesSUCCESS == terResult) { @@ -1411,7 +1410,9 @@ TER LedgerEntrySet::trustCreate ( uHighNode, Ledger::getOwnerDirIndex (uHighAccountID), sleRippleState->getIndex (), - BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, uHighAccountID)); + std::bind (&Ledger::ownerDirDescriber, + std::placeholders::_1, std::placeholders::_2, + uHighAccountID)); } if (tesSUCCESS == terResult) @@ -1534,7 +1535,7 @@ TER LedgerEntrySet::rippleCredit (const uint160& uSenderID, const uint160& uRece saBalance -= saAmount; WriteLog (lsTRACE, LedgerEntrySet) << "rippleCredit: " << - RippleAddress::createHumanAccountID (uSenderID) << + RippleAddress::createHumanAccountID (uSenderID) << " -> " << RippleAddress::createHumanAccountID (uReceiverID) << " : before=" << saBefore.getFullText () << " amount=" << saAmount.getFullText () << @@ -1718,4 +1719,3 @@ TER LedgerEntrySet::accountSend (const uint160& uSenderID, const uint160& uRecei } } // ripple - diff --git a/src/ripple_app/ledger/LedgerMaster.cpp b/src/ripple_app/ledger/LedgerMaster.cpp index 9e04fffaf0..048d83c922 100644 --- a/src/ripple_app/ledger/LedgerMaster.cpp +++ b/src/ripple_app/ledger/LedgerMaster.cpp @@ -400,7 +400,7 @@ public: // Returns Ledgers we have all the nodes for and are indexed bool getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) - { + { maxVal = mPubLedgerSeq.load(); if (!maxVal) @@ -432,7 +432,7 @@ public: ++minVal; // Best effort for remaining exclusions - BOOST_FOREACH(std::uint32_t v, sPendingSaves) + for(auto v : sPendingSaves) { if ((v >= minVal) && (v <= maxVal)) { @@ -484,7 +484,7 @@ public: break; } - std::map< std::uint32_t, std::pair >::iterator it = ledgerHashes.find (seq); + auto it (ledgerHashes.find (seq)); if (it == ledgerHashes.end ()) { @@ -496,7 +496,9 @@ public: mCompleteLedgers.setRange (minHas, maxHas); } maxHas = minHas; - ledgerHashes = Ledger::getHashesByIndex ((seq < 500) ? 0 : (seq - 499), seq); + ledgerHashes = Ledger::getHashesByIndex ((seq < 500) + ? 0 + : (seq - 499), seq); it = ledgerHashes.find (seq); if (it == ledgerHashes.end ()) @@ -528,7 +530,7 @@ public: int count = 0; Overlay::PeerSequence peerList = getApp().overlay ().getActivePeers (); - BOOST_FOREACH (const Peer::ptr & peer, peerList) + for (auto const& peer : peerList) { if (peer->hasRange (nextLedger->getLedgerSeq() - 1, nextLedger->getLedgerSeq())) { @@ -565,13 +567,14 @@ public: try { hash = ledger->getLedgerHash (lSeq); - } - catch (...) - { - WriteLog (lsWARNING, LedgerMaster) << "fixMismatch encounters partial ledger"; - clearLedger(lSeq); - return; - } + } + catch (...) + { + WriteLog (lsWARNING, LedgerMaster) << + "fixMismatch encounters partial ledger"; + clearLedger(lSeq); + return; + } if (hash.isNonZero ()) { @@ -581,8 +584,9 @@ public: if (otherLedger && (otherLedger->getHash () == hash)) { // we closed the seam - CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "Match at " << lSeq << ", " << - invalidate << " prior ledgers invalidated"; + CondLog (invalidate != 0, lsWARNING, LedgerMaster) << + "Match at " << lSeq << ", " << invalidate << + " prior ledgers invalidated"; return; } } @@ -592,7 +596,8 @@ public: } // all prior ledgers invalidated - CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "All " << invalidate << " prior ledgers invalidated"; + CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "All " << + invalidate << " prior ledgers invalidated"; } void setFullLedger (Ledger::pointer ledger, bool isSynchronous, bool isCurrent) @@ -664,9 +669,9 @@ public: return; // Ledger could match the ledger we're already building - if (seq == mBuildingLedgerSeq) - return; - } + if (seq == mBuildingLedgerSeq) + return; + } Ledger::pointer ledger = mLedgerHistory.getLedgerByHash (hash); @@ -681,7 +686,7 @@ public: ledger = l->getLedger(); else { - WriteLog (lsDEBUG, LedgerMaster) << + WriteLog (lsDEBUG, LedgerMaster) << "checkAccept triggers acquire " << to_string (hash); } } @@ -765,7 +770,7 @@ public: /** Report that the consensus process built a particular ledger */ void consensusBuilt (Ledger::ref ledger) override { - + // Because we just built a ledger, we are no longer building one setBuildingLedger (0); @@ -939,8 +944,9 @@ public: { // Previous ledger is in DB ScopedLockType sl(m_mutex); mFillInProgress = ledger->getLedgerSeq(); - getApp().getJobQueue().addJob(jtADVANCE, "tryFill", BIND_TYPE ( - &LedgerMasterImp::tryFill, this, P_1, ledger)); + getApp().getJobQueue().addJob(jtADVANCE, "tryFill", std::bind ( + &LedgerMasterImp::tryFill, this, + std::placeholders::_1, ledger)); } progress = true; } @@ -984,12 +990,15 @@ public: } else { - WriteLog (lsTRACE, LedgerMaster) << "tryAdvance found " << pubLedgers.size() << " ledgers to publish"; - BOOST_FOREACH(Ledger::ref ledger, pubLedgers) + WriteLog (lsTRACE, LedgerMaster) << + "tryAdvance found " << pubLedgers.size() << + " ledgers to publish"; + for(auto ledger : pubLedgers) { { ScopedUnlockType sul (m_mutex); - WriteLog(lsDEBUG, LedgerMaster) << "tryAdvance publishing seq " << ledger->getLedgerSeq(); + WriteLog(lsDEBUG, LedgerMaster) << + "tryAdvance publishing seq " << ledger->getLedgerSeq(); setFullLedger(ledger, true, true); getApp().getOPs().pubLedger(ledger); @@ -1116,20 +1125,20 @@ public: { mAdvanceThread = true; getApp().getJobQueue ().addJob (jtADVANCE, "advanceLedger", - BIND_TYPE (&LedgerMasterImp::advanceThread, this)); + std::bind (&LedgerMasterImp::advanceThread, this)); } } // Return the hash of the valid ledger with a particular sequence, given a subsequent ledger known valid uint256 getLedgerHash(std::uint32_t desiredSeq, Ledger::ref knownGoodLedger) - { + { assert(desiredSeq < knownGoodLedger->getLedgerSeq()); uint256 hash = knownGoodLedger->getLedgerHash(desiredSeq); // Not directly in the given ledger if (hash.isZero ()) - { + { std::uint32_t seq = (desiredSeq + 255) % 256; assert(seq < desiredSeq); @@ -1244,7 +1253,8 @@ public: { ++mPathFindThread; getApp().getJobQueue().addJob (jtUPDATE_PF, name, - BIND_TYPE (&LedgerMasterImp::updatePaths, this, P_1)); + std::bind (&LedgerMasterImp::updatePaths, this, + std::placeholders::_1)); } } @@ -1346,7 +1356,7 @@ public: // See if the hash for the ledger we need is in the reference ledger ledgerHash = referenceLedger->getLedgerHash (index); if (ledgerHash.isZero()) - { + { // No, Try to get another ledger that might have the hash we need // Compute the index and hash of a ledger that will have the hash we need LedgerIndex refIndex = (index + 255) & (~255); diff --git a/src/ripple_app/ledger/OrderBookDB.cpp b/src/ripple_app/ledger/OrderBookDB.cpp index 71feeb46e3..c34afbb070 100644 --- a/src/ripple_app/ledger/OrderBookDB.cpp +++ b/src/ripple_app/ledger/OrderBookDB.cpp @@ -59,7 +59,7 @@ void OrderBookDB::setup (Ledger::ref ledger) update(ledger); else getApp().getJobQueue().addJob(jtUPDATE_PF, "OrderBookDB::update", - BIND_TYPE(&OrderBookDB::update, this, ledger)); + std::bind(&OrderBookDB::update, this, ledger)); } static void updateHelper (SLE::ref entry, @@ -108,7 +108,8 @@ void OrderBookDB::update (Ledger::pointer ledger) try { - ledger->visitStateItems(BIND_TYPE(&updateHelper, P_1, boost::ref(seen), boost::ref(destMap), + ledger->visitStateItems(std::bind(&updateHelper, std::placeholders::_1, + boost::ref(seen), boost::ref(destMap), boost::ref(sourceMap), boost::ref(XRPBooks), boost::ref(books))); } catch (const SHAMapMissingNode&) @@ -138,7 +139,7 @@ void OrderBookDB::addOrderBook(const uint160& ci, const uint160& co, if (toXRP) { // We don't want to search through all the to-XRP or from-XRP order books! - BOOST_FOREACH(OrderBook::ref ob, mSourceMap[RippleAssetRef(ci, ii)]) + for (auto ob : mSourceMap[RippleAssetRef(ci, ii)]) { if (ob->getCurrencyOut().isZero ()) // also to XRP return; @@ -146,7 +147,7 @@ void OrderBookDB::addOrderBook(const uint160& ci, const uint160& co, } else { - BOOST_FOREACH(OrderBook::ref ob, mDestMap[RippleAssetRef(co, io)]) + for (auto ob : mDestMap[RippleAssetRef(co, io)]) { if ((ob->getCurrencyIn() == ci) && (ob->getIssuerIn() == ii)) return; @@ -168,8 +169,7 @@ void OrderBookDB::getBooksByTakerPays (RippleIssuer const& issuerID, RippleCurre std::vector& bookRet) { ScopedLockType sl (mLock); - ripple::unordered_map< RippleAsset, std::vector >::const_iterator - it = mSourceMap.find (RippleAssetRef (currencyID, issuerID)); + auto it = mSourceMap.find (RippleAssetRef (currencyID, issuerID)); if (it != mSourceMap.end ()) bookRet = it->second; @@ -189,8 +189,7 @@ void OrderBookDB::getBooksByTakerGets (RippleIssuer const& issuerID, RippleCurre std::vector& bookRet) { ScopedLockType sl (mLock); - ripple::unordered_map< RippleAsset, std::vector >::const_iterator - it = mDestMap.find (RippleAssetRef (currencyID, issuerID)); + auto it = mDestMap.find (RippleAssetRef (currencyID, issuerID)); if (it != mDestMap.end ()) bookRet = it->second; @@ -243,7 +242,7 @@ void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, { // check if this is an offer or an offer cancel or a payment that consumes an offer //check to see what the meta looks like - BOOST_FOREACH (STObject & node, alTx.getMeta ()->getNodes ()) + for (auto& node : alTx.getMeta ()->getNodes ()) { try { @@ -296,7 +295,7 @@ void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, } } } - + //------------------------------------------------------------------------------ BookListeners::BookListeners () diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index e227c48e89..354ca7aae3 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -24,7 +24,7 @@ #include "Tuning.h" namespace ripple { - + // VFALCO TODO Clean this global up static bool volatile doShutdown = false; @@ -331,7 +331,7 @@ public: , m_txQueue (TxQueue::New ()) , m_validators (add (Validators::Manager::New ( - *this, + *this, getConfig ().getModuleDatabasePath (), LogPartition::getJournal ()))) @@ -732,7 +732,7 @@ public: // move the instantiation inside a conditional: // // if (!getConfig ().RUN_STANDALONE) - m_peers = make_Overlay (m_mainIoPool, *m_resourceManager, + m_peers = make_Overlay (m_mainIoPool, *m_resourceManager, *m_siteFiles, getConfig ().getModuleDatabasePath (), *m_resolver, m_mainIoPool, m_peerSSLContext->get ()); // add to Stoppable @@ -954,7 +954,7 @@ public: // running the various logic threads like Validators, PeerFinder, etc. prepare (); start (); - + { if (!getConfig ().RUN_STANDALONE) @@ -1043,7 +1043,8 @@ public: } m_jobQueue->addJob(jtSWEEP, "sweep", - BIND_TYPE(&ApplicationImp::doSweep, this, P_1)); + std::bind(&ApplicationImp::doSweep, this, + std::placeholders::_1)); } } diff --git a/src/ripple_app/main/NodeStoreScheduler.cpp b/src/ripple_app/main/NodeStoreScheduler.cpp index 5dc600e031..6f8f0b5af9 100644 --- a/src/ripple_app/main/NodeStoreScheduler.cpp +++ b/src/ripple_app/main/NodeStoreScheduler.cpp @@ -47,8 +47,8 @@ void NodeStoreScheduler::scheduleTask (NodeStore::Task& task) m_jobQueue->addJob ( jtWRITE, "NodeObject::store", - BIND_TYPE (&NodeStoreScheduler::doTask, - this, boost::ref(task), P_1)); + std::bind (&NodeStoreScheduler::doTask, + this, boost::ref(task), std::placeholders::_1)); } void NodeStoreScheduler::doTask (NodeStore::Task& task, Job&) diff --git a/src/ripple_app/misc/NetworkOPs.cpp b/src/ripple_app/misc/NetworkOPs.cpp index 0f1120a1ca..a787b13958 100644 --- a/src/ripple_app/misc/NetworkOPs.cpp +++ b/src/ripple_app/misc/NetworkOPs.cpp @@ -533,12 +533,12 @@ void NetworkOPsImp::onDeadlineTimer (beast::DeadlineTimer& timer) if (timer == m_heartbeatTimer) { getApp().getJobQueue ().addJob (jtNETOP_TIMER, "NetOPs.heartbeat", - BIND_TYPE (&NetworkOPsImp::processHeartbeatTimer, this)); + std::bind (&NetworkOPsImp::processHeartbeatTimer, this)); } else if (timer == m_clusterTimer) { getApp().getJobQueue ().addJob (jtNETOP_CLUSTER, "NetOPs.cluster", - BIND_TYPE (&NetworkOPsImp::processClusterTimer, this)); + std::bind (&NetworkOPsImp::processClusterTimer, this)); } } @@ -916,7 +916,7 @@ void NetworkOPsImp::runTransactionQueue () } if (getApp().getTxQueue ().stopProcessing (txn)) - getApp().getIOService ().post (BIND_TYPE (&NetworkOPsImp::runTransactionQueue, this)); + getApp().getIOService ().post (std::bind (&NetworkOPsImp::runTransactionQueue, this)); } Transaction::pointer NetworkOPsImp::processTransactionCb ( @@ -2436,7 +2436,7 @@ void NetworkOPsImp::reportFeeChange () (getApp().getFeeTrack ().getLoadFactor () == mLastLoadFactor)) return; - getApp().getJobQueue ().addJob (jtCLIENT, "reportFeeChange->pubServer", BIND_TYPE (&NetworkOPsImp::pubServer, this)); + getApp().getJobQueue ().addJob (jtCLIENT, "reportFeeChange->pubServer", std::bind (&NetworkOPsImp::pubServer, this)); } Json::Value NetworkOPsImp::transJson (const SerializedTransaction& stTxn, TER terResult, bool bValidated, @@ -2864,15 +2864,15 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker const uint256 uBookEnd = Ledger::getQualityNext (uBookBase); uint256 uTipIndex = uBookBase; - if (m_journal.trace) + if (m_journal.trace) { m_journal.trace << "getBookPage:" << - " uTakerPaysCurrencyID=" << + " uTakerPaysCurrencyID=" << STAmount::createHumanCurrency (uTakerPaysCurrencyID) << " uTakerPaysIssuerID=" << RippleAddress::createHumanAccountID (uTakerPaysIssuerID); m_journal.trace << "getBookPage:" << - " uTakerGetsCurrencyID=" << + " uTakerGetsCurrencyID=" << STAmount::createHumanCurrency (uTakerGetsCurrencyID) << " uTakerGetsIssuerID=" << RippleAddress::createHumanAccountID (uTakerGetsIssuerID); @@ -3016,7 +3016,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker STAmount saOwnerPays = (QUALITY_ONE == uOfferRate) ? saTakerGetsFunded : std::min ( - saOwnerFunds, + saOwnerFunds, STAmount::multiply ( saTakerGetsFunded, STAmount (CURRENCY_ONE, ACCOUNT_ONE, uOfferRate, -9))); @@ -3273,11 +3273,14 @@ void NetworkOPsImp::makeFetchPack (Job&, boost::weak_ptr wPeer, wantLedger->peekAccountStateMap ()->getFetchPack (haveLedger->peekAccountStateMap ().get (), true, 1024, - BIND_TYPE (fpAppender, &reply, lSeq, P_1, P_2)); + std::bind (fpAppender, &reply, lSeq, std::placeholders::_1, + std::placeholders::_2)); if (wantLedger->getTransHash ().isNonZero ()) - wantLedger->peekTransactionMap ()->getFetchPack (nullptr, true, 256, - BIND_TYPE (fpAppender, &reply, lSeq, P_1, P_2)); + wantLedger->peekTransactionMap ()->getFetchPack ( + nullptr, true, 256, + std::bind (fpAppender, &reply, lSeq, std::placeholders::_1, + std::placeholders::_2)); if (reply.objects ().size () >= 256) break; @@ -3347,7 +3350,8 @@ void NetworkOPsImp::gotFetchPack (bool progress, std::uint32_t seq) // which is expensive. A flag should track whether we've already dispatched getApp().getJobQueue ().addJob (jtLEDGER_DATA, "gotFetchPack", - BIND_TYPE (&InboundLedgers::gotFetchPack, &getApp().getInboundLedgers (), P_1)); + std::bind (&InboundLedgers::gotFetchPack, + &getApp().getInboundLedgers (), std::placeholders::_1)); } void NetworkOPsImp::missingNodeInLedger (std::uint32_t seq) diff --git a/src/ripple_app/misc/ProofOfWork.cpp b/src/ripple_app/misc/ProofOfWork.cpp index c206984afa..8b84321d9a 100644 --- a/src/ripple_app/misc/ProofOfWork.cpp +++ b/src/ripple_app/misc/ProofOfWork.cpp @@ -181,7 +181,7 @@ bool ProofOfWork::calcResultInfo (PowResult powCode, std::string& strToken, std: { powOK, "powOK", "Valid proof-of-work." }, }; - int iIndex = NUMBER (powResultInfoA); + int iIndex = RIPPLE_ARRAYSIZE (powResultInfoA); while (iIndex-- && powResultInfoA[iIndex].powCode != powCode) ; diff --git a/src/ripple_app/misc/Validations.cpp b/src/ripple_app/misc/Validations.cpp index c5f19eff17..5bb75a8f3c 100644 --- a/src/ripple_app/misc/Validations.cpp +++ b/src/ripple_app/misc/Validations.cpp @@ -419,7 +419,8 @@ private: mWriting = true; getApp().getJobQueue ().addJob (jtWRITE, "Validations::doWrite", - BIND_TYPE (&ValidationsImp::doWrite, this, P_1)); + std::bind (&ValidationsImp::doWrite, + this, std::placeholders::_1)); } void doWrite (Job&) diff --git a/src/ripple_app/node/SqliteFactory.cpp b/src/ripple_app/node/SqliteFactory.cpp index 51508ada69..5b22750437 100644 --- a/src/ripple_app/node/SqliteFactory.cpp +++ b/src/ripple_app/node/SqliteFactory.cpp @@ -41,7 +41,7 @@ static const char* s_nodeStoreDBInit [] = "END TRANSACTION;" }; -static int s_nodeStoreDBCount = NUMBER (s_nodeStoreDBInit); +static int s_nodeStoreDBCount = RIPPLE_ARRAYSIZE (s_nodeStoreDBInit); //------------------------------------------------------------------------------ diff --git a/src/ripple_app/paths/Pathfinder.cpp b/src/ripple_app/paths/Pathfinder.cpp index 7d149a9c1d..b30660029d 100644 --- a/src/ripple_app/paths/Pathfinder.cpp +++ b/src/ripple_app/paths/Pathfinder.cpp @@ -705,7 +705,9 @@ void Pathfinder::addLink( if (!candidates.empty()) { std::sort (candidates.begin(), candidates.end(), - BIND_TYPE(candCmp, mLedger->getLedgerSeq(), P_1, P_2)); + std::bind(candCmp, mLedger->getLedgerSeq(), + std::placeholders::_1, + std::placeholders::_2)); int count = candidates.size(); if ((count > 10) && (uEndAccount != mSrcAccountID)) // allow more paths from source diff --git a/src/ripple_app/peers/PeerSet.cpp b/src/ripple_app/peers/PeerSet.cpp index 582adb1fe4..c99534fe71 100644 --- a/src/ripple_app/peers/PeerSet.cpp +++ b/src/ripple_app/peers/PeerSet.cpp @@ -114,7 +114,8 @@ void PeerSet::TimerEntry (boost::weak_ptr wptr, const boost::system::er if (ptr->mTxnData) { getApp().getJobQueue ().addJob (jtTXN_DATA, "timerEntryTxn", - BIND_TYPE (&PeerSet::TimerJobEntry, P_1, ptr)); + std::bind (&PeerSet::TimerJobEntry, std::placeholders::_1, + ptr)); } else { @@ -127,7 +128,8 @@ void PeerSet::TimerEntry (boost::weak_ptr wptr, const boost::system::er } else getApp().getJobQueue ().addJob (jtLEDGER_DATA, "timerEntryLgr", - BIND_TYPE (&PeerSet::TimerJobEntry, P_1, ptr)); + std::bind (&PeerSet::TimerJobEntry, std::placeholders::_1, + ptr)); } } } @@ -180,7 +182,7 @@ std::size_t PeerSet::takePeerSetFrom (const PeerSet& s) mPeers.insert (std::make_pair (p.first, 0)); ++ret; } - + return ret; } diff --git a/src/ripple_app/peers/UniqueNodeList.cpp b/src/ripple_app/peers/UniqueNodeList.cpp index 385ffd7b02..93fb7a7fc6 100644 --- a/src/ripple_app/peers/UniqueNodeList.cpp +++ b/src/ripple_app/peers/UniqueNodeList.cpp @@ -162,12 +162,12 @@ public: if (timer == m_scoreTimer) { getApp().getJobQueue ().addJob (jtUNL, "UNL.score", - BIND_TYPE (&UniqueNodeListImp::doScore, this)); + std::bind (&UniqueNodeListImp::doScore, this)); } else if (timer == m_fetchTimer) { getApp().getJobQueue ().addJob (jtUNL, "UNL.fetch", - BIND_TYPE (&UniqueNodeListImp::doFetch, this)); + std::bind (&UniqueNodeListImp::doFetch, this)); } } @@ -572,7 +572,10 @@ public: getConfig ().VALIDATORS_URI, VALIDATORS_FILE_BYTES_MAX, boost::posix_time::seconds (VALIDATORS_FETCH_SECONDS), - BIND_TYPE (&UniqueNodeListImp::validatorsResponse, this, P_1, P_2, P_3)); + std::bind (&UniqueNodeListImp::validatorsResponse, this, + std::placeholders::_1, + std::placeholders::_2, + std::placeholders::_3)); } } @@ -1412,7 +1415,9 @@ private: NODE_FILE_PATH, NODE_FILE_BYTES_MAX, boost::posix_time::seconds (NODE_FETCH_SECONDS), - BIND_TYPE (&UniqueNodeListImp::responseFetch, this, strDomain, P_1, P_2, P_3)); + std::bind (&UniqueNodeListImp::responseFetch, this, strDomain, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } //-------------------------------------------------------------------------- @@ -1451,7 +1456,10 @@ private: strPath, NODE_FILE_BYTES_MAX, boost::posix_time::seconds (NODE_FETCH_SECONDS), - BIND_TYPE (&UniqueNodeListImp::responseValidators, this, strValidatorsUrl, naNodePublic, secSite, strDomain, P_1, P_2, P_3)); + std::bind (&UniqueNodeListImp::responseValidators, this, + strValidatorsUrl, naNodePublic, secSite, strDomain, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } else { @@ -1485,7 +1493,9 @@ private: strPath, NODE_FILE_BYTES_MAX, boost::posix_time::seconds (NODE_FETCH_SECONDS), - BIND_TYPE (&UniqueNodeListImp::responseIps, this, strDomain, naNodePublic, P_1, P_2, P_3)); + std::bind (&UniqueNodeListImp::responseIps, this, strDomain, + naNodePublic, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); } else { diff --git a/src/ripple_app/rpc/RPCHandler.cpp b/src/ripple_app/rpc/RPCHandler.cpp index 8de0f7e122..2c25db3deb 100644 --- a/src/ripple_app/rpc/RPCHandler.cpp +++ b/src/ripple_app/rpc/RPCHandler.cpp @@ -181,7 +181,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resourc { "unsubscribe", &RPCHandler::doUnsubscribe, false, optNone }, }; - int i = NUMBER (commandsA); + int i = RIPPLE_ARRAYSIZE (commandsA); while (i-- && strCommand != commandsA[i].pCommand) ; diff --git a/src/ripple_app/shamap/SHAMapSync.cpp b/src/ripple_app/shamap/SHAMapSync.cpp index 66f573d245..6770ac4b6b 100644 --- a/src/ripple_app/shamap/SHAMapSync.cpp +++ b/src/ripple_app/shamap/SHAMapSync.cpp @@ -628,7 +628,9 @@ static void addFPtoList (std::list& list, const uint25 std::list SHAMap::getFetchPack (SHAMap* have, bool includeLeaves, int max) { std::list ret; - getFetchPack (have, includeLeaves, max, BIND_TYPE (addFPtoList, boost::ref (ret), P_1, P_2)); + getFetchPack (have, includeLeaves, max, + std::bind (addFPtoList, boost::ref (ret), + std::placeholders::_1, std::placeholders::_2)); return ret; } diff --git a/src/ripple_app/shamap/SHAMapSyncFilters.cpp b/src/ripple_app/shamap/SHAMapSyncFilters.cpp index 904698ed70..817265cbb0 100644 --- a/src/ripple_app/shamap/SHAMapSyncFilters.cpp +++ b/src/ripple_app/shamap/SHAMapSyncFilters.cpp @@ -43,8 +43,11 @@ void ConsensusTransSetSF::gotNode (bool fromFilter, const SHAMapNode& id, uint25 SerializerIterator sit (s); SerializedTransaction::pointer stx = boost::make_shared (boost::ref (sit)); assert (stx->getTransactionID () == nodeHash); - getApp().getJobQueue ().addJob (jtTRANSACTION, "TXS->TXN", - BIND_TYPE (&NetworkOPs::submitTransaction, &getApp().getOPs (), P_1, stx, NetworkOPs::stCallback ())); + getApp().getJobQueue ().addJob ( + jtTRANSACTION, "TXS->TXN", + std::bind (&NetworkOPs::submitTransaction, &getApp().getOPs (), + std::placeholders::_1, stx, + NetworkOPs::stCallback ())); } catch (...) { diff --git a/src/ripple_app/transactors/CreateOfferDirect.cpp b/src/ripple_app/transactors/CreateOfferDirect.cpp index 1684f21251..6b0d9d8060 100644 --- a/src/ripple_app/transactors/CreateOfferDirect.cpp +++ b/src/ripple_app/transactors/CreateOfferDirect.cpp @@ -193,7 +193,7 @@ std::pair DirectOfferCreateTransactor::crossOffers ( core::Book book ( core::AssetRef ( - saTakerPays.getCurrency(), saTakerPays.getIssuer()), + saTakerPays.getCurrency(), saTakerPays.getIssuer()), core::AssetRef ( saTakerGets.getCurrency(), saTakerGets.getIssuer())); @@ -203,7 +203,7 @@ std::pair DirectOfferCreateTransactor::crossOffers ( auto const result (process_order ( view, book, mTxnAccountID, - core::Amounts (saTakerPays, saTakerGets), cross_flow, + core::Amounts (saTakerPays, saTakerGets), cross_flow, core::Taker::Options (mTxn.getFlags()), mEngine->getLedger ()->getParentCloseTimeNC (), m_journal)); @@ -211,14 +211,14 @@ std::pair DirectOfferCreateTransactor::crossOffers ( core::Amounts const funds ( view.accountFunds (mTxnAccountID, saTakerPays), view.accountFunds (mTxnAccountID, saTakerGets)); - + if (m_journal.debug) m_journal.debug << " cross_flow: " << cross_flow.in << ", " << cross_flow.out; - + if (m_journal.debug) m_journal.debug << " balances: " << funds.in << ", " << funds.out; - saTakerPaid = cross_flow.in; + saTakerPaid = cross_flow.in; saTakerGot = cross_flow.out; if (m_journal.debug) m_journal.debug << @@ -232,7 +232,7 @@ TER DirectOfferCreateTransactor::doApply () { if (m_journal.debug) m_journal.debug << "OfferCreate> " << mTxn.getJson (0); - + std::uint32_t const uTxFlags = mTxn.getFlags (); bool const bPassive = is_bit_set (uTxFlags, tfPassive); @@ -427,7 +427,7 @@ TER DirectOfferCreateTransactor::doApply () ? terNO_ACCOUNT : tecNO_ISSUER; } - + if (is_bit_set (sleTakerPays->getFieldU32 (sfFlags), lsfRequireAuth)) { SLE::pointer sleRippleState (mEngine->entryCache ( @@ -593,7 +593,8 @@ TER DirectOfferCreateTransactor::doApply () // Add offer to owner's directory. terResult = view.dirAdd (uOwnerNode, Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex, - BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, mTxnAccountID)); + std::bind (&Ledger::ownerDirDescriber, std::placeholders::_1, + std::placeholders::_2, mTxnAccountID)); if (tesSUCCESS == terResult) { @@ -618,9 +619,10 @@ TER DirectOfferCreateTransactor::doApply () // Add offer to order book. terResult = view.dirAdd (uBookNode, uDirectory, uLedgerIndex, - BIND_TYPE (&Ledger::qualityDirDescriber, P_1, P_2, - saTakerPays.getCurrency (), uPaysIssuerID, - saTakerGets.getCurrency (), uGetsIssuerID, uRate)); + std::bind (&Ledger::qualityDirDescriber, std::placeholders::_1, + std::placeholders::_2, saTakerPays.getCurrency (), + uPaysIssuerID, saTakerGets.getCurrency (), + uGetsIssuerID, uRate)); } if (tesSUCCESS == terResult) @@ -685,4 +687,3 @@ TER DirectOfferCreateTransactor::doApply () } } - diff --git a/src/ripple_app/transactors/CreateOfferLegacy.cpp b/src/ripple_app/transactors/CreateOfferLegacy.cpp index be773f6a47..dfdd17eff4 100644 --- a/src/ripple_app/transactors/CreateOfferLegacy.cpp +++ b/src/ripple_app/transactors/CreateOfferLegacy.cpp @@ -1030,7 +1030,8 @@ TER ClassicOfferCreateTransactor::doApply () // Add offer to owner's directory. terResult = lesActive.dirAdd (uOwnerNode, Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex, - BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, mTxnAccountID)); + std::bind (&Ledger::ownerDirDescriber, std::placeholders::_1, + std::placeholders::_2, mTxnAccountID)); if (tesSUCCESS == terResult) @@ -1055,9 +1056,10 @@ TER ClassicOfferCreateTransactor::doApply () // Add offer to order book. terResult = lesActive.dirAdd (uBookNode, uDirectory, uLedgerIndex, - BIND_TYPE (&Ledger::qualityDirDescriber, P_1, P_2, - saTakerPays.getCurrency (), uPaysIssuerID, - saTakerGets.getCurrency (), uGetsIssuerID, uRate)); + std::bind (&Ledger::qualityDirDescriber, std::placeholders::_1, + std::placeholders::_2, saTakerPays.getCurrency (), + uPaysIssuerID, saTakerGets.getCurrency (), uGetsIssuerID, + uRate)); } if (tesSUCCESS == terResult) diff --git a/src/ripple_app/tx/TransactionAcquire.cpp b/src/ripple_app/tx/TransactionAcquire.cpp index 0755ff20f4..849d777b08 100644 --- a/src/ripple_app/tx/TransactionAcquire.cpp +++ b/src/ripple_app/tx/TransactionAcquire.cpp @@ -75,7 +75,7 @@ void TransactionAcquire::done () map = mMap; } - getApp().getJobQueue().addJob (jtTXN_DATA, "completeAcquire", BIND_TYPE (&TACompletionHandler, mHash, map)); + getApp().getJobQueue().addJob (jtTXN_DATA, "completeAcquire", std::bind (&TACompletionHandler, mHash, map)); } void TransactionAcquire::onTimer (bool progress, ScopedLockType& psl) diff --git a/src/ripple_app/websocket/WSServerHandler.h b/src/ripple_app/websocket/WSServerHandler.h index e9d2f3bbb8..8e284934f7 100644 --- a/src/ripple_app/websocket/WSServerHandler.h +++ b/src/ripple_app/websocket/WSServerHandler.h @@ -121,13 +121,13 @@ public: void send (connection_ptr cpClient, message_ptr mpMessage) { - cpClient->get_strand ().post (BIND_TYPE ( + cpClient->get_strand ().post (std::bind ( &WSServerHandler::ssend, cpClient, mpMessage)); } void send (connection_ptr cpClient, const std::string& strMessage, bool broadcast) { - cpClient->get_strand ().post (BIND_TYPE ( + cpClient->get_strand ().post (std::bind ( &WSServerHandler::ssendb, cpClient, strMessage, broadcast)); } @@ -276,7 +276,7 @@ public: // Must be done without holding the websocket send lock getApp().getJobQueue ().addJob (jtCLIENT, "WSClient::destroy", - BIND_TYPE (&WSConnectionType ::destroy, ptr)); + std::bind (&WSConnectionType ::destroy, ptr)); } void on_message (connection_ptr cpClient, message_ptr mpMessage) @@ -310,7 +310,8 @@ public: if (bRunQ) getApp().getJobQueue ().addJob (jtCLIENT, "WSClient::command", - BIND_TYPE (&WSServerHandler::do_messages, this, P_1, cpClient)); + std::bind (&WSServerHandler::do_messages, + this, std::placeholders::_1, cpClient)); } void do_messages (Job& job, connection_ptr cpClient) @@ -345,8 +346,10 @@ public: } if (ptr->checkMessage ()) - getApp().getJobQueue ().addJob (jtCLIENT, "WSClient::more", - BIND_TYPE (&WSServerHandler::do_messages, this, P_1, cpClient)); + getApp().getJobQueue ().addJob ( + jtCLIENT, "WSClient::more", + std::bind (&WSServerHandler::do_messages, this, + std::placeholders::_1, cpClient)); } bool do_message (Job& job, const connection_ptr& cpClient, const wsc_ptr& conn, const message_ptr& mpMessage) diff --git a/src/ripple_basics/utility/PlatformMacros.h b/src/ripple_basics/utility/PlatformMacros.h index 73445e0ce8..2c164a6ca0 100644 --- a/src/ripple_basics/utility/PlatformMacros.h +++ b/src/ripple_basics/utility/PlatformMacros.h @@ -25,28 +25,23 @@ namespace ripple { -#define BIND_TYPE std::bind -#define P_1 std::placeholders::_1 -#define P_2 std::placeholders::_2 -#define P_3 std::placeholders::_3 -#define P_4 std::placeholders::_4 - template inline std::enable_if_t< - (std::is_integral::value || std::is_enum::value) && - (std::is_integral::value || std::is_enum::value), + (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) { - return (x & 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 NUMBER(x) (sizeof(x)/sizeof((x)[0])) -#define is_bit_set(x,y) (!!((x) & (y))) +#define RIPPLE_ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0])) } // ripple diff --git a/src/ripple_data/protocol/TER.cpp b/src/ripple_data/protocol/TER.cpp index 1e80220ca6..4d5fefb959 100644 --- a/src/ripple_data/protocol/TER.cpp +++ b/src/ripple_data/protocol/TER.cpp @@ -123,7 +123,7 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman) { tesSUCCESS, "tesSUCCESS", "The transaction was applied." }, }; - int iIndex = NUMBER (transResultInfoA); + int iIndex = RIPPLE_ARRAYSIZE (transResultInfoA); while (iIndex-- && transResultInfoA[iIndex].terCode != terCode) ; diff --git a/src/ripple_net/basics/HTTPClient.cpp b/src/ripple_net/basics/HTTPClient.cpp index 00c63fb890..298d4e5bd6 100644 --- a/src/ripple_net/basics/HTTPClient.cpp +++ b/src/ripple_net/basics/HTTPClient.cpp @@ -151,7 +151,8 @@ public: request ( bSSL, deqSites, - BIND_TYPE (&HTTPClientImp::makeGet, shared_from_this (), strPath, P_1, P_2), + std::bind (&HTTPClientImp::makeGet, shared_from_this (), strPath, + std::placeholders::_1, std::placeholders::_2), timeout, complete); } @@ -406,7 +407,7 @@ public: // no body wanted or available invokeComplete (ecResult, mStatus); } - else if (mBody.size () >= mResponseMax) + else if (mBody.size () >= mResponseMax) { // we got the whole thing invokeComplete (ecResult, mStatus, mBody); @@ -611,9 +612,10 @@ void HTTPClient::sendSMS (boost::asio::io_service& io_service, const std::string new HTTPClientImp (io_service, iPort, maxClientHeaderBytes)); client->get (bSSL, deqSites, strURI, boost::posix_time::seconds (smsTimeoutSeconds), - BIND_TYPE (&HTTPClientImp::onSMSResponse, P_1, P_2, P_3)); + std::bind (&HTTPClientImp::onSMSResponse, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } } } // ripple - diff --git a/src/ripple_net/rpc/RPCCall.cpp b/src/ripple_net/rpc/RPCCall.cpp index 55d357986a..5d6fcc8f08 100644 --- a/src/ripple_net/rpc/RPCCall.cpp +++ b/src/ripple_net/rpc/RPCCall.cpp @@ -857,7 +857,7 @@ public: { "unsubscribe", &RPCParser::parseEvented, -1, -1 }, }; - int i = NUMBER (commandsA); + int i = RIPPLE_ARRAYSIZE (commandsA); while (i-- && strMethod != commandsA[i].pCommand) ; @@ -1008,7 +1008,8 @@ int RPCCall::fromCommandLine (const std::vector& vCmd) ? jvRequest["method"].asString () : vCmd[0], jvParams, // Parsed, execute. false, - BIND_TYPE (RPCCallImp::callRPCHandler, &jvOutput, P_1)); + std::bind (RPCCallImp::callRPCHandler, &jvOutput, + std::placeholders::_1)); isService.run (); // This blocks until there is no more outstanding async calls. @@ -1105,15 +1106,17 @@ void RPCCall::fromNetwork ( io_service, strIp, iPort, - BIND_TYPE ( + std::bind ( &RPCCallImp::onRequest, strMethod, jvParams, mapRequestHeaders, - strPath, P_1, P_2), + strPath, std::placeholders::_1, std::placeholders::_2), RPC_REPLY_MAX_BYTES, boost::posix_time::seconds (RPC_NOTIFY_SECONDS), - BIND_TYPE (&RPCCallImp::onResponse, callbackFuncP, P_1, P_2, P_3)); + std::bind (&RPCCallImp::onResponse, callbackFuncP, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } } // ripple diff --git a/src/ripple_net/rpc/RPCSub.cpp b/src/ripple_net/rpc/RPCSub.cpp index c5037c0af1..eb1ef52617 100644 --- a/src/ripple_net/rpc/RPCSub.cpp +++ b/src/ripple_net/rpc/RPCSub.cpp @@ -94,7 +94,7 @@ public: WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork start"; m_jobQueue.addJob ( - jtCLIENT, "RPCSub::sendThread", BIND_TYPE (&RPCSubImp::sendThread, this)); + jtCLIENT, "RPCSub::sendThread", std::bind (&RPCSubImp::sendThread, this)); } } diff --git a/src/ripple_overlay/impl/PeerImp.h b/src/ripple_overlay/impl/PeerImp.h index e15199ef24..c47f78a50b 100644 --- a/src/ripple_overlay/impl/PeerImp.h +++ b/src/ripple_overlay/impl/PeerImp.h @@ -55,7 +55,7 @@ std::ostream& operator<< (std::ostream& os, PeerImp const* peer); //------------------------------------------------------------------------------ -class PeerImp +class PeerImp : public Peer , public boost::enable_shared_from_this , private beast::LeakChecked @@ -239,7 +239,7 @@ public: , m_was_canceled (false) { } - + /** New outgoing peer @note Construction of outbound peers is a two step process: a second call is needed (to connect or accept) but we cannot make it from @@ -276,7 +276,7 @@ public: , m_was_canceled (false) { } - + virtual ~PeerImp () { @@ -318,7 +318,7 @@ public: { if (! m_strand.running_in_this_thread ()) { - m_strand.post (BIND_TYPE (&PeerImp::detach, + m_strand.post (std::bind (&PeerImp::detach, shared_from_this (), rsn, graceful)); return; } @@ -333,7 +333,7 @@ public: m_peerFinder.on_cancel (m_slot); else m_peerFinder.on_closed (m_slot); - + if (m_state == stateActive) m_overlay.onPeerDisconnect (shared_from_this ()); @@ -458,7 +458,7 @@ public: { if (!onStrand) { - m_strand.post (BIND_TYPE ( + m_strand.post (std::bind ( &Peer::sendPacket, shared_from_this (), packet, true)); return; } @@ -743,7 +743,7 @@ private: Application::ScopedLockType lock (getApp ().getMasterLock ()); detach ("hrb"); } - + return; } @@ -1043,7 +1043,7 @@ private: case protocol::mtGET_LEDGER: { event->reName ("Peer::getledger"); - boost::shared_ptr msg ( + boost::shared_ptr msg ( boost::make_shared ()); if (msg->ParseFromArray (&m_readBuffer[Message::kHeaderBytes], @@ -1298,7 +1298,7 @@ private: @return true if successful, false otherwise. */ bool sendHello () - { + { if (!calculateSessionCookie()) return false; @@ -1535,8 +1535,9 @@ private: else getApp().getJobQueue ().addJob (jtTRANSACTION, "recvTransaction->checkTransaction", - BIND_TYPE ( - &PeerImp::checkTransaction, P_1, flags, stx, + std::bind ( + &PeerImp::checkTransaction, std::placeholders::_1, + flags, stx, boost::weak_ptr (shared_from_this ()))); #ifndef TRUST_NETWORK @@ -1588,9 +1589,9 @@ private: getApp().getJobQueue ().addJob ( isTrusted ? jtVALIDATION_t : jtVALIDATION_ut, "recvValidation->checkValidation", - BIND_TYPE ( - &PeerImp::checkValidation, P_1, &m_overlay, val, - isTrusted, m_clusterNode, packet, + std::bind ( + &PeerImp::checkValidation, std::placeholders::_1, + &m_overlay, val, isTrusted, m_clusterNode, packet, boost::weak_ptr (shared_from_this ()))); } else @@ -1690,7 +1691,7 @@ private: endpoint.address = m_remoteAddress.at_port ( tm.ipv4().ipv4port ()); } - + endpoints.push_back (endpoint); } @@ -1817,7 +1818,7 @@ private: { packet.set_type (protocol::TMPing::ptPONG); sendPacket (boost::make_shared (packet, protocol::mtPING), true); - } + } } void recvErrorMessage (protocol::TMErrorMsg& packet) @@ -1930,7 +1931,7 @@ private: // got data for a candidate transaction set getApp().getJobQueue().addJob (jtTXN_DATA, "recvPeerData", - BIND_TYPE (&PeerImp::peerTXData, P_1, + std::bind (&PeerImp::peerTXData, std::placeholders::_1, boost::weak_ptr (shared_from_this ()), hash, packet_ptr, m_journal)); @@ -2067,20 +2068,21 @@ private: " proposal from " << m_shortId; uint256 consensusLCL; - + { Application::ScopedLockType lock (getApp ().getMasterLock ()); consensusLCL = getApp().getOPs ().getConsensusLCL (); } - + LedgerProposal::pointer proposal = boost::make_shared ( prevLedger.isNonZero () ? prevLedger : consensusLCL, set.proposeseq (), proposeHash, set.closetime (), signerPublic, suppression); getApp().getJobQueue ().addJob (isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut, - "recvPropose->checkPropose", BIND_TYPE ( - &PeerImp::checkPropose, P_1, &m_overlay, packet, proposal, consensusLCL, - m_nodePublicKey, boost::weak_ptr (shared_from_this ()), m_clusterNode)); + "recvPropose->checkPropose", std::bind ( + &PeerImp::checkPropose, std::placeholders::_1, &m_overlay, + packet, proposal, consensusLCL, m_nodePublicKey, + boost::weak_ptr (shared_from_this ()), m_clusterNode)); } void recvHaveTxSet (protocol::TMHaveTransactionSet& packet) @@ -2105,7 +2107,7 @@ private: { Application::ScopedLockType lock (getApp ().getMasterLock ()); - + if (!getApp().getOPs ().hasTXSet (shared_from_this (), hash, packet.status ())) charge (Resource::feeUnwantedData); } @@ -2179,7 +2181,8 @@ private: getApp().getJobQueue ().addJob ( jtPROOFWORK, "recvProof->doProof", - BIND_TYPE (&PeerImp::doProofOfWork, P_1, boost::weak_ptr (shared_from_this ()), pow)); + std::bind (&PeerImp::doProofOfWork, std::placeholders::_1, + boost::weak_ptr (shared_from_this ()), pow)); #endif return; @@ -2201,7 +2204,7 @@ private: m_recentLedgers.push_back (hash); } - + void getLedger (protocol::TMGetLedger& packet) { SHAMap::pointer map; @@ -2216,7 +2219,7 @@ private: if (packet.itype () == protocol::liTS_CANDIDATE) { // Request is for a transaction candidate set - m_journal.trace << "Received request for TX candidate set data " + m_journal.trace << "Received request for TX candidate set data " << to_string (this); if ((!packet.has_ledgerhash () || packet.ledgerhash ().size () != 32)) @@ -2281,7 +2284,7 @@ private: return; } - m_journal.error << "We do not have the map our peer wants " + m_journal.error << "We do not have the map our peer wants " << to_string (this); charge (Resource::feeInvalidRequest); @@ -2525,28 +2528,28 @@ private: } Message::pointer oPacket = boost::make_shared (reply, protocol::mtLEDGER_DATA); - sendPacket (oPacket, false); + sendPacket (oPacket, false); } - + // This is dispatched by the job queue static void - sGetLedger (boost::weak_ptr wPeer, + sGetLedger (boost::weak_ptr wPeer, boost::shared_ptr packet) { boost::shared_ptr peer = wPeer.lock (); - + if (peer) peer->getLedger (*packet); } - + void addTxSet (uint256 const& hash) { boost::mutex::scoped_lock sl(m_recentLock); if(std::find (m_recentTxSets.begin (), m_recentTxSets.end (), hash) != m_recentTxSets.end ()) return; - + if (m_recentTxSets.size () == 128) m_recentTxSets.pop_front (); @@ -2577,7 +2580,7 @@ private: memcpy (hash.begin (), packet->ledgerhash ().data (), 32); getApp().getJobQueue ().addJob (jtPACK, "MakeFetchPack", - BIND_TYPE (&NetworkOPs::makeFetchPack, &getApp().getOPs (), P_1, + std::bind (&NetworkOPs::makeFetchPack, &getApp().getOPs (), std::placeholders::_1, boost::weak_ptr (shared_from_this ()), packet, hash, UptimeTimer::getInstance ().getElapsedSeconds ())); } @@ -2769,7 +2772,7 @@ private: { pPeers->foreach (send_if_not ( boost::make_shared (*packet, protocol::mtVALIDATION), - peer_in_set(peers))); + peer_in_set(peers))); } } diff --git a/src/ripple_rpc/handlers/AccountOffers.cpp b/src/ripple_rpc/handlers/AccountOffers.cpp index 86cb0f05f7..2f5893a890 100644 --- a/src/ripple_rpc/handlers/AccountOffers.cpp +++ b/src/ripple_rpc/handlers/AccountOffers.cpp @@ -73,7 +73,9 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& l return rpcError (rpcACT_NOT_FOUND); Json::Value& jvsOffers = (jvResult[jss::offers] = Json::arrayValue); - lpLedger->visitAccountItems (raAccount.getAccountID (), BIND_TYPE (&offerAdder, boost::ref (jvsOffers), P_1)); + lpLedger->visitAccountItems (raAccount.getAccountID (), + std::bind (&offerAdder, boost::ref (jvsOffers), + std::placeholders::_1)); loadType = Resource::feeMediumBurdenRPC;