diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index a7e4882c5..e5933fc6c 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -375,13 +375,8 @@ getTransaction (Ledger const& ledger, txn = Transaction::sharedTransaction (item->peekData (), Validate::YES); else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { - Blob txnData; - int txnLength; - - if (!item->peekSerializer().getVL (txnData, 0, txnLength)) - return Transaction::pointer (); - - txn = Transaction::sharedTransaction (txnData, Validate::NO); + auto sit = SerialIter{item->data(), item->size()}; + txn = Transaction::sharedTransaction(sit.getVL(), Validate::NO); } else { @@ -917,7 +912,7 @@ Ledger::read (Keylet const& k) const if (! value) return nullptr; auto sle = std::make_shared( - value->peekSerializer(), value->key()); + SerialIter{value->data(), value->size()}, value->key()); if (! k.check(*sle)) return nullptr; // VFALCO TODO Eliminate "immutable" runtime property @@ -1037,7 +1032,7 @@ Ledger::peek (Keylet const& k) const if (! value) return nullptr; auto sle = std::make_shared( - value->peekSerializer(), value->key()); + SerialIter{value->data(), value->size()}, value->key()); if (! k.check(*sle)) return nullptr; // VFALCO TODO Eliminate "immutable" runtime property @@ -1050,20 +1045,21 @@ Ledger::peek (Keylet const& k) const //------------------------------------------------------------------------------ static void visitHelper ( - std::function const&)>& function, + std::function const&)>& callback, std::shared_ptr const& item) { - function (std::make_shared (item->peekSerializer(), item->key())); + callback(std::make_shared(SerialIter{item->data(), item->size()}, + item->key())); } -void Ledger::visitStateItems (std::function function) const +void Ledger::visitStateItems (std::function callback) const { try { if (stateMap_) { stateMap_->visitLeaves( - std::bind(&visitHelper, std::ref(function), + std::bind(&visitHelper, std::ref(callback), std::placeholders::_1)); } } diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index a011d016b..c600a900c 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -312,13 +312,13 @@ void LedgerHistory::handleMismatch (LedgerHash const& built, LedgerHash const& v builtLedger->txMap().visitLeaves( [&builtTx](std::shared_ptr const& item) { - builtTx.push_back({item->getTag(), item->peekData()}); + builtTx.push_back({item->key(), item->peekData()}); }); // Get valid ledger hashes and metadata validLedger->txMap().visitLeaves( [&validTx](std::shared_ptr const& item) { - validTx.push_back({item->getTag(), item->peekData()}); + validTx.push_back({item->key(), item->peekData()}); }); // Sort both by hash diff --git a/src/ripple/app/ledger/LedgerToJson.h b/src/ripple/app/ledger/LedgerToJson.h index 924255170..83d2c0b98 100644 --- a/src/ripple/app/ledger/LedgerToJson.h +++ b/src/ripple/app/ledger/LedgerToJson.h @@ -129,7 +129,7 @@ void fillJson (Object& json, LedgerFill const& fill) CountedYield count ( fill.yieldStrategy.transactionYieldCount, fill.yield); for (auto item = txMap.peekFirstItem (type); item; - item = txMap.peekNextItem (item->getTag (), type)) + item = txMap.peekNextItem (item->key(), type)) { count.yield(); if (bFull || bExpand) @@ -167,7 +167,7 @@ void fillJson (Object& json, LedgerFill const& fill) STTx txn (tsit); TxMeta meta ( - item->getTag (), ledger.getLedgerSeq(), sit.getVL ()); + item->key(), ledger.getLedgerSeq(), sit.getVL ()); auto&& txJson = appendObject (txns); copyFrom(txJson, txn.getJson (0)); @@ -177,12 +177,12 @@ void fillJson (Object& json, LedgerFill const& fill) else { auto&& error = appendObject (txns); - error[to_string (item->getTag ())] = (int) type; + error[to_string (item->key())] = (int) type; } } else { - txns.append (to_string (item->getTag ())); + txns.append (to_string (item->key())); } } } @@ -201,7 +201,7 @@ void fillJson (Object& json, LedgerFill const& fill) [&array] (std::shared_ptr const& smi) { auto&& obj = appendObject (array); - obj[jss::hash] = to_string(smi->getTag ()); + obj[jss::hash] = to_string(smi->key()); obj[jss::tx_blob] = strHex(smi->peekData ()); }); } @@ -221,7 +221,7 @@ void fillJson (Object& json, LedgerFill const& fill) [&array, &count] (std::shared_ptr const& smi) { count.yield(); - array.append (to_string(smi->getTag ())); + array.append (to_string(smi->key())); }); } } diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp index 7f972be93..ab265836d 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp @@ -1825,7 +1825,7 @@ void applyTransactions ( // The transaction isn't in the check ledger, try to apply it WriteLog (lsDEBUG, LedgerConsensus) << - "Processing candidate transaction: " << item->getTag (); + "Processing candidate transaction: " << item->key(); try { diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 79ce8e8d3..d42f18a61 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -1331,16 +1331,16 @@ bool ApplicationImp::loadOldLedger ( for (auto const& item : txns) { auto const txn = - getTransaction(*replayLedger, item->getTag(), + getTransaction(*replayLedger, item->key(), getApp().getMasterTransaction()); if (m_journal.info) m_journal.info << txn->getJson(0); Serializer s; txn->getSTransaction()->add(s); - cur->txInsert(item->getTag(), + cur->txInsert(item->key(), std::make_shared( std::move(s)), nullptr); - getApp().getHashRouter().setFlag (item->getTag(), SF_SIGGOOD); + getApp().getHashRouter().setFlag (item->key(), SF_SIGGOOD); } // Switch to the mutable snapshot diff --git a/src/ripple/app/tx/impl/TransactionMaster.cpp b/src/ripple/app/tx/impl/TransactionMaster.cpp index 8e2723831..d47ef3e2e 100644 --- a/src/ripple/app/tx/impl/TransactionMaster.cpp +++ b/src/ripple/app/tx/impl/TransactionMaster.cpp @@ -64,7 +64,7 @@ STTx::pointer TransactionMaster::fetch (std::shared_ptr const& item, bool checkDisk, std::uint32_t uCommitLedger) { STTx::pointer txn; - Transaction::pointer iTx = getApp().getMasterTransaction ().fetch (item->getTag (), false); + auto iTx = getApp().getMasterTransaction ().fetch (item->key(), false); if (!iTx) { @@ -76,12 +76,8 @@ STTx::pointer TransactionMaster::fetch (std::shared_ptr const& item, } else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { - Serializer s; - int length; - item->peekSerializer().getVL (s.modData (), 0, length); - SerialIter sit (s.slice()); - - txn = std::make_shared (std::ref (sit)); + auto blob = SerialIter{item->data(), item->size()}.getVL(); + txn = std::make_shared(SerialIter{blob.data(), blob.size()}); } } else diff --git a/src/ripple/protocol/STLedgerEntry.h b/src/ripple/protocol/STLedgerEntry.h index 75ab812a1..3eaccafb7 100644 --- a/src/ripple/protocol/STLedgerEntry.h +++ b/src/ripple/protocol/STLedgerEntry.h @@ -48,6 +48,8 @@ public: STLedgerEntry (const Serializer & s, uint256 const& index); STLedgerEntry (SerialIter & sit, uint256 const& index); + STLedgerEntry(SerialIter&& sit, uint256 const& index) + : STLedgerEntry(sit, index) {} STLedgerEntry (const STObject & object, uint256 const& index); diff --git a/src/ripple/protocol/STTx.h b/src/ripple/protocol/STTx.h index 11cbe9965..3d7e031e4 100644 --- a/src/ripple/protocol/STTx.h +++ b/src/ripple/protocol/STTx.h @@ -54,6 +54,7 @@ public: STTx (STTx const& other) = default; explicit STTx (SerialIter& sit); + explicit STTx (SerialIter&& sit) : STTx(sit) {} explicit STTx (TxType type); explicit STTx (STObject&& object); diff --git a/src/ripple/rpc/handlers/LedgerData.cpp b/src/ripple/rpc/handlers/LedgerData.cpp index 0bc267878..c4c2fb055 100644 --- a/src/ripple/rpc/handlers/LedgerData.cpp +++ b/src/ripple/rpc/handlers/LedgerData.cpp @@ -82,7 +82,7 @@ Json::Value doLedgerData (RPC::Context& context) auto item = map.peekNextItem (resumePoint); if (!item) break; - resumePoint = item->getTag(); + resumePoint = item->key(); if (limit-- <= 0) { @@ -96,13 +96,13 @@ Json::Value doLedgerData (RPC::Context& context) Json::Value& entry = nodes.append (Json::objectValue); entry[jss::data] = strHex ( item->peekData().begin(), item->peekData().size()); - entry[jss::index] = to_string (item->getTag ()); + entry[jss::index] = to_string (item->key()); } else { - SLE sle (item->peekSerializer(), item->getTag ()); + SLE sle (SerialIter{item->data(), item->size()}, item->key()); Json::Value& entry = nodes.append (sle.getJson (0)); - entry[jss::index] = to_string (item->getTag ()); + entry[jss::index] = to_string (item->key()); } } diff --git a/src/ripple/shamap/SHAMapItem.h b/src/ripple/shamap/SHAMapItem.h index 2aa612bf2..e866b977d 100644 --- a/src/ripple/shamap/SHAMapItem.h +++ b/src/ripple/shamap/SHAMapItem.h @@ -20,9 +20,10 @@ #ifndef RIPPLE_SHAMAP_SHAMAPITEM_H_INCLUDED #define RIPPLE_SHAMAP_SHAMAPITEM_H_INCLUDED -#include #include +#include #include +#include #include #include @@ -33,87 +34,58 @@ namespace ripple { class SHAMapItem { private: - uint256 mTag; - Serializer mData; + uint256 tag_; + Blob data_; 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; - uint256 const& - key() const - { - return mTag; - } - - // DEPRECATED - uint256 const& getTag() const; + uint256 const& key() const; Blob const& peekData() const; - Serializer const& peekSerializer() const; -public: // public only to SHAMapTreeNode std::size_t size() const; - -private: - explicit SHAMapItem (Blob const& data); - void const* data() const; - void dump (beast::Journal journal); }; //------------------------------------------------------------------------------ -inline -SHAMapItem::SHAMapItem (uint256 const& tag) - : mTag (tag) -{ -} - inline Slice SHAMapItem::slice() const { - return mData.slice(); + return {data_.data(), data_.size()}; } inline std::size_t SHAMapItem::size() const { - return mData.peekData().size(); + return data_.size(); } inline void const* SHAMapItem::data() const { - return mData.peekData().data(); + return data_.data(); } inline uint256 const& -SHAMapItem::getTag() const +SHAMapItem::key() const { - return mTag; + return tag_; } inline Blob const& SHAMapItem::peekData() const { - return mData.peekData(); -} - -inline -Serializer const& -SHAMapItem::peekSerializer() const -{ - return mData; + return data_; } } // ripple diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 161a729ee..11b7885f0 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -107,7 +107,7 @@ SHAMap::getStack (uint256 const& id, bool include_nonmatching_leaf) const } if (include_nonmatching_leaf || - (std::static_pointer_cast(node)->peekItem()->getTag() == id)) + (std::static_pointer_cast(node)->peekItem()->key() == id)) stack.push ({node, nodeID}); return stack; @@ -164,7 +164,7 @@ SHAMapTreeNode* SHAMap::walkToPointer (uint256 const& id) const } auto ret = static_cast(inNode); - return ret->peekItem()->getTag() == id ? ret : nullptr; + return ret->peekItem()->key() == id ? ret : nullptr; } std::shared_ptr @@ -577,7 +577,7 @@ SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNType& type) const if (node->isLeaf ()) { auto leaf = static_cast(node); - if (leaf->peekItem ()->getTag () > id) + if (leaf->peekItem ()->key() > id) { type = leaf->getType (); return leaf->peekItem (); @@ -621,7 +621,7 @@ SHAMap::peekPrevItem (uint256 const& id) const if (node->isLeaf ()) { auto leaf = static_cast(node); - if (leaf->peekItem ()->getTag () < id) + if (leaf->peekItem ()->key() < id) return leaf->peekItem (); } else @@ -699,7 +699,7 @@ bool SHAMap::delItem (uint256 const& id) auto leaf = std::dynamic_pointer_cast(stack.top ().first); stack.pop (); - if (!leaf || (leaf->peekItem ()->getTag () != id)) + if (!leaf || (leaf->peekItem ()->key() != id)) return false; SHAMapTreeNode::TNType type = leaf->getType (); @@ -773,7 +773,7 @@ SHAMap::addGiveItem (std::shared_ptr const& item, bool isTransaction, bool hasMeta) { // add the specified item, does not update - uint256 tag = item->getTag (); + uint256 tag = item->key(); SHAMapTreeNode::TNType type = !isTransaction ? SHAMapTreeNode::tnACCOUNT_STATE : (hasMeta ? SHAMapTreeNode::tnTRANSACTION_MD : SHAMapTreeNode::tnTRANSACTION_NM); @@ -791,7 +791,7 @@ SHAMap::addGiveItem (std::shared_ptr const& item, if (node->isLeaf()) { auto leaf = std::static_pointer_cast(node); - if (leaf->peekItem()->getTag() == tag) + if (leaf->peekItem()->key() == tag) return false; } node = unshareNode(std::move(node), nodeID); @@ -809,14 +809,14 @@ 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 (); - assert (otherItem && (tag != otherItem->getTag ())); + assert (otherItem && (tag != otherItem->key())); node = std::make_shared(node->getSeq()); int b1, b2; while ((b1 = nodeID.selectBranch (tag)) == - (b2 = nodeID.selectBranch (otherItem->getTag ()))) + (b2 = nodeID.selectBranch (otherItem->key()))) { stack.push ({node, nodeID}); @@ -865,7 +865,7 @@ SHAMap::updateGiveItem (std::shared_ptr const& item, bool isTransaction, bool hasMeta) { // can't change the tag but can change the hash - uint256 tag = item->getTag (); + uint256 tag = item->key(); assert (state_ != SHAMapState::Immutable); @@ -878,7 +878,7 @@ SHAMap::updateGiveItem (std::shared_ptr const& item, auto nodeID = stack.top ().second; stack.pop (); - if (!node || (node->peekItem ()->getTag () != tag)) + if (!node || (node->peekItem ()->key() != tag)) { assert (false); return false; diff --git a/src/ripple/shamap/impl/SHAMapDelta.cpp b/src/ripple/shamap/impl/SHAMapDelta.cpp index 47b40af3f..517eae930 100644 --- a/src/ripple/shamap/impl/SHAMapDelta.cpp +++ b/src/ripple/shamap/impl/SHAMapDelta.cpp @@ -58,14 +58,14 @@ bool SHAMap::walkBranch (SHAMapAbstractNode* node, // This is a leaf node, process its item auto item = static_cast(node)->peekItem(); - if (emptyBranch || (item->getTag () != otherMapItem->getTag ())) + if (emptyBranch || (item->key() != otherMapItem->key())) { // unmatched if (isFirstMap) - differences.insert (std::make_pair (item->getTag (), + differences.insert (std::make_pair (item->key(), DeltaRef (item, std::shared_ptr ()))); else - differences.insert (std::make_pair (item->getTag (), + differences.insert (std::make_pair (item->key(), DeltaRef (std::shared_ptr (), item))); if (--maxCount <= 0) @@ -75,10 +75,10 @@ bool SHAMap::walkBranch (SHAMapAbstractNode* node, { // non-matching items with same tag if (isFirstMap) - differences.insert (std::make_pair (item->getTag (), + differences.insert (std::make_pair (item->key(), DeltaRef (item, otherMapItem))); else - differences.insert (std::make_pair (item->getTag (), + differences.insert (std::make_pair (item->key(), DeltaRef (otherMapItem, item))); if (--maxCount <= 0) @@ -98,11 +98,11 @@ 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 (), + differences.insert(std::make_pair(otherMapItem->key(), DeltaRef(std::shared_ptr(), otherMapItem))); else - differences.insert(std::make_pair(otherMapItem->getTag (), + differences.insert(std::make_pair(otherMapItem->key(), DeltaRef(otherMapItem, std::shared_ptr()))); if (--maxCount <= 0) @@ -147,11 +147,11 @@ SHAMap::compare (std::shared_ptr const& otherMap, // two leaves auto ours = static_cast(ourNode); auto other = static_cast(otherNode); - if (ours->peekItem()->getTag () == other->peekItem()->getTag ()) + if (ours->peekItem()->key() == other->peekItem()->key()) { if (ours->peekItem()->peekData () != other->peekItem()->peekData ()) { - differences.insert (std::make_pair (ours->peekItem()->getTag (), + differences.insert (std::make_pair (ours->peekItem()->key(), DeltaRef (ours->peekItem (), other->peekItem ()))); if (--maxCount <= 0) @@ -160,13 +160,13 @@ SHAMap::compare (std::shared_ptr const& otherMap, } else { - differences.insert (std::make_pair(ours->peekItem()->getTag (), + differences.insert (std::make_pair(ours->peekItem()->key(), DeltaRef(ours->peekItem(), std::shared_ptr()))); if (--maxCount <= 0) return false; - differences.insert(std::make_pair(other->peekItem()->getTag (), + differences.insert(std::make_pair(other->peekItem()->key(), DeltaRef(std::shared_ptr(), other->peekItem ()))); if (--maxCount <= 0) return false; diff --git a/src/ripple/shamap/impl/SHAMapItem.cpp b/src/ripple/shamap/impl/SHAMapItem.cpp index 8313d2f51..ce1e90a67 100644 --- a/src/ripple/shamap/impl/SHAMapItem.cpp +++ b/src/ripple/shamap/impl/SHAMapItem.cpp @@ -18,35 +18,23 @@ //============================================================================== #include +#include #include - + namespace ripple { class SHAMap; SHAMapItem::SHAMapItem (uint256 const& tag, Blob const& data) - : mTag (tag) - , mData (data.data(), data.size()) + : tag_(tag) + , data_(data) { } SHAMapItem::SHAMapItem (uint256 const& tag, const Serializer& data) - : mTag (tag) - , mData (data.data(), data.size()) + : tag_ (tag) + , data_(data.peekData()) { } -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) -{ - if (journal.info) journal.info << - "SHAMapItem(" << mTag << ") " << mData.size () << "bytes"; -} - } // ripple diff --git a/src/ripple/shamap/impl/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp index e2341796a..61333264f 100644 --- a/src/ripple/shamap/impl/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -606,7 +606,7 @@ bool SHAMap::deepCompare (SHAMap& other) const return false; auto& nodePeek = static_cast(node)->peekItem(); auto& otherNodePeek = static_cast(otherNode)->peekItem(); - if (nodePeek->getTag() != otherNodePeek->getTag()) + if (nodePeek->key() != otherNodePeek->key()) return false; if (nodePeek->peekData() != otherNodePeek->peekData()) return false; @@ -742,7 +742,7 @@ SHAMap::visitDifferences(SHAMap* have, if (root_->isLeaf ()) { auto leaf = std::static_pointer_cast(root_); - if (!have || !have->hasLeafNode(leaf->peekItem()->getTag(), leaf->getNodeHash())) + if (!have || !have->hasLeafNode(leaf->peekItem()->key(), leaf->getNodeHash())) func (*root_); return; @@ -779,7 +779,7 @@ SHAMap::visitDifferences(SHAMap* have, stack.push ({static_cast(next), childID}); } else if (!have || !have->hasLeafNode( - static_cast(next)->peekItem()->getTag(), + static_cast(next)->peekItem()->key(), childHash)) { if (! func (*next)) diff --git a/src/ripple/shamap/impl/SHAMapTreeNode.cpp b/src/ripple/shamap/impl/SHAMapTreeNode.cpp index 151870085..0c6712979 100644 --- a/src/ripple/shamap/impl/SHAMapTreeNode.cpp +++ b/src/ripple/shamap/impl/SHAMapTreeNode.cpp @@ -328,13 +328,13 @@ SHAMapTreeNode::updateHash() { nh = sha512Half(HashPrefix::leafNode, make_Slice(mItem->peekData()), - mItem->getTag()); + mItem->key()); } else if (mType == tnTRANSACTION_MD) { nh = sha512Half(HashPrefix::txNode, make_Slice(mItem->peekData()), - mItem->getTag()); + mItem->key()); } else assert (false); @@ -414,12 +414,12 @@ SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format) const { s.add32 (HashPrefix::leafNode); s.addRaw (mItem->peekData ()); - s.add256 (mItem->getTag ()); + s.add256 (mItem->key()); } else { s.addRaw (mItem->peekData ()); - s.add256 (mItem->getTag ()); + s.add256 (mItem->key()); s.add8 (1); } } @@ -442,12 +442,12 @@ SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format) const { s.add32 (HashPrefix::txNode); s.addRaw (mItem->peekData ()); - s.add256 (mItem->getTag ()); + s.add256 (mItem->key()); } else { s.addRaw (mItem->peekData ()); - s.add256 (mItem->getTag ()); + s.add256 (mItem->key()); s.add8 (4); } } @@ -534,7 +534,7 @@ SHAMapTreeNode::getString(const SHAMapNodeID & id) const ret += ",leaf\n"; ret += " Tag="; - ret += to_string (peekItem()->getTag ()); + ret += to_string (peekItem()->key()); ret += "\n Hash="; ret += to_string (mHash); ret += "/"; diff --git a/src/ripple/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp index 541f03bb5..0583d63c6 100644 --- a/src/ripple/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -29,10 +29,10 @@ namespace ripple { namespace shamap { namespace tests { -inline bool operator== (SHAMapItem const& a, SHAMapItem const& b) { return a.getTag() == b.getTag(); } -inline bool operator!= (SHAMapItem const& a, SHAMapItem const& b) { return a.getTag() != b.getTag(); } -inline bool operator== (SHAMapItem const& a, uint256 const& b) { return a.getTag() == b; } -inline bool operator!= (SHAMapItem const& a, uint256 const& b) { return a.getTag() != b; } +inline bool operator== (SHAMapItem const& a, SHAMapItem const& b) { return a.key() == b.key(); } +inline bool operator!= (SHAMapItem const& a, SHAMapItem const& b) { return a.key() != b.key(); } +inline bool operator== (SHAMapItem const& a, uint256 const& b) { return a.key() == b; } +inline bool operator!= (SHAMapItem const& a, uint256 const& b) { return a.key() != b; } class SHAMap_test : public beast::unit_test::suite { @@ -71,20 +71,20 @@ public: std::shared_ptr i; i = sMap.peekFirstItem (); unexpected (!i || (*i != i1), "bad traverse"); - i = sMap.peekNextItem (i->getTag ()); + i = sMap.peekNextItem (i->key()); unexpected (!i || (*i != i2), "bad traverse"); - i = sMap.peekNextItem (i->getTag ()); + i = sMap.peekNextItem (i->key()); unexpected (i, "bad traverse"); sMap.addItem (i4, true, false); - sMap.delItem (i2.getTag ()); + sMap.delItem (i2.key()); sMap.addItem (i3, true, false); i = sMap.peekFirstItem (); unexpected (!i || (*i != i1), "bad traverse"); - i = sMap.peekNextItem (i->getTag ()); + i = sMap.peekNextItem (i->key()); unexpected (!i || (*i != i3), "bad traverse"); - i = sMap.peekNextItem (i->getTag ()); + i = sMap.peekNextItem (i->key()); unexpected (!i || (*i != i4), "bad traverse"); - i = sMap.peekNextItem (i->getTag ()); + i = sMap.peekNextItem (i->key()); unexpected (i, "bad traverse"); testcase ("snapshot"); @@ -92,7 +92,7 @@ public: std::shared_ptr map2 = sMap.snapShot (false); unexpected (sMap.getHash () != mapHash, "bad snapshot"); unexpected (map2->getHash () != mapHash, "bad snapshot"); - unexpected (!sMap.delItem (sMap.peekFirstItem ()->getTag ()), "bad mod"); + unexpected (!sMap.delItem (sMap.peekFirstItem ()->key()), "bad mod"); unexpected (sMap.getHash () == mapHash, "bad snapshot"); unexpected (map2->getHash () != mapHash, "bad snapshot"); diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index 84affb4bf..f79213dcc 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -58,7 +58,7 @@ public: for (int i = 0; i < count; ++i) { std::shared_ptr item = makeRandomAS (); - items.push_back (item->getTag ()); + items.push_back (item->key()); if (!map.addItem (*item, false, false)) {