diff --git a/src/cpp/ripple/AcceptedLedger.cpp b/src/cpp/ripple/AcceptedLedger.cpp index 6226c3ebcb..2e2f69f085 100644 --- a/src/cpp/ripple/AcceptedLedger.cpp +++ b/src/cpp/ripple/AcceptedLedger.cpp @@ -49,12 +49,11 @@ void ALTransaction::buildJson() if (!mAffected.empty()) { - Json::Value affected(Json::arrayValue); + Json::Value& affected = (mJson["affected"] = Json::arrayValue); BOOST_FOREACH(const RippleAddress& ra, mAffected) { affected.append(ra.humanAccountID()); } - mJson["affected"] = affected; } } @@ -64,7 +63,7 @@ AcceptedLedger::AcceptedLedger(Ledger::ref ledger) : mLedger(ledger) for (SHAMapItem::pointer item = txSet.peekFirstItem(); !!item; item = txSet.peekNextItem(item->getTag())) { SerializerIterator sit(item->peekSerializer()); - insert(ALTransaction(ledger->getLedgerSeq(), sit)); + insert(boost::make_shared(ledger->getLedgerSeq(), sit)); } } @@ -78,16 +77,16 @@ AcceptedLedger::pointer AcceptedLedger::makeAcceptedLedger(Ledger::ref ledger) return ret; } -void AcceptedLedger::insert(const ALTransaction& at) +void AcceptedLedger::insert(ALTransaction::ref at) { - assert(mMap.find(at.getIndex()) == mMap.end()); - mMap.insert(std::make_pair(at.getIndex(), at)); + assert(mMap.find(at->getIndex()) == mMap.end()); + mMap.insert(std::make_pair(at->getIndex(), at)); } -const ALTransaction* AcceptedLedger::getTxn(int i) const +ALTransaction::pointer AcceptedLedger::getTxn(int i) const { map_t::const_iterator it = mMap.find(i); if (it == mMap.end()) - return NULL; - return &it->second; + return ALTransaction::pointer(); + return it->second; } diff --git a/src/cpp/ripple/AcceptedLedger.h b/src/cpp/ripple/AcceptedLedger.h index 04f917a788..f8de687399 100644 --- a/src/cpp/ripple/AcceptedLedger.h +++ b/src/cpp/ripple/AcceptedLedger.h @@ -19,6 +19,8 @@ protected: void buildJson(); public: + typedef boost::shared_ptr pointer; + typedef const pointer& ref; ALTransaction(uint32 ledgerSeq, SerializerIterator& sit); ALTransaction(SerializedTransaction::ref, TransactionMetaSet::ref); @@ -42,17 +44,17 @@ public: class AcceptedLedger { public: - typedef boost::shared_ptr pointer; - typedef const pointer& ret; - typedef std::map map_t; // Must be an ordered map! - typedef map_t::value_type value_type; - typedef map_t::const_iterator const_iterator; + typedef boost::shared_ptr pointer; + typedef const pointer& ret; + typedef std::map map_t; // Must be an ordered map! + typedef map_t::value_type value_type; + typedef map_t::const_iterator const_iterator; protected: Ledger::pointer mLedger; map_t mMap; - void insert(const ALTransaction&); + void insert(ALTransaction::ref); static TaggedCache ALCache; AcceptedLedger(Ledger::ref ledger); @@ -68,7 +70,7 @@ public: int getLedgerSeq() const { return mLedger->getLedgerSeq(); } int getTxnCount() const { return mMap.size(); } - const ALTransaction* getTxn(int) const; + ALTransaction::pointer getTxn(int) const; }; #endif diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index 50c6f73dad..d4ebb0bfea 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -471,12 +471,12 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) BOOST_FOREACH(const AcceptedLedger::value_type& vt, aLedger->getMap()) { - uint256 txID = vt.second.getTransactionID(); + uint256 txID = vt.second->getTransactionID(); theApp->getMasterTransaction().inLedger(txID, mLedgerSeq); db->executeSQL(boost::str(deleteAcctTrans % txID.GetHex())); - const std::vector& accts = vt.second.getAffected(); + const std::vector& accts = vt.second->getAffected(); if (!accts.empty()) { std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq, TxnSeq) VALUES "; @@ -496,7 +496,7 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) sql += "',"; sql += boost::lexical_cast(getLedgerSeq()); sql += ","; - sql += boost::lexical_cast(vt.second.getTxnSeq()); + sql += boost::lexical_cast(vt.second->getTxnSeq()); sql += ")"; } sql += ";"; @@ -507,7 +507,7 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) cLog(lsWARNING) << "Transaction in ledger " << mLedgerSeq << " affects no accounts"; db->executeSQL(SerializedTransaction::getMetaSQLInsertReplaceHeader() + - vt.second.getTxn()->getMetaSQL(getLedgerSeq(), vt.second.getEscMeta()) + ";"); + vt.second->getTxn()->getMetaSQL(getLedgerSeq(), vt.second->getEscMeta()) + ";"); } db->executeSQL("COMMIT TRANSACTION;"); } diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 5149a21c99..0a500b2f50 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1439,8 +1439,8 @@ void NetworkOPs::pubLedger(Ledger::ref accepted) { BOOST_FOREACH(const AcceptedLedger::value_type& vt, alpAccepted->getMap()) { - cLog(lsTRACE) << "pubAccepted: " << vt.second.getJson(); - pubValidatedTransaction(lpAccepted, vt.second); + cLog(lsTRACE) << "pubAccepted: " << vt.second->getJson(); + pubValidatedTransaction(lpAccepted, *vt.second); } } }