diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 4065a8c1b9..0a63169b59 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -342,9 +342,10 @@ addTransaction (Ledger& ledger, uint256 const& txID, const Serializer& txn) { // low-level - just add to table - auto item = std::make_shared (txID, txn.peekData ()); + auto item = std::make_shared< + SHAMapItem const> (txID, txn.peekData ()); - if (! ledger.txMap().addGiveItem (item, true, false)) + if (! ledger.txMap().addGiveItem (std::move(item), true, false)) { WriteLog (lsWARNING, Ledger) << "Attempt to add transaction to ledger that already had it"; @@ -363,9 +364,10 @@ bool addTransaction (Ledger& ledger, Serializer s (txn.getDataLength () + md.getDataLength () + 16); s.addVL (txn.peekData ()); s.addVL (md.peekData ()); - auto item = std::make_shared (txID, s.peekData ()); + auto item = std::make_shared< + SHAMapItem const> (txID, std::move(s)); - if (! ledger.txMap().addGiveItem (item, true, true)) + if (! ledger.txMap().addGiveItem (std::move(item), true, true)) { WriteLog (lsFATAL, Ledger) << "Attempt to add transaction+MD to ledger that already had it"; @@ -965,7 +967,7 @@ Ledger::unchecked_insert( Serializer ss; sle->add(ss); auto item = std::make_shared< - SHAMapItem>(sle->key(), + SHAMapItem const>(sle->key(), std::move(ss)); // VFALCO NOTE addGiveItem should take ownership auto const success = @@ -984,7 +986,7 @@ Ledger::unchecked_replace( Serializer ss; sle->add(ss); auto item = std::make_shared< - SHAMapItem>(sle->key(), + SHAMapItem const>(sle->key(), std::move(ss)); // VFALCO NOTE updateGiveItem should take ownership auto const success = @@ -1016,7 +1018,8 @@ Ledger::peek (Keylet const& k) const //------------------------------------------------------------------------------ static void visitHelper ( - std::function& function, std::shared_ptr const& item) + std::function const&)>& function, + std::shared_ptr const& item) { function (std::make_shared (item->peekSerializer(), item->key())); } @@ -1339,7 +1342,7 @@ cachedRead (Ledger const& ledger, uint256 const& key, SLECache& cache, boost::optional type) { uint256 hash; - auto const item = + auto const& item = ledger.stateMap().peekItem(key, hash); if (! item) return {}; diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index ccacf29397..d66d78cdd7 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -310,13 +310,13 @@ void LedgerHistory::handleMismatch (LedgerHash const& built, LedgerHash const& v std::vector builtTx, validTx; // Get built ledger hashes and metadata builtLedger->txMap().visitLeaves( - [&builtTx](std::shared_ptr const& item) + [&builtTx](std::shared_ptr const& item) { builtTx.push_back({item->getTag(), item->peekData()}); }); // Get valid ledger hashes and metadata validLedger->txMap().visitLeaves( - [&validTx](std::shared_ptr const& item) + [&validTx](std::shared_ptr const& item) { validTx.push_back({item->getTag(), item->peekData()}); }); diff --git a/src/ripple/app/ledger/LedgerToJson.h b/src/ripple/app/ledger/LedgerToJson.h index 4457a88a01..dc43550306 100644 --- a/src/ripple/app/ledger/LedgerToJson.h +++ b/src/ripple/app/ledger/LedgerToJson.h @@ -198,7 +198,7 @@ void fillJson (Object& json, LedgerFill const& fill) if (bBinary) { stateMap.visitLeaves ( - [&array] (std::shared_ptr const& smi) + [&array] (std::shared_ptr const& smi) { auto&& obj = appendObject (array); obj[jss::hash] = to_string(smi->getTag ()); @@ -218,7 +218,7 @@ void fillJson (Object& json, LedgerFill const& fill) else { stateMap.visitLeaves( - [&array, &count] (std::shared_ptr const& smi) + [&array, &count] (std::shared_ptr const& smi) { count.yield(); array.append (to_string(smi->getTag ())); diff --git a/src/ripple/rpc/handlers/LedgerData.cpp b/src/ripple/rpc/handlers/LedgerData.cpp index 106f712531..0bc267878c 100644 --- a/src/ripple/rpc/handlers/LedgerData.cpp +++ b/src/ripple/rpc/handlers/LedgerData.cpp @@ -79,7 +79,7 @@ Json::Value doLedgerData (RPC::Context& context) for (;;) { - std::shared_ptr item = map.peekNextItem (resumePoint); + auto item = map.peekNextItem (resumePoint); if (!item) break; resumePoint = item->getTag(); diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index c582313c25..6b34579346 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -91,8 +91,8 @@ private: bool backed_ = true; // Map is backed by the database public: - using DeltaItem = std::pair, - std::shared_ptr>; + using DeltaItem = std::pair, + std::shared_ptr>; using Delta = std::map; ~SHAMap (); @@ -139,8 +139,10 @@ public: uint256 getHash () const; // save a copy if you have a temporary anyway - bool updateGiveItem (std::shared_ptr const&, bool isTransaction, bool hasMeta); - bool addGiveItem (std::shared_ptr const&, bool isTransaction, bool hasMeta); + bool updateGiveItem (std::shared_ptr const&, + bool isTransaction, bool hasMeta); + bool addGiveItem (std::shared_ptr const&, + bool isTransaction, bool hasMeta); /** Fetch an item given its key. This retrieves the item whose key matches. @@ -149,27 +151,31 @@ public: Can throw SHAMapMissingNode @note This can cause NodeStore reads */ - // VFALCO NOTE This should return `const&` when SHAMapTreeNode - // stores std::shared_ptr - std::shared_ptr - fetch (uint256 const& key) const; + std::shared_ptr const& + fetch (uint256 const& key) const; - // VFALCO NOTE Is "save a copy" the in imperative or indicative mood? - // save a copy if you only need a temporary - std::shared_ptr peekItem (uint256 const& id) const; - std::shared_ptr peekItem (uint256 const& id, uint256 & hash) const; - std::shared_ptr peekItem (uint256 const& id, SHAMapTreeNode::TNType & type) const; + // Save a copy if you need to extend the life + // of the SHAMapItem beyond this SHAMap + std::shared_ptr const& peekItem (uint256 const& id) const; + std::shared_ptr const& + peekItem (uint256 const& id, uint256 & hash) const; + std::shared_ptr const& + peekItem (uint256 const& id, SHAMapTreeNode::TNType & type) const; // traverse functions - std::shared_ptr peekFirstItem () const; - std::shared_ptr peekFirstItem (SHAMapTreeNode::TNType & type) const; - std::shared_ptr peekLastItem () const; - std::shared_ptr peekNextItem (uint256 const& ) const; - std::shared_ptr peekNextItem (uint256 const& , SHAMapTreeNode::TNType & type) const; - std::shared_ptr peekPrevItem (uint256 const& ) const; + std::shared_ptr const& peekFirstItem () const; + std::shared_ptr const& + peekFirstItem (SHAMapTreeNode::TNType & type) const; + std::shared_ptr const& peekLastItem () const; + std::shared_ptr const& peekNextItem (uint256 const& ) const; + std::shared_ptr const& + peekNextItem (uint256 const& , SHAMapTreeNode::TNType & type) const; + std::shared_ptr const& peekPrevItem (uint256 const& ) const; void visitNodes (std::function const&) const; - void visitLeaves(std::function const&)> const&) const; + void + visitLeaves( + std::function const&)> const&) const; // comparison/sync functions void getMissingNodes (std::vector& nodeIDs, std::vector& hashes, int max, @@ -219,8 +225,8 @@ public: private: using SharedPtrNodeStack = std::stack, SHAMapNodeID>>; - using DeltaRef = std::pair const&, - std::shared_ptr const&>; + using DeltaRef = std::pair const&, + std::shared_ptr const&>; int unshare (); @@ -289,14 +295,14 @@ private: descendNoStore (std::shared_ptr const&, int branch) const; /** If there is only one leaf below this node, get its contents */ - std::shared_ptr onlyBelow (SHAMapAbstractNode*) const; + std::shared_ptr const& onlyBelow (SHAMapAbstractNode*) const; bool hasInnerNode (SHAMapNodeID const& nodeID, uint256 const& hash) const; bool hasLeafNode (uint256 const& tag, uint256 const& hash) const; bool walkBranch (SHAMapAbstractNode* node, - std::shared_ptr const& otherMapItem, bool isFirstMap, - Delta & differences, int & maxCount) const; + std::shared_ptr const& otherMapItem, + bool isFirstMap, Delta & differences, int & maxCount) const; int walkSubTree (bool doWrite, NodeObjectType t, std::uint32_t seq); }; diff --git a/src/ripple/shamap/SHAMapItem.h b/src/ripple/shamap/SHAMapItem.h index e3559d9b16..2aa612bf29 100644 --- a/src/ripple/shamap/SHAMapItem.h +++ b/src/ripple/shamap/SHAMapItem.h @@ -40,6 +40,7 @@ public: explicit SHAMapItem (uint256 const& tag); SHAMapItem (uint256 const& tag, Blob const & data); SHAMapItem (uint256 const& tag, Serializer const& s); + SHAMapItem (uint256 const& key, Serializer&& s); Slice slice() const; @@ -53,7 +54,7 @@ public: uint256 const& getTag() const; Blob const& peekData() const; - Serializer& peekSerializer(); + Serializer const& peekSerializer() const; public: // public only to SHAMapTreeNode std::size_t size() const; @@ -109,8 +110,8 @@ SHAMapItem::peekData() const } inline -Serializer& -SHAMapItem::peekSerializer() +Serializer const& +SHAMapItem::peekSerializer() const { return mData; } diff --git a/src/ripple/shamap/SHAMapTreeNode.h b/src/ripple/shamap/SHAMapTreeNode.h index 7063567d52..aae9a33074 100644 --- a/src/ripple/shamap/SHAMapTreeNode.h +++ b/src/ripple/shamap/SHAMapTreeNode.h @@ -75,7 +75,7 @@ public: bool isInBounds (SHAMapNodeID const &id) const; virtual bool updateHash () = 0; - virtual void addRaw (Serializer&, SHANodeFormat format) = 0; + virtual void addRaw (Serializer&, SHANodeFormat format) const = 0; virtual std::string getString (SHAMapNodeID const&) const; virtual std::shared_ptr clone(std::uint32_t seq) const = 0; @@ -120,7 +120,7 @@ public: bool updateHash () override; void updateHashDeep(); - void addRaw (Serializer&, SHANodeFormat format) override; + void addRaw (Serializer&, SHANodeFormat format) const override; std::string getString (SHAMapNodeID const&) const override; friend std::shared_ptr @@ -133,18 +133,19 @@ class SHAMapTreeNode : public SHAMapAbstractNode { private: - std::shared_ptr mItem; + std::shared_ptr mItem; public: SHAMapTreeNode (const SHAMapTreeNode&) = delete; SHAMapTreeNode& operator= (const SHAMapTreeNode&) = delete; - SHAMapTreeNode (std::shared_ptr const& item, TNType type, std::uint32_t seq); - SHAMapTreeNode(std::shared_ptr const& item, TNType type, + SHAMapTreeNode (std::shared_ptr const& item, + TNType type, std::uint32_t seq); + SHAMapTreeNode(std::shared_ptr const& item, TNType type, std::uint32_t seq, uint256 const& hash); std::shared_ptr clone(std::uint32_t seq) const override; - void addRaw (Serializer&, SHANodeFormat format) override; + void addRaw (Serializer&, SHANodeFormat format) const override; public: // public only to SHAMap @@ -153,8 +154,8 @@ public: // public only to SHAMap // item node function bool hasItem () const; - std::shared_ptr const& peekItem () const; - bool setItem (std::shared_ptr const& i, TNType type); + std::shared_ptr const& peekItem () const; + bool setItem (std::shared_ptr const& i, TNType type); std::string getString (SHAMapNodeID const&) const override; bool updateHash () override; @@ -290,7 +291,7 @@ SHAMapTreeNode::hasItem () const } inline -std::shared_ptr const& +std::shared_ptr const& SHAMapTreeNode::peekItem () const { return mItem; diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index b0ce1a72dd..161a729eec 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -468,7 +468,9 @@ SHAMap::lastBelow (SHAMapAbstractNode* node) const while (true); } -std::shared_ptr +static const std::shared_ptr no_item; + +std::shared_ptr const& SHAMap::onlyBelow (SHAMapAbstractNode* node) const { // If there is only one item below this node, return it @@ -482,7 +484,7 @@ SHAMap::onlyBelow (SHAMapAbstractNode* node) const if (!inner->isEmptyBranch (i)) { if (nextNode) - return std::shared_ptr (); + return no_item; nextNode = descendThrow (inner, i); } @@ -491,7 +493,7 @@ SHAMap::onlyBelow (SHAMapAbstractNode* node) const if (!nextNode) { assert (false); - return std::shared_ptr (); + return no_item; } node = nextNode; @@ -508,7 +510,7 @@ SHAMap::onlyBelow (SHAMapAbstractNode* node) const static std::shared_ptr< SHAMapItem const> const nullConstSHAMapItem; -std::shared_ptr +std::shared_ptr const& SHAMap::fetch (uint256 const& key) const { SHAMapTreeNode const* const leaf = @@ -518,9 +520,8 @@ SHAMap::fetch (uint256 const& key) const return leaf->peekItem(); } -static const std::shared_ptr no_item; - -std::shared_ptr SHAMap::peekFirstItem () const +std::shared_ptr const& +SHAMap::peekFirstItem () const { SHAMapTreeNode* node = firstBelow (root_.get ()); @@ -530,7 +531,8 @@ std::shared_ptr SHAMap::peekFirstItem () const return node->peekItem (); } -std::shared_ptr SHAMap::peekFirstItem (SHAMapTreeNode::TNType& type) const +std::shared_ptr const& +SHAMap::peekFirstItem (SHAMapTreeNode::TNType& type) const { SHAMapTreeNode* node = firstBelow (root_.get ()); @@ -541,7 +543,8 @@ std::shared_ptr SHAMap::peekFirstItem (SHAMapTreeNode::TNType& type) return node->peekItem (); } -std::shared_ptr SHAMap::peekLastItem () const +std::shared_ptr const& +SHAMap::peekLastItem () const { SHAMapTreeNode* node = lastBelow (root_.get ()); @@ -551,13 +554,14 @@ std::shared_ptr SHAMap::peekLastItem () const return node->peekItem (); } -std::shared_ptr SHAMap::peekNextItem (uint256 const& id) const +std::shared_ptr const& +SHAMap::peekNextItem (uint256 const& id) const { SHAMapTreeNode::TNType type; return peekNextItem (id, type); } -std::shared_ptr +std::shared_ptr const& SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNType& type) const { // Get a pointer to the next item in the tree after a given item - item need not be in tree @@ -603,7 +607,7 @@ SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNType& type) const } // Get a pointer to the previous item in the tree after a given item - item need not be in tree -std::shared_ptr +std::shared_ptr const& SHAMap::peekPrevItem (uint256 const& id) const { auto stack = getStack (id, true); @@ -639,7 +643,8 @@ SHAMap::peekPrevItem (uint256 const& id) const return no_item; } -std::shared_ptr SHAMap::peekItem (uint256 const& id) const +std::shared_ptr const& +SHAMap::peekItem (uint256 const& id) const { SHAMapTreeNode* leaf = walkToPointer (id); @@ -649,7 +654,8 @@ std::shared_ptr SHAMap::peekItem (uint256 const& id) const return leaf->peekItem (); } -std::shared_ptr SHAMap::peekItem (uint256 const& id, SHAMapTreeNode::TNType& type) const +std::shared_ptr const& +SHAMap::peekItem (uint256 const& id, SHAMapTreeNode::TNType& type) const { SHAMapTreeNode* leaf = walkToPointer (id); @@ -660,7 +666,8 @@ std::shared_ptr SHAMap::peekItem (uint256 const& id, SHAMapTreeNode: return leaf->peekItem (); } -std::shared_ptr SHAMap::peekItem (uint256 const& id, uint256& hash) const +std::shared_ptr const& +SHAMap::peekItem (uint256 const& id, uint256& hash) const { SHAMapTreeNode* leaf = walkToPointer (id); @@ -728,7 +735,7 @@ bool SHAMap::delItem (uint256 const& id) else if (bc == 1) { // If there's only one item, pull up on the thread - std::shared_ptr item = onlyBelow (node.get ()); + std::shared_ptr item = onlyBelow (node.get ()); if (item) { @@ -762,7 +769,7 @@ bool SHAMap::delItem (uint256 const& id) } bool -SHAMap::addGiveItem (std::shared_ptr const& item, +SHAMap::addGiveItem (std::shared_ptr const& item, bool isTransaction, bool hasMeta) { // add the specified item, does not update @@ -801,7 +808,7 @@ SHAMap::addGiveItem (std::shared_ptr const& item, { // this is a leaf node that has to be made an inner node holding two items auto leaf = std::static_pointer_cast(node); - std::shared_ptr otherItem = leaf->peekItem (); + std::shared_ptr otherItem = leaf->peekItem (); assert (otherItem && (tag != otherItem->getTag ())); node = std::make_shared(node->getSeq()); @@ -838,7 +845,7 @@ SHAMap::addGiveItem (std::shared_ptr const& item, bool SHAMap::addItem (const SHAMapItem& i, bool isTransaction, bool hasMetaData) { - return addGiveItem (std::make_shared (i), isTransaction, hasMetaData); + return addGiveItem(std::make_shared(i), isTransaction, hasMetaData); } uint256 @@ -854,7 +861,7 @@ SHAMap::getHash () const } bool -SHAMap::updateGiveItem (std::shared_ptr const& item, +SHAMap::updateGiveItem (std::shared_ptr const& item, bool isTransaction, bool hasMeta) { // can't change the tag but can change the hash diff --git a/src/ripple/shamap/impl/SHAMapDelta.cpp b/src/ripple/shamap/impl/SHAMapDelta.cpp index 16044f9ffd..47b40af3f0 100644 --- a/src/ripple/shamap/impl/SHAMapDelta.cpp +++ b/src/ripple/shamap/impl/SHAMapDelta.cpp @@ -31,8 +31,8 @@ namespace ripple { // synchronizing matching branches too.) bool SHAMap::walkBranch (SHAMapAbstractNode* node, - std::shared_ptr const& otherMapItem, bool isFirstMap, - Delta& differences, int& maxCount) const + std::shared_ptr const& otherMapItem, + bool isFirstMap,Delta& differences, int& maxCount) const { // Walk a branch of a SHAMap that's matched by an empty branch or single item in the other map std::stack > nodeStack; @@ -63,10 +63,10 @@ bool SHAMap::walkBranch (SHAMapAbstractNode* node, // unmatched if (isFirstMap) differences.insert (std::make_pair (item->getTag (), - DeltaRef (item, std::shared_ptr ()))); + DeltaRef (item, std::shared_ptr ()))); else differences.insert (std::make_pair (item->getTag (), - DeltaRef (std::shared_ptr (), item))); + DeltaRef (std::shared_ptr (), item))); if (--maxCount <= 0) return false; @@ -98,13 +98,12 @@ bool SHAMap::walkBranch (SHAMapAbstractNode* node, { // otherMapItem was unmatched, must add if (isFirstMap) // this is first map, so other item is from second - differences.insert (std::make_pair (otherMapItem->getTag (), - DeltaRef (std::shared_ptr(), - otherMapItem))); + differences.insert(std::make_pair(otherMapItem->getTag (), + DeltaRef(std::shared_ptr(), + otherMapItem))); else - differences.insert (std::make_pair (otherMapItem->getTag (), - DeltaRef (otherMapItem, - std::shared_ptr ()))); + differences.insert(std::make_pair(otherMapItem->getTag (), + DeltaRef(otherMapItem, std::shared_ptr()))); if (--maxCount <= 0) return false; @@ -163,13 +162,12 @@ SHAMap::compare (std::shared_ptr const& otherMap, { differences.insert (std::make_pair(ours->peekItem()->getTag (), DeltaRef(ours->peekItem(), - std::shared_ptr ()))); + std::shared_ptr()))); if (--maxCount <= 0) return false; differences.insert(std::make_pair(other->peekItem()->getTag (), - DeltaRef(std::shared_ptr(), - other->peekItem ()))); + DeltaRef(std::shared_ptr(), other->peekItem ()))); if (--maxCount <= 0) return false; } @@ -202,7 +200,7 @@ SHAMap::compare (std::shared_ptr const& otherMap, // We have a branch, the other tree does not SHAMapAbstractNode* iNode = descendThrow (ours, i); if (!walkBranch (iNode, - std::shared_ptr (), true, + std::shared_ptr (), true, differences, maxCount)) return false; } @@ -212,7 +210,7 @@ SHAMap::compare (std::shared_ptr const& otherMap, SHAMapAbstractNode* iNode = otherMap->descendThrow(other, i); if (!otherMap->walkBranch (iNode, - std::shared_ptr(), + std::shared_ptr(), false, differences, maxCount)) return false; } diff --git a/src/ripple/shamap/impl/SHAMapItem.cpp b/src/ripple/shamap/impl/SHAMapItem.cpp index 7af336133d..8313d2f51b 100644 --- a/src/ripple/shamap/impl/SHAMapItem.cpp +++ b/src/ripple/shamap/impl/SHAMapItem.cpp @@ -36,6 +36,12 @@ SHAMapItem::SHAMapItem (uint256 const& tag, const Serializer& data) { } +SHAMapItem::SHAMapItem (uint256 const& key, Serializer&& s) + : mTag(key) + , mData(std::move(s)) +{ +} + // VFALCO This function appears not to be called void SHAMapItem::dump (beast::Journal journal) { diff --git a/src/ripple/shamap/impl/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp index 8965cadf74..e2341796a5 100644 --- a/src/ripple/shamap/impl/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -29,7 +29,7 @@ namespace ripple { static const uint256 uZero; static bool visitLeavesHelper ( - std::function const&)> const& function, + std::function const&)> const& function, SHAMapAbstractNode& node) { // Adapt visitNodes to visitLeaves @@ -41,7 +41,7 @@ static bool visitLeavesHelper ( void SHAMap::visitLeaves( - std::function const& item)> const& leafFunction) const + std::function const& item)> const& leafFunction) const { visitNodes (std::bind (visitLeavesHelper, std::cref (leafFunction), std::placeholders::_1)); diff --git a/src/ripple/shamap/impl/SHAMapTreeNode.cpp b/src/ripple/shamap/impl/SHAMapTreeNode.cpp index 2f0dca846a..1518700854 100644 --- a/src/ripple/shamap/impl/SHAMapTreeNode.cpp +++ b/src/ripple/shamap/impl/SHAMapTreeNode.cpp @@ -55,7 +55,7 @@ SHAMapTreeNode::clone(std::uint32_t seq) const return std::make_shared(mItem, mType, seq, mHash); } -SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr const& item, +SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr const& item, TNType type, std::uint32_t seq) : SHAMapAbstractNode(type, seq) , mItem (item) @@ -64,7 +64,7 @@ SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr const& item, updateHash(); } -SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr const& item, +SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr const& item, TNType type, std::uint32_t seq, uint256 const& hash) : SHAMapAbstractNode(type, seq, hash) , mItem (item) @@ -105,7 +105,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f if (type == 0) { // transaction - auto item = std::make_shared( + auto item = std::make_shared( sha512Half(HashPrefix::transactionID, Slice(s.data(), s.size())), s.peekData()); @@ -125,7 +125,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f if (u.isZero ()) throw std::runtime_error ("invalid AS node"); - auto item = std::make_shared (u, s.peekData ()); + auto item = std::make_shared (u, s.peekData ()); if (hashValid) return std::make_shared(item, tnACCOUNT_STATE, seq, hash); return std::make_shared(item, tnACCOUNT_STATE, seq); @@ -185,7 +185,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f if (u.isZero ()) throw std::runtime_error ("invalid TM node"); - auto item = std::make_shared (u, s.peekData ()); + auto item = std::make_shared (u, s.peekData ()); if (hashValid) return std::make_shared(item, tnTRANSACTION_MD, seq, hash); return std::make_shared(item, tnTRANSACTION_MD, seq); @@ -211,7 +211,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f if (prefix == HashPrefix::transactionID) { - auto item = std::make_shared( + auto item = std::make_shared( sha512Half(make_Slice(rawNode)), s.peekData ()); if (hashValid) @@ -233,7 +233,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f throw std::runtime_error ("invalid PLN node"); } - auto item = std::make_shared (u, s.peekData ()); + auto item = std::make_shared (u, s.peekData ()); if (hashValid) return std::make_shared(item, tnACCOUNT_STATE, seq, hash); return std::make_shared(item, tnACCOUNT_STATE, seq); @@ -265,7 +265,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f uint256 txID; s.get256 (txID, s.getLength () - 32); s.chop (32); - auto item = std::make_shared (txID, s.peekData ()); + auto item = std::make_shared (txID, s.peekData ()); if (hashValid) return std::make_shared(item, tnTRANSACTION_MD, seq, hash); return std::make_shared(item, tnTRANSACTION_MD, seq); @@ -347,7 +347,7 @@ SHAMapTreeNode::updateHash() } void -SHAMapInnerNode::addRaw(Serializer& s, SHANodeFormat format) +SHAMapInnerNode::addRaw(Serializer& s, SHANodeFormat format) const { assert ((format == snfPREFIX) || (format == snfWIRE) || (format == snfHASH)); @@ -397,7 +397,7 @@ SHAMapInnerNode::addRaw(Serializer& s, SHANodeFormat format) } void -SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format) +SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format) const { assert ((format == snfPREFIX) || (format == snfWIRE) || (format == snfHASH)); @@ -455,7 +455,7 @@ SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format) assert (false); } -bool SHAMapTreeNode::setItem (std::shared_ptr const& i, TNType type) +bool SHAMapTreeNode::setItem (std::shared_ptr const& i, TNType type) { mType = type; mItem = i; diff --git a/src/ripple/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp index d96cff4fa2..541f03bb5b 100644 --- a/src/ripple/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -68,7 +68,7 @@ public: unexpected (!sMap.addItem (i2, true, false), "no add"); unexpected (!sMap.addItem (i1, true, false), "no add"); - std::shared_ptr i; + std::shared_ptr i; i = sMap.peekFirstItem (); unexpected (!i || (*i != i1), "bad traverse"); i = sMap.peekNextItem (i->getTag ());