diff --git a/src/ripple_app/ledger/Ledger.cpp b/src/ripple_app/ledger/Ledger.cpp index dd9cad724..150743054 100644 --- a/src/ripple_app/ledger/Ledger.cpp +++ b/src/ripple_app/ledger/Ledger.cpp @@ -392,7 +392,7 @@ Transaction::pointer Ledger::getTransaction (uint256 const& transID) const return txn; if (type == SHAMapTreeNode::tnTRANSACTION_NM) - txn = Transaction::sharedTransaction (item->getData (), true); + txn = Transaction::sharedTransaction (item->peekData (), true); else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { Blob txnData; diff --git a/src/ripple_app/shamap/SHAMap.h b/src/ripple_app/shamap/SHAMap.h index 20e657f50..44e534834 100644 --- a/src/ripple_app/shamap/SHAMap.h +++ b/src/ripple_app/shamap/SHAMap.h @@ -54,6 +54,7 @@ public: typedef const boost::shared_ptr& ref; typedef std::pair DeltaItem; + typedef std::pair DeltaRef; typedef std::map Delta; typedef boost::unordered_map NodeMap; diff --git a/src/ripple_app/shamap/SHAMapDelta.cpp b/src/ripple_app/shamap/SHAMapDelta.cpp index 363981445..72c624e91 100644 --- a/src/ripple_app/shamap/SHAMapDelta.cpp +++ b/src/ripple_app/shamap/SHAMapDelta.cpp @@ -62,17 +62,17 @@ bool SHAMap::walkBranch (SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, boo else { // This is a leaf node, process its item - SHAMapItem::pointer item = node->getItem (); + SHAMapItem::pointer item = node->peekItem (); if (!emptyBranch && (otherMapItem->getTag () < item->getTag ())) { // this item comes after the item from the other map, so add the other item if (isFirstMap) // this is first map, so other item is from second differences.insert (std::make_pair (otherMapItem->getTag (), - std::make_pair (SHAMapItem::pointer (), otherMapItem))); + DeltaRef (SHAMapItem::pointer (), otherMapItem))); else differences.insert (std::make_pair (otherMapItem->getTag (), - std::make_pair (otherMapItem, SHAMapItem::pointer ()))); + DeltaRef (otherMapItem, SHAMapItem::pointer ()))); if (--maxCount <= 0) return false; @@ -84,9 +84,9 @@ bool SHAMap::walkBranch (SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, boo { // unmatched if (isFirstMap) - differences.insert (std::make_pair (item->getTag (), std::make_pair (item, SHAMapItem::pointer ()))); + differences.insert (std::make_pair (item->getTag (), DeltaRef (item, SHAMapItem::pointer ()))); else - differences.insert (std::make_pair (item->getTag (), std::make_pair (SHAMapItem::pointer (), item))); + differences.insert (std::make_pair (item->getTag (), DeltaRef (SHAMapItem::pointer (), item))); if (--maxCount <= 0) return false; @@ -97,9 +97,9 @@ bool SHAMap::walkBranch (SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, boo { // non-matching items if (isFirstMap) - differences.insert (std::make_pair (otherMapItem->getTag (), std::make_pair (item, otherMapItem))); + differences.insert (std::make_pair (otherMapItem->getTag (), DeltaRef (item, otherMapItem))); else - differences.insert (std::make_pair (otherMapItem->getTag (), std::make_pair (otherMapItem, item))); + differences.insert (std::make_pair (otherMapItem->getTag (), DeltaRef (otherMapItem, item))); if (--maxCount <= 0) return false; @@ -115,10 +115,10 @@ bool SHAMap::walkBranch (SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, boo // otherMapItem was unmatched, must add if (isFirstMap) // this is first map, so other item is from second differences.insert (std::make_pair (otherMapItem->getTag (), - std::make_pair (SHAMapItem::pointer (), otherMapItem))); + DeltaRef (SHAMapItem::pointer (), otherMapItem))); else differences.insert (std::make_pair (otherMapItem->getTag (), - std::make_pair (otherMapItem, SHAMapItem::pointer ()))); + DeltaRef (otherMapItem, SHAMapItem::pointer ()))); if (--maxCount <= 0) return false; @@ -167,7 +167,7 @@ bool SHAMap::compare (SHAMap::ref otherMap, Delta& differences, int maxCount) if (ourNode->peekData () != otherNode->peekData ()) { differences.insert (std::make_pair (ourNode->getTag (), - std::make_pair (ourNode->getItem (), otherNode->getItem ()))); + DeltaRef (ourNode->peekItem (), otherNode->peekItem ()))); if (--maxCount <= 0) return false; @@ -176,13 +176,13 @@ bool SHAMap::compare (SHAMap::ref otherMap, Delta& differences, int maxCount) else { differences.insert (std::make_pair (ourNode->getTag (), - std::make_pair (ourNode->getItem (), SHAMapItem::pointer ()))); + DeltaRef (ourNode->peekItem (), SHAMapItem::pointer ()))); if (--maxCount <= 0) return false; differences.insert (std::make_pair (otherNode->getTag (), - std::make_pair (SHAMapItem::pointer (), otherNode->getItem ()))); + DeltaRef (SHAMapItem::pointer (), otherNode->peekItem ()))); if (--maxCount <= 0) return false; @@ -190,12 +190,12 @@ bool SHAMap::compare (SHAMap::ref otherMap, Delta& differences, int maxCount) } else if (ourNode->isInner () && otherNode->isLeaf ()) { - if (!walkBranch (ourNode, otherNode->getItem (), true, differences, maxCount)) + if (!walkBranch (ourNode, otherNode->peekItem (), true, differences, maxCount)) return false; } else if (ourNode->isLeaf () && otherNode->isInner ()) { - if (!otherMap->walkBranch (otherNode, ourNode->getItem (), false, differences, maxCount)) + if (!otherMap->walkBranch (otherNode, ourNode->peekItem (), false, differences, maxCount)) return false; } else if (ourNode->isInner () && otherNode->isInner ()) diff --git a/src/ripple_app/shamap/SHAMapItem.h b/src/ripple_app/shamap/SHAMapItem.h index 29ccd3dfc..2704f6104 100644 --- a/src/ripple_app/shamap/SHAMapItem.h +++ b/src/ripple_app/shamap/SHAMapItem.h @@ -43,10 +43,6 @@ public: { return mTag; } - Blob getData () const - { - return mData.getData (); - } Blob const& peekData () const { return mData.peekData (); diff --git a/src/ripple_app/shamap/SHAMapSync.cpp b/src/ripple_app/shamap/SHAMapSync.cpp index a4d401397..36f9ceaf6 100644 --- a/src/ripple_app/shamap/SHAMapSync.cpp +++ b/src/ripple_app/shamap/SHAMapSync.cpp @@ -439,7 +439,7 @@ bool SHAMap::deepCompare (SHAMap& other) if (node->peekItem ()->getTag () != otherNode->peekItem ()->getTag ()) return false; - if (node->peekItem ()->getData () != otherNode->peekItem ()->getData ()) return false; + if (node->peekItem ()->peekData () != otherNode->peekItem ()->peekData ()) return false; } else if (node->isInner ()) { diff --git a/src/ripple_app/shamap/SHAMapTreeNode.cpp b/src/ripple_app/shamap/SHAMapTreeNode.cpp index dbba8c821..219edf961 100644 --- a/src/ripple_app/shamap/SHAMapTreeNode.cpp +++ b/src/ripple_app/shamap/SHAMapTreeNode.cpp @@ -32,12 +32,7 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapTreeNode& node, uint32 seq) : SHAMap mHash (node.mHash), mSeq (seq), mType (node.mType), mIsBranch (node.mIsBranch), mFullBelow (false) { if (node.mItem) - { - if ((mSeq == 0) && (node.mSeq == 0)) - mItem = node.mItem; // two immutable nodes can share an item - else - mItem = boost::make_shared (*node.mItem); - } + mItem = node.mItem; else memcpy (mHashes, node.mHashes, sizeof (mHashes)); } @@ -387,12 +382,6 @@ bool SHAMapTreeNode::setItem (SHAMapItem::ref i, TNType type) return updateHash (); } -SHAMapItem::pointer SHAMapTreeNode::getItem () const -{ - assert (isLeaf ()); - return boost::make_shared (*mItem); -} - bool SHAMapTreeNode::isEmpty () const { return mIsBranch == 0; diff --git a/src/ripple_app/shamap/SHAMapTreeNode.h b/src/ripple_app/shamap/SHAMapTreeNode.h index f9f13cb54..abaee7ceb 100644 --- a/src/ripple_app/shamap/SHAMapTreeNode.h +++ b/src/ripple_app/shamap/SHAMapTreeNode.h @@ -141,7 +141,6 @@ public: { // CAUTION: Do not modify the item return mItem; } - SHAMapItem::pointer getItem () const; bool setItem (SHAMapItem::ref i, TNType type); uint256 const& getTag () const { @@ -151,10 +150,6 @@ public: { return mItem->peekData (); } - Blob getData () const - { - return mItem->getData (); - } // sync functions bool isFullBelow (void) const diff --git a/src/ripple_app/tx/Transaction.cpp b/src/ripple_app/tx/Transaction.cpp index 3b01e678a..dec779819 100644 --- a/src/ripple_app/tx/Transaction.cpp +++ b/src/ripple_app/tx/Transaction.cpp @@ -294,7 +294,7 @@ bool Transaction::convertToTransactions (uint32 firstLedgerSeq, uint32 secondLed if (!!first) { // transaction in our table - firstTrans = sharedTransaction (first->getData (), checkFirstTransactions); + firstTrans = sharedTransaction (first->peekData (), checkFirstTransactions); if ((firstTrans->getStatus () == INVALID) || (firstTrans->getID () != id )) { @@ -307,7 +307,7 @@ bool Transaction::convertToTransactions (uint32 firstLedgerSeq, uint32 secondLed if (!!second) { // transaction in other table - secondTrans = sharedTransaction (second->getData (), checkSecondTransactions); + secondTrans = sharedTransaction (second->peekData (), checkSecondTransactions); if ((secondTrans->getStatus () == INVALID) || (secondTrans->getID () != id)) {