diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index b3aaa9d72..a174b523a 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -650,7 +650,6 @@ target_sources (rippled PRIVATE src/ripple/shamap/impl/SHAMap.cpp src/ripple/shamap/impl/SHAMapDelta.cpp src/ripple/shamap/impl/SHAMapInnerNode.cpp - src/ripple/shamap/impl/SHAMapItem.cpp src/ripple/shamap/impl/SHAMapLeafNode.cpp src/ripple/shamap/impl/SHAMapNodeID.cpp src/ripple/shamap/impl/SHAMapSync.cpp diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index 6c5206716..3e888dc58 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -316,7 +316,7 @@ RCLConsensus::Adaptor::onClose( tx.first->add(s); initialSet->addItem( SHAMapNodeType::tnTRANSACTION_NM, - SHAMapItem(tx.first->getTransactionID(), std::move(s))); + SHAMapItem(tx.first->getTransactionID(), s.slice())); } // Add pseudo-transactions to the set diff --git a/src/ripple/app/consensus/RCLCxTx.h b/src/ripple/app/consensus/RCLCxTx.h index 45ee55743..f1c34238c 100644 --- a/src/ripple/app/consensus/RCLCxTx.h +++ b/src/ripple/app/consensus/RCLCxTx.h @@ -91,8 +91,7 @@ public: insert(Tx const& t) { return map_->addItem( - SHAMapNodeType::tnTRANSACTION_NM, - SHAMapItem{t.id(), t.tx_.peekData()}); + SHAMapNodeType::tnTRANSACTION_NM, SHAMapItem{t.tx_}); } /** Remove a transaction from the set. diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 5b484ef48..d1308c589 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -371,7 +371,8 @@ Ledger::setAccepted( bool Ledger::addSLE(SLE const& sle) { - SHAMapItem item(sle.key(), sle.getSerializer()); + auto const s = sle.getSerializer(); + SHAMapItem item(sle.key(), s.slice()); return stateMap_->addItem(SHAMapNodeType::tnACCOUNT_STATE, std::move(item)); } @@ -438,8 +439,7 @@ Ledger::read(Keylet const& k) const auto const& item = stateMap_->peekItem(k.key); if (!item) return nullptr; - auto sle = std::make_shared( - SerialIter{item->data(), item->size()}, item->key()); + auto sle = std::make_shared(SerialIter{item->slice()}, item->key()); if (!k.check(*sle)) return nullptr; return sle; @@ -533,7 +533,7 @@ Ledger::rawInsert(std::shared_ptr const& sle) sle->add(ss); if (!stateMap_->addGiveItem( SHAMapNodeType::tnACCOUNT_STATE, - std::make_shared(sle->key(), std::move(ss)))) + std::make_shared(sle->key(), ss.slice()))) LogicError("Ledger::rawInsert: key already exists"); } @@ -544,7 +544,7 @@ Ledger::rawReplace(std::shared_ptr const& sle) sle->add(ss); if (!stateMap_->updateGiveItem( SHAMapNodeType::tnACCOUNT_STATE, - std::make_shared(sle->key(), std::move(ss)))) + std::make_shared(sle->key(), ss.slice()))) LogicError("Ledger::rawReplace: key not found"); } @@ -562,7 +562,7 @@ Ledger::rawTxInsert( s.addVL(metaData->peekData()); if (!txMap().addGiveItem( SHAMapNodeType::tnTRANSACTION_MD, - std::make_shared(key, std::move(s)))) + std::make_shared(key, s.slice()))) LogicError("duplicate_tx: " + to_string(key)); } @@ -578,9 +578,8 @@ Ledger::rawTxInsertWithHash( Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); s.addVL(txn->peekData()); s.addVL(metaData->peekData()); - auto item = std::make_shared(key, std::move(s)); - auto hash = sha512Half( - HashPrefix::txNode, makeSlice(item->peekData()), item->key()); + auto item = std::make_shared(key, s.slice()); + auto hash = sha512Half(HashPrefix::txNode, item->slice(), item->key()); if (!txMap().addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, std::move(item))) LogicError("duplicate_tx: " + to_string(key)); @@ -647,8 +646,7 @@ Ledger::peek(Keylet const& k) const auto const& value = stateMap_->peekItem(k.key); if (!value) return nullptr; - auto sle = std::make_shared( - SerialIter{value->data(), value->size()}, value->key()); + auto sle = std::make_shared(SerialIter{value->slice()}, value->key()); if (!k.check(*sle)) return nullptr; return sle; diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index 03ff7cc14..bfb8d0b5a 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -411,7 +411,7 @@ LedgerHistory::handleMismatch( } else { - if ((*b)->peekData() != (*v)->peekData()) + if ((*b)->slice() != (*v)->slice()) { // Same transaction with different metadata log_metadata_difference( diff --git a/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp b/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp index 452e6ca77..780b46649 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp +++ b/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp @@ -264,8 +264,8 @@ LedgerReplayMsgHandler::processReplayDeltaResponse( STObject meta(metaSit, sfMetadata); orderedTxns.emplace(meta[sfTransactionIndex], std::move(tx)); - auto item = std::make_shared( - tid, std::move(shaMapItemData)); + auto item = + std::make_shared(tid, shaMapItemData.slice()); if (!item || !txMap.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, item)) { diff --git a/src/ripple/app/ledger/impl/SkipListAcquire.cpp b/src/ripple/app/ledger/impl/SkipListAcquire.cpp index a2df68acc..00340d24b 100644 --- a/src/ripple/app/ledger/impl/SkipListAcquire.cpp +++ b/src/ripple/app/ledger/impl/SkipListAcquire.cpp @@ -147,8 +147,8 @@ SkipListAcquire::processData( JLOG(journal_.trace()) << "got data for " << hash_; try { - if (auto sle = std::make_shared( - SerialIter{item->data(), item->size()}, item->key()); + if (auto sle = + std::make_shared(SerialIter{item->slice()}, item->key()); sle) { if (auto const& skipList = sle->getFieldV256(sfHashes).value(); diff --git a/src/ripple/app/ledger/impl/TransactionMaster.cpp b/src/ripple/app/ledger/impl/TransactionMaster.cpp index e01c0d7c3..861a6503e 100644 --- a/src/ripple/app/ledger/impl/TransactionMaster.cpp +++ b/src/ripple/app/ledger/impl/TransactionMaster.cpp @@ -123,7 +123,7 @@ TransactionMaster::fetch( } else if (type == SHAMapNodeType::tnTRANSACTION_MD) { - auto blob = SerialIter{item->data(), item->size()}.getVL(); + auto blob = SerialIter{item->slice()}.getVL(); txn = std::make_shared( SerialIter{blob.data(), blob.size()}); } diff --git a/src/ripple/app/misc/AmendmentTable.h b/src/ripple/app/misc/AmendmentTable.h index c811b6003..e30c25e33 100644 --- a/src/ripple/app/misc/AmendmentTable.h +++ b/src/ripple/app/misc/AmendmentTable.h @@ -157,7 +157,7 @@ public: initialPosition->addGiveItem( SHAMapNodeType::tnTRANSACTION_NM, std::make_shared( - amendTx.getTransactionID(), s.peekData())); + amendTx.getTransactionID(), s.slice())); } } }; diff --git a/src/ripple/app/misc/FeeVoteImpl.cpp b/src/ripple/app/misc/FeeVoteImpl.cpp index ef2ffecc5..faa8a2595 100644 --- a/src/ripple/app/misc/FeeVoteImpl.cpp +++ b/src/ripple/app/misc/FeeVoteImpl.cpp @@ -246,7 +246,7 @@ FeeVoteImpl::doVoting( if (!initialPosition->addGiveItem( SHAMapNodeType::tnTRANSACTION_NM, - std::make_shared(txID, s.peekData()))) + std::make_shared(txID, s.slice()))) { JLOG(journal_.warn()) << "Ledger already had fee change"; } diff --git a/src/ripple/app/misc/NegativeUNLVote.cpp b/src/ripple/app/misc/NegativeUNLVote.cpp index 6b02bc321..01d1241d6 100644 --- a/src/ripple/app/misc/NegativeUNLVote.cpp +++ b/src/ripple/app/misc/NegativeUNLVote.cpp @@ -120,7 +120,7 @@ NegativeUNLVote::addTx( negUnlTx.add(s); if (!initialSet->addGiveItem( SHAMapNodeType::tnTRANSACTION_NM, - std::make_shared(txID, s.peekData()))) + std::make_shared(txID, s.slice()))) { JLOG(j_.warn()) << "N-UNL: ledger seq=" << seq << ", add ttUNL_MODIFY tx failed"; diff --git a/src/ripple/protocol/Serializer.h b/src/ripple/protocol/Serializer.h index e51e1bb14..37058f562 100644 --- a/src/ripple/protocol/Serializer.h +++ b/src/ripple/protocol/Serializer.h @@ -102,6 +102,8 @@ public: int addRaw(Blob const& vector); int + addRaw(Slice slice); + int addRaw(const void* ptr, int len); int addRaw(const Serializer& s); diff --git a/src/ripple/protocol/impl/Serializer.cpp b/src/ripple/protocol/impl/Serializer.cpp index 5a5b39322..42f79cfc5 100644 --- a/src/ripple/protocol/impl/Serializer.cpp +++ b/src/ripple/protocol/impl/Serializer.cpp @@ -104,6 +104,14 @@ Serializer::addRaw(Blob const& vector) return ret; } +int +Serializer::addRaw(Slice slice) +{ + int ret = mData.size(); + mData.insert(mData.end(), slice.begin(), slice.end()); + return ret; +} + int Serializer::addRaw(const Serializer& s) { diff --git a/src/ripple/shamap/SHAMapAccountStateLeafNode.h b/src/ripple/shamap/SHAMapAccountStateLeafNode.h index 1d1711d49..8daaf2495 100644 --- a/src/ripple/shamap/SHAMapAccountStateLeafNode.h +++ b/src/ripple/shamap/SHAMapAccountStateLeafNode.h @@ -67,14 +67,14 @@ public: void updateHash() final override { - hash_ = SHAMapHash{sha512Half( - HashPrefix::leafNode, makeSlice(item_->peekData()), item_->key())}; + hash_ = SHAMapHash{ + sha512Half(HashPrefix::leafNode, item_->slice(), item_->key())}; } void serializeForWire(Serializer& s) const final override { - s.addRaw(item_->peekData()); + s.addRaw(item_->slice()); s.addBitString(item_->key()); s.add8(wireTypeAccountState); } @@ -83,7 +83,7 @@ public: serializeWithPrefix(Serializer& s) const final override { s.add32(HashPrefix::leafNode); - s.addRaw(item_->peekData()); + s.addRaw(item_->slice()); s.addBitString(item_->key()); } }; diff --git a/src/ripple/shamap/SHAMapItem.h b/src/ripple/shamap/SHAMapItem.h index 6e0664b0a..24e6c08c2 100644 --- a/src/ripple/shamap/SHAMapItem.h +++ b/src/ripple/shamap/SHAMapItem.h @@ -20,14 +20,10 @@ #ifndef RIPPLE_SHAMAP_SHAMAPITEM_H_INCLUDED #define RIPPLE_SHAMAP_SHAMAPITEM_H_INCLUDED -#include +#include #include #include #include -#include -#include - -#include namespace ripple { @@ -36,60 +32,40 @@ class SHAMapItem : public CountedObject { private: uint256 tag_; - Blob data_; + Buffer data_; public: - SHAMapItem(uint256 const& tag, Blob const& data); - SHAMapItem(uint256 const& tag, Serializer const& s); - SHAMapItem(uint256 const& tag, Serializer&& s); + SHAMapItem() = delete; - Slice - slice() const; + SHAMapItem(uint256 const& tag, Slice data) : tag_(tag), data_(data) + { + } uint256 const& - key() const; + key() const + { + return tag_; + } - Blob const& - peekData() const; + Slice + slice() const + { + return static_cast(data_); + } std::size_t - size() const; + size() const + { + return data_.size(); + } + void const* - data() const; + data() const + { + return data_.data(); + } }; -//------------------------------------------------------------------------------ - -inline Slice -SHAMapItem::slice() const -{ - return {data_.data(), data_.size()}; -} - -inline std::size_t -SHAMapItem::size() const -{ - return data_.size(); -} - -inline void const* -SHAMapItem::data() const -{ - return data_.data(); -} - -inline uint256 const& -SHAMapItem::key() const -{ - return tag_; -} - -inline Blob const& -SHAMapItem::peekData() const -{ - return data_; -} - } // namespace ripple #endif diff --git a/src/ripple/shamap/SHAMapTreeNode.h b/src/ripple/shamap/SHAMapTreeNode.h index 7423444a9..bc3a0b0d8 100644 --- a/src/ripple/shamap/SHAMapTreeNode.h +++ b/src/ripple/shamap/SHAMapTreeNode.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/src/ripple/shamap/SHAMapTxLeafNode.h b/src/ripple/shamap/SHAMapTxLeafNode.h index 480318212..d9a2e01e9 100644 --- a/src/ripple/shamap/SHAMapTxLeafNode.h +++ b/src/ripple/shamap/SHAMapTxLeafNode.h @@ -65,14 +65,14 @@ public: void updateHash() final override { - hash_ = SHAMapHash{sha512Half( - HashPrefix::transactionID, makeSlice(item_->peekData()))}; + hash_ = + SHAMapHash{sha512Half(HashPrefix::transactionID, item_->slice())}; } void serializeForWire(Serializer& s) const final override { - s.addRaw(item_->peekData()); + s.addRaw(item_->slice()); s.add8(wireTypeTransaction); } @@ -80,7 +80,7 @@ public: serializeWithPrefix(Serializer& s) const final override { s.add32(HashPrefix::transactionID); - s.addRaw(item_->peekData()); + s.addRaw(item_->slice()); } }; diff --git a/src/ripple/shamap/SHAMapTxPlusMetaLeafNode.h b/src/ripple/shamap/SHAMapTxPlusMetaLeafNode.h index ba919ce26..be2c23903 100644 --- a/src/ripple/shamap/SHAMapTxPlusMetaLeafNode.h +++ b/src/ripple/shamap/SHAMapTxPlusMetaLeafNode.h @@ -66,14 +66,14 @@ public: void updateHash() final override { - hash_ = SHAMapHash{sha512Half( - HashPrefix::txNode, makeSlice(item_->peekData()), item_->key())}; + hash_ = SHAMapHash{ + sha512Half(HashPrefix::txNode, item_->slice(), item_->key())}; } void serializeForWire(Serializer& s) const final override { - s.addRaw(item_->peekData()); + s.addRaw(item_->slice()); s.addBitString(item_->key()); s.add8(wireTypeTransactionWithMeta); } @@ -82,7 +82,7 @@ public: serializeWithPrefix(Serializer& s) const final override { s.add32(HashPrefix::txNode); - s.addRaw(item_->peekData()); + s.addRaw(item_->slice()); s.addBitString(item_->key()); } }; diff --git a/src/ripple/shamap/impl/SHAMapDelta.cpp b/src/ripple/shamap/impl/SHAMapDelta.cpp index 98efec2ce..b8db81c60 100644 --- a/src/ripple/shamap/impl/SHAMapDelta.cpp +++ b/src/ripple/shamap/impl/SHAMapDelta.cpp @@ -78,7 +78,7 @@ SHAMap::walkBranch( if (--maxCount <= 0) return false; } - else if (item->peekData() != otherMapItem->peekData()) + else if (item->slice() != otherMapItem->slice()) { // non-matching items with same tag if (isFirstMap) @@ -156,8 +156,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const auto other = static_cast(otherNode); if (ours->peekItem()->key() == other->peekItem()->key()) { - if (ours->peekItem()->peekData() != - other->peekItem()->peekData()) + if (ours->peekItem()->slice() != other->peekItem()->slice()) { differences.insert(std::make_pair( ours->peekItem()->key(), diff --git a/src/ripple/shamap/impl/SHAMapItem.cpp b/src/ripple/shamap/impl/SHAMapItem.cpp deleted file mode 100644 index 1e6e967e8..000000000 --- a/src/ripple/shamap/impl/SHAMapItem.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include - -namespace ripple { - -class SHAMap; - -SHAMapItem::SHAMapItem(uint256 const& tag, Blob const& data) - : tag_(tag), data_(data) -{ -} - -SHAMapItem::SHAMapItem(uint256 const& tag, const Serializer& data) - : tag_(tag), data_(data.peekData()) -{ -} - -SHAMapItem::SHAMapItem(uint256 const& tag, Serializer&& data) - : tag_(tag), data_(std::move(data.modData())) -{ -} - -} // namespace ripple diff --git a/src/ripple/shamap/impl/SHAMapLeafNode.cpp b/src/ripple/shamap/impl/SHAMapLeafNode.cpp index 4c2d82f88..1f1f3c7ff 100644 --- a/src/ripple/shamap/impl/SHAMapLeafNode.cpp +++ b/src/ripple/shamap/impl/SHAMapLeafNode.cpp @@ -28,7 +28,7 @@ SHAMapLeafNode::SHAMapLeafNode( std::uint32_t cowid) : SHAMapTreeNode(cowid), item_(std::move(item)) { - assert(item_->peekData().size() >= 12); + assert(item_->size() >= 12); } SHAMapLeafNode::SHAMapLeafNode( @@ -37,7 +37,7 @@ SHAMapLeafNode::SHAMapLeafNode( SHAMapHash const& hash) : SHAMapTreeNode(cowid, hash), item_(std::move(item)) { - assert(item_->peekData().size() >= 12); + assert(item_->size() >= 12); } std::shared_ptr const& diff --git a/src/ripple/shamap/impl/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp index f0a8facda..dd24e84e4 100644 --- a/src/ripple/shamap/impl/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -697,7 +697,7 @@ SHAMap::deepCompare(SHAMap& other) const static_cast(otherNode)->peekItem(); if (nodePeek->key() != otherNodePeek->key()) return false; - if (nodePeek->peekData() != otherNodePeek->peekData()) + if (nodePeek->slice() != otherNodePeek->slice()) return false; } else if (node->isInner()) diff --git a/src/ripple/shamap/impl/SHAMapTreeNode.cpp b/src/ripple/shamap/impl/SHAMapTreeNode.cpp index 09416ec24..480a560a2 100644 --- a/src/ripple/shamap/impl/SHAMapTreeNode.cpp +++ b/src/ripple/shamap/impl/SHAMapTreeNode.cpp @@ -42,11 +42,8 @@ SHAMapTreeNode::makeTransaction( SHAMapHash const& hash, bool hashValid) { - // FIXME: using a Serializer results in a copy; avoid it? - Serializer s(data.begin(), data.size()); - auto item = std::make_shared( - sha512Half(HashPrefix::transactionID, data), s); + sha512Half(HashPrefix::transactionID, data), data); if (hashValid) return std::make_shared(std::move(item), 0, hash); @@ -74,7 +71,7 @@ SHAMapTreeNode::makeTransactionWithMeta( s.chop(tag.bytes); - auto item = std::make_shared(tag, s.peekData()); + auto item = std::make_shared(tag, s.slice()); if (hashValid) return std::make_shared( @@ -106,7 +103,7 @@ SHAMapTreeNode::makeAccountState( if (tag.isZero()) Throw("Invalid AS node"); - auto item = std::make_shared(tag, s.peekData()); + auto item = std::make_shared(tag, s.slice()); if (hashValid) return std::make_shared( diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 1b9f5ab71..848451974 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1276,7 +1277,11 @@ struct LedgerReplayer_test : public beast::unit_test::suite InboundLedger::Reason::GENERIC, finalHash, totalReplay); auto skipList = net.client.findSkipListAcquire(finalHash); - auto item = std::make_shared(uint256(12345), Blob(55, 55)); + + std::uint8_t payload[55] = { + 0x6A, 0x09, 0xE6, 0x67, 0xF3, 0xBC, 0xC9, 0x08, 0xB2}; + auto item = std::make_shared( + uint256(12345), Slice(payload, sizeof(payload))); skipList->processData(l->seq(), item); std::vector deltaStatuses; diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index ce58ba05e..3b6bf0d4f 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -91,7 +91,7 @@ public: Serializer s; for (int d = 0; d < 3; ++d) s.add32(ripple::rand_int(r)); - return std::make_shared(s.getSHA512Half(), s.peekData()); + return std::make_shared(s.getSHA512Half(), s.slice()); } void diff --git a/src/test/shamap/SHAMapSync_test.cpp b/src/test/shamap/SHAMapSync_test.cpp index a5ca73538..f262f5f8b 100644 --- a/src/test/shamap/SHAMapSync_test.cpp +++ b/src/test/shamap/SHAMapSync_test.cpp @@ -41,8 +41,7 @@ public: for (int d = 0; d < 3; ++d) s.add32(rand_int(eng_)); - - return std::make_shared(s.getSHA512Half(), s.peekData()); + return std::make_shared(s.getSHA512Half(), s.slice()); } bool diff --git a/src/test/shamap/SHAMap_test.cpp b/src/test/shamap/SHAMap_test.cpp index 91d8a272b..b7726ccc9 100644 --- a/src/test/shamap/SHAMap_test.cpp +++ b/src/test/shamap/SHAMap_test.cpp @@ -18,10 +18,11 @@ //============================================================================== #include -#include +#include #include #include #include +#include #include #include @@ -109,14 +110,11 @@ operator!=(SHAMapItem const& a, uint256 const& b) class SHAMap_test : public beast::unit_test::suite { public: - static Blob + static Buffer IntToVUC(int v) { - Blob vuc; - - for (int i = 0; i < 32; ++i) - vuc.push_back(static_cast(v)); - + Buffer vuc(32); + std::fill_n(vuc.data(), vuc.size(), static_cast(v)); return vuc; } @@ -371,8 +369,9 @@ class SHAMapPathProof_test : public beast::unit_test::suite for (unsigned char c = 1; c < 100; ++c) { uint256 k(c); - Blob b(32, c); - map.addItem(SHAMapNodeType::tnACCOUNT_STATE, SHAMapItem{k, b}); + map.addItem( + SHAMapNodeType::tnACCOUNT_STATE, + SHAMapItem{k, Slice{k.data(), k.size()}}); map.invariants(); auto root = map.getHash().as_uint256();