diff --git a/src/CanonicalTXSet.cpp b/src/CanonicalTXSet.cpp index e3af1e4870..8b536d354a 100644 --- a/src/CanonicalTXSet.cpp +++ b/src/CanonicalTXSet.cpp @@ -37,7 +37,7 @@ bool CanonicalTXKey::operator>=(const CanonicalTXKey& key)const return mTXid >= key.mTXid; } -void CanonicalTXSet::push_back(const SerializedTransaction::pointer& txn) +void CanonicalTXSet::push_back(SerializedTransaction::ref txn) { uint256 effectiveAccount = mSetHash; effectiveAccount ^= txn->getSourceAccount().getAccountID().to256(); diff --git a/src/CanonicalTXSet.h b/src/CanonicalTXSet.h index 3315625a3e..c75fb6b1b1 100644 --- a/src/CanonicalTXSet.h +++ b/src/CanonicalTXSet.h @@ -38,7 +38,7 @@ protected: public: CanonicalTXSet(const uint256& lclHash) : mSetHash(lclHash) { ; } - void push_back(const SerializedTransaction::pointer& txn); + void push_back(SerializedTransaction::ref txn); iterator erase(const iterator& it); iterator begin() { return mMap.begin(); } diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 2bd8e57449..afaf29cfe8 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -993,7 +993,7 @@ void LedgerConsensus::playbackProposals() } } -void LedgerConsensus::applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn, +void LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTransaction::ref txn, Ledger::ref ledger, CanonicalTXSet& failedTransactions, bool openLedger) { TransactionEngineParams parms = openLedger ? tapOPEN_LEDGER : tapNONE; diff --git a/src/LedgerConsensus.h b/src/LedgerConsensus.h index 23582e071c..2387307f6b 100644 --- a/src/LedgerConsensus.h +++ b/src/LedgerConsensus.h @@ -134,7 +134,7 @@ protected: void sendHaveTxSet(const uint256& set, bool direct); void applyTransactions(SHAMap::ref transactionSet, Ledger::ref targetLedger, Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr); - void applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn, + void applyTransaction(TransactionEngine& engine, SerializedTransaction::ref txn, Ledger::ref targetLedger, CanonicalTXSet& failedTransactions, bool openLgr); uint32 roundCloseTime(uint32 closeTime); diff --git a/src/LedgerEntrySet.h b/src/LedgerEntrySet.h index 2558f12881..aaafd523b1 100644 --- a/src/LedgerEntrySet.h +++ b/src/LedgerEntrySet.h @@ -65,8 +65,8 @@ public: void init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID); void clear(); - Ledger::pointer& getLedger() { return mLedger; } - const Ledger::pointer& getLedgerRef() const { return mLedger; } + Ledger::pointer& getLedger() { return mLedger; } + Ledger::ref getLedgerRef() const { return mLedger; } // basic entry functions SLE::pointer getEntry(const uint256& index, LedgerEntryAction&); diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index a2e800bc4d..09239e69f1 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -638,7 +638,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo theApp->getConnectionPool().relayMessage(NULL, packet); } -int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger) +int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger) { cLog(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq(); cLog(lsINFO) << " LCL is " << closingLedger->getParentHash(); diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index cd2e8bede0..2c5475c93a 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -180,7 +180,7 @@ public: void checkState(const boost::system::error_code& result); void switchLastClosedLedger(Ledger::pointer newLedger, bool duringConsensus); // Used for the "jump" case bool checkLastClosedLedger(const std::vector&, uint256& networkClosed); - int beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger); + int beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger); void endConsensus(bool correctLCL); void setStandAlone() { setMode(omFULL); } void setStateTimer(); diff --git a/src/RippleCalc.cpp b/src/RippleCalc.cpp index d87758a4a4..5241ad8241 100644 --- a/src/RippleCalc.cpp +++ b/src/RippleCalc.cpp @@ -27,7 +27,7 @@ std::size_t hash_value(const aciSource& asValue) // <-- uOfferIndex : 0=end of list. TER RippleCalc::calcNodeAdvance( const unsigned int uIndex, // 0 < uIndex < uLast - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality, const bool bReverse) { @@ -267,7 +267,7 @@ TER RippleCalc::calcNodeAdvance( // Continue process till request is satisified while we the rate does not increase past the initial rate. TER RippleCalc::calcNodeDeliverRev( const unsigned int uIndex, // 0 < uIndex < uLast - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality, const uint160& uOutAccountID, // --> Output owner's account. const STAmount& saOutReq, // --> Funds wanted. @@ -459,7 +459,7 @@ TER RippleCalc::calcNodeDeliverRev( // Goal: Make progress consuming the offer. TER RippleCalc::calcNodeDeliverFwd( const unsigned int uIndex, // 0 < uIndex < uLast - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality, const uint160& uInAccountID, // --> Input owner's account. const STAmount& saInFunds, // --> Funds available for delivery and fees. @@ -610,7 +610,7 @@ TER RippleCalc::calcNodeDeliverFwd( // Called to drive from the last offer node in a chain. TER RippleCalc::calcNodeOfferRev( const unsigned int uIndex, // 0 < uIndex < uLast - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality) { TER terResult; @@ -650,7 +650,7 @@ TER RippleCalc::calcNodeOfferRev( // - Deliver is set without transfer fees. TER RippleCalc::calcNodeOfferFwd( const unsigned int uIndex, // 0 < uIndex < uLast - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality ) { @@ -789,7 +789,7 @@ void RippleCalc::calcNodeRipple( // Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver from saCur... // <-- tesSUCCESS or tepPATH_DRY -TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality) +TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality) { TER terResult = tesSUCCESS; const unsigned int uLast = pspCur->vpnNodes.size() - 1; @@ -1100,7 +1100,7 @@ TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, const PathState::p // - Output to next node is computed as input minus quality or transfer fee. TER RippleCalc::calcNodeAccountFwd( const unsigned int uIndex, // 0 <= uIndex <= uLast - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality) { TER terResult = tesSUCCESS; @@ -1362,7 +1362,7 @@ TER RippleCalc::calcNodeAccountFwd( } // Return true, iff lhs has less priority than rhs. -bool PathState::lessPriority(const PathState::pointer& lhs, const PathState::pointer& rhs) +bool PathState::lessPriority(PathState::ref lhs, PathState::ref rhs) { if (lhs->uQuality != rhs->uQuality) return lhs->uQuality > rhs->uQuality; // Bigger is worse. @@ -1713,7 +1713,7 @@ Json::Value PathState::getJson() const return jvPathState; } -TER RippleCalc::calcNodeFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality) +TER RippleCalc::calcNodeFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality) { const PaymentNode& pnCur = pspCur->vpnNodes[uIndex]; const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount); @@ -1743,7 +1743,7 @@ TER RippleCalc::calcNodeFwd(const unsigned int uIndex, const PathState::pointer& // --> [all]saWanted.mCurrency // --> [all]saAccount // <-> [0]saWanted.mAmount : --> limit, <-- actual -TER RippleCalc::calcNodeRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality) +TER RippleCalc::calcNodeRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality) { PaymentNode& pnCur = pspCur->vpnNodes[uIndex]; const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount); @@ -1785,7 +1785,7 @@ TER RippleCalc::calcNodeRev(const unsigned int uIndex, const PathState::pointer& // Calculate the next increment of a path. // The increment is what can satisfy a portion or all of the requested output at the best quality. // <-- pspCur->uQuality -void RippleCalc::pathNext(const PathState::pointer& pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent) +void RippleCalc::pathNext(PathState::ref pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent) { // The next state is what is available in preference order. // This is calculated when referenced accounts changed. diff --git a/src/RippleCalc.h b/src/RippleCalc.h index 14d07f4aad..b212c162e3 100644 --- a/src/RippleCalc.h +++ b/src/RippleCalc.h @@ -65,13 +65,14 @@ extern std::size_t hash_value(const aciSource& asValue); class PathState { protected: - const Ledger::pointer& mLedger; + Ledger::ref mLedger; TER pushNode(const int iType, const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); TER pushImply(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID); public: - typedef boost::shared_ptr pointer; + typedef boost::shared_ptr pointer; + typedef const boost::shared_ptr& ref; TER terStatus; std::vector vpnNodes; @@ -123,7 +124,7 @@ public: return boost::make_shared(iIndex, lesSource, spSourcePath, uReceiverID, uSenderID, saSend, saSendMax); } - static bool lessPriority(const PathState::pointer& lhs, const PathState::pointer& rhs); + static bool lessPriority(PathState::ref lhs, PathState::ref rhs); }; class RippleCalc @@ -139,18 +140,18 @@ public: boost::unordered_set musUnfundedFound; // Offers that were found unfunded. PathState::pointer pathCreate(const STPath& spPath); - void pathNext(const PathState::pointer& pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent); - TER calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeOfferRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeOfferFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeAccountFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality); - TER calcNodeAdvance(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality, const bool bReverse); + void pathNext(PathState::ref pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent); + TER calcNode(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeOfferRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeOfferFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeAccountRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeAccountFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality); + TER calcNodeAdvance(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality, const bool bReverse); TER calcNodeDeliverRev( const unsigned int uIndex, - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality, const uint160& uOutAccountID, const STAmount& saOutReq, @@ -158,7 +159,7 @@ public: TER calcNodeDeliverFwd( const unsigned int uIndex, - const PathState::pointer& pspCur, + PathState::ref pspCur, const bool bMultiQuality, const uint160& uInAccountID, const STAmount& saInFunds, diff --git a/src/RippleLines.cpp b/src/RippleLines.cpp index a9808780b7..fece4f4291 100644 --- a/src/RippleLines.cpp +++ b/src/RippleLines.cpp @@ -7,9 +7,9 @@ SETUP_LOG(); -RippleLines::RippleLines(const uint160& accountID, Ledger::pointer ledger) +RippleLines::RippleLines(const uint160& accountID, Ledger::ref ledger) { - fillLines(accountID,ledger); + fillLines(accountID, ledger); } void RippleLines::printRippleLines() @@ -25,7 +25,7 @@ RippleLines::RippleLines(const uint160& accountID ) fillLines(accountID,theApp->getMasterLedger().getCurrentLedger()); } -void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger) +void RippleLines::fillLines(const uint160& accountID, Ledger::ref ledger) { uint256 rootIndex = Ledger::getOwnerDirIndex(accountID); uint256 currentIndex = rootIndex; diff --git a/src/RippleLines.h b/src/RippleLines.h index 00373838dd..5ddd47e04d 100644 --- a/src/RippleLines.h +++ b/src/RippleLines.h @@ -9,12 +9,12 @@ It provides a vector so you to easily iterate through them class RippleLines { std::vector mLines; - void fillLines(const uint160& accountID, Ledger::pointer ledger); + void fillLines(const uint160& accountID, Ledger::ref ledger); public: - RippleLines(const uint160& accountID, Ledger::pointer ledger); + RippleLines(const uint160& accountID, Ledger::ref ledger); RippleLines(const uint160& accountID ); // looks in the current ledger - std::vector& getLines(){ return(mLines); } + std::vector& getLines() { return(mLines); } void printRippleLines(); }; diff --git a/src/SHAMap.h b/src/SHAMap.h index 7426ab780b..2621ba58ec 100644 --- a/src/SHAMap.h +++ b/src/SHAMap.h @@ -208,7 +208,7 @@ public: bool hasItem() const { return !!mItem; } SHAMapItem::ref peekItem() { return mItem; } SHAMapItem::pointer getItem() const; - bool setItem(const SHAMapItem::pointer& i, TNType type); + bool setItem(SHAMapItem::ref i, TNType type); const uint256& getTag() const { return mItem->getTag(); } const std::vector& peekData() { return mItem->peekData(); } std::vector getData() const { return mItem->getData(); } diff --git a/src/SHAMapNodes.cpp b/src/SHAMapNodes.cpp index b301e9db82..9db9f4e2ce 100644 --- a/src/SHAMapNodes.cpp +++ b/src/SHAMapNodes.cpp @@ -185,7 +185,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapTreeNode& node, uint32 seq) : SHAMapN memcpy(mHashes, node.mHashes, sizeof(mHashes)); } -SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, const SHAMapItem::pointer& item, TNType type, uint32 seq) : +SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, SHAMapItem::ref item, TNType type, uint32 seq) : SHAMapNode(node), mItem(item), mSeq(seq), mType(type), mFullBelow(true) { assert(item->peekData().size() >= 12); @@ -465,7 +465,7 @@ void SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format) assert(false); } -bool SHAMapTreeNode::setItem(const SHAMapItem::pointer& i, TNType type) +bool SHAMapTreeNode::setItem(SHAMapItem::ref i, TNType type) { uint256 hash = getNodeHash(); mType = type; diff --git a/src/SerializedTransaction.h b/src/SerializedTransaction.h index e049a455df..a5dc831018 100644 --- a/src/SerializedTransaction.h +++ b/src/SerializedTransaction.h @@ -20,7 +20,8 @@ class SerializedTransaction : public STObject { public: - typedef boost::shared_ptr pointer; + typedef boost::shared_ptr pointer; + typedef const boost::shared_ptr& ref; protected: TransactionType mType; diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 8eea1dd76d..1f0f43ff13 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -13,7 +13,7 @@ #include "SerializedTransaction.h" #include "Log.h" -Transaction::Transaction(const SerializedTransaction::pointer& sit, bool bValidate) +Transaction::Transaction(SerializedTransaction::ref sit, bool bValidate) : mInLedger(0), mStatus(INVALID), mResult(temUNCERTAIN), mTransaction(sit) { try @@ -709,8 +709,8 @@ bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedg for(it = inMap.begin(); it != inMap.end(); ++it) { const uint256& id = it->first; - const SHAMapItem::pointer& first = it->second.first; - const SHAMapItem::pointer& second = it->second.second; + SHAMapItem::ref first = it->second.first; + SHAMapItem::ref second = it->second.second; Transaction::pointer firstTrans, secondTrans; if (!!first) diff --git a/src/Transaction.h b/src/Transaction.h index c78a617bbc..f9101cf49e 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -129,7 +129,7 @@ private: const std::vector& vucSignature); public: - Transaction(const SerializedTransaction::pointer& st, bool bValidate); + Transaction(SerializedTransaction::ref st, bool bValidate); static Transaction::pointer sharedTransaction(const std::vector&vucTransaction, bool bValidate); static Transaction::pointer transactionFromSQL(Database* db, bool bValidate); diff --git a/src/TransactionMaster.cpp b/src/TransactionMaster.cpp index b59f54d228..eabf17622c 100644 --- a/src/TransactionMaster.cpp +++ b/src/TransactionMaster.cpp @@ -31,7 +31,7 @@ Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDi return txn; } -SerializedTransaction::pointer TransactionMaster::fetch(const SHAMapItem::pointer& item, bool checkDisk, uint32 uCommitLedger) +SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger) { SerializedTransaction::pointer txn; Transaction::pointer iTx = theApp->getMasterTransaction().fetch(item->getTag(), false); diff --git a/src/TransactionMaster.h b/src/TransactionMaster.h index c5e5f9a759..19fd8b64da 100644 --- a/src/TransactionMaster.h +++ b/src/TransactionMaster.h @@ -16,7 +16,7 @@ public: TransactionMaster(); Transaction::pointer fetch(const uint256&, bool checkDisk); - SerializedTransaction::pointer fetch(const SHAMapItem::pointer& item, bool checkDisk, uint32 uCommitLedger); + SerializedTransaction::pointer fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger); // return value: true = we had the transaction already bool canonicalize(Transaction::pointer& txn, bool maybeNew);