diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index fbe95e9c9d3..7cd6f89cad3 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -182,8 +182,8 @@ Ledger::Ledger( std::vector const& amendments, Family& family) : mImmutable(false) - , txMap_(std::make_shared(SHAMapType::TRANSACTION, family)) - , stateMap_(std::make_shared(SHAMapType::STATE, family)) + , txMap_(SHAMapType::TRANSACTION, family) + , stateMap_(SHAMapType::STATE, family) , rules_{config.features} , j_(beast::Journal(beast::Journal::getNullSink())) { @@ -235,7 +235,7 @@ Ledger::Ledger( rawInsert(sle); } - stateMap_->flushDirty(hotACCOUNT_NODE); + stateMap_.flushDirty(hotACCOUNT_NODE); setImmutable(); } @@ -247,12 +247,8 @@ Ledger::Ledger( Family& family, beast::Journal j) : mImmutable(true) - , txMap_(std::make_shared( - SHAMapType::TRANSACTION, - info.txHash, - family)) - , stateMap_( - std::make_shared(SHAMapType::STATE, info.accountHash, family)) + , txMap_(SHAMapType::TRANSACTION, info.txHash, family) + , stateMap_(SHAMapType::STATE, info.accountHash, family) , rules_(config.features) , info_(info) , j_(j) @@ -260,7 +256,7 @@ Ledger::Ledger( loaded = true; if (info_.txHash.isNonZero() && - !txMap_->fetchRoot(SHAMapHash{info_.txHash}, nullptr)) + !txMap_.fetchRoot(SHAMapHash{info_.txHash}, nullptr)) { if (config.reporting()) { @@ -272,7 +268,7 @@ Ledger::Ledger( } if (info_.accountHash.isNonZero() && - !stateMap_->fetchRoot(SHAMapHash{info_.accountHash}, nullptr)) + !stateMap_.fetchRoot(SHAMapHash{info_.accountHash}, nullptr)) { if (config.reporting()) { @@ -283,8 +279,8 @@ Ledger::Ledger( JLOG(j.warn()) << "Don't have state data root for ledger" << info_.seq; } - txMap_->setImmutable(); - stateMap_->setImmutable(); + txMap_.setImmutable(); + stateMap_.setImmutable(); defaultFees(config); if (!setup()) @@ -301,10 +297,8 @@ Ledger::Ledger( // Create a new ledger that follows this one Ledger::Ledger(Ledger const& prevLedger, NetClock::time_point closeTime) : mImmutable(false) - , txMap_(std::make_shared( - SHAMapType::TRANSACTION, - prevLedger.stateMap_->family())) - , stateMap_(prevLedger.stateMap_->snapShot(true)) + , txMap_(SHAMapType::TRANSACTION, prevLedger.txMap_.family()) + , stateMap_(prevLedger.stateMap_, true) , fees_(prevLedger.fees_) , rules_(prevLedger.rules_) , j_(beast::Journal(beast::Journal::getNullSink())) @@ -333,12 +327,8 @@ Ledger::Ledger(Ledger const& prevLedger, NetClock::time_point closeTime) Ledger::Ledger(LedgerInfo const& info, Config const& config, Family& family) : mImmutable(true) - , txMap_(std::make_shared( - SHAMapType::TRANSACTION, - info.txHash, - family)) - , stateMap_( - std::make_shared(SHAMapType::STATE, info.accountHash, family)) + , txMap_(SHAMapType::TRANSACTION, info.txHash, family) + , stateMap_(SHAMapType::STATE, info.accountHash, family) , rules_{config.features} , info_(info) , j_(beast::Journal(beast::Journal::getNullSink())) @@ -352,8 +342,8 @@ Ledger::Ledger( Config const& config, Family& family) : mImmutable(false) - , txMap_(std::make_shared(SHAMapType::TRANSACTION, family)) - , stateMap_(std::make_shared(SHAMapType::STATE, family)) + , txMap_(SHAMapType::TRANSACTION, family) + , stateMap_(SHAMapType::STATE, family) , rules_{config.features} , j_(beast::Journal(beast::Journal::getNullSink())) { @@ -371,16 +361,16 @@ Ledger::setImmutable(bool rehash) // place the hash transitions to valid if (!mImmutable && rehash) { - info_.txHash = txMap_->getHash().as_uint256(); - info_.accountHash = stateMap_->getHash().as_uint256(); + info_.txHash = txMap_.getHash().as_uint256(); + info_.accountHash = stateMap_.getHash().as_uint256(); } if (rehash) info_.hash = calculateLedgerHash(info_); mImmutable = true; - txMap_->setImmutable(); - stateMap_->setImmutable(); + txMap_.setImmutable(); + stateMap_.setImmutable(); setup(); } @@ -403,7 +393,7 @@ bool Ledger::addSLE(SLE const& sle) { auto const s = sle.getSerializer(); - return stateMap_->addItem( + return stateMap_.addItem( SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle.key(), s.slice())); } @@ -439,20 +429,20 @@ bool Ledger::exists(Keylet const& k) const { // VFALCO NOTE Perhaps check the type for debug builds? - return stateMap_->hasItem(k.key); + return stateMap_.hasItem(k.key); } bool Ledger::exists(uint256 const& key) const { - return stateMap_->hasItem(key); + return stateMap_.hasItem(key); } std::optional Ledger::succ(uint256 const& key, std::optional const& last) const { - auto item = stateMap_->upper_bound(key); - if (item == stateMap_->end()) + auto item = stateMap_.upper_bound(key); + if (item == stateMap_.end()) return std::nullopt; if (last && item->key() >= last) return std::nullopt; @@ -467,7 +457,7 @@ Ledger::read(Keylet const& k) const assert(false); return nullptr; } - auto const& item = stateMap_->peekItem(k.key); + auto const& item = stateMap_.peekItem(k.key); if (!item) return nullptr; auto sle = std::make_shared(SerialIter{item->slice()}, item->key()); @@ -481,45 +471,44 @@ Ledger::read(Keylet const& k) const auto Ledger::slesBegin() const -> std::unique_ptr { - return std::make_unique(stateMap_->begin()); + return std::make_unique(stateMap_.begin()); } auto Ledger::slesEnd() const -> std::unique_ptr { - return std::make_unique(stateMap_->end()); + return std::make_unique(stateMap_.end()); } auto Ledger::slesUpperBound(uint256 const& key) const -> std::unique_ptr { - return std::make_unique(stateMap_->upper_bound(key)); + return std::make_unique(stateMap_.upper_bound(key)); } auto Ledger::txsBegin() const -> std::unique_ptr { - return std::make_unique(!open(), txMap_->begin()); + return std::make_unique(!open(), txMap_.begin()); } auto Ledger::txsEnd() const -> std::unique_ptr { - return std::make_unique(!open(), txMap_->end()); + return std::make_unique(!open(), txMap_.end()); } bool Ledger::txExists(uint256 const& key) const { - return txMap_->hasItem(key); + return txMap_.hasItem(key); } auto Ledger::txRead(key_type const& key) const -> tx_type { - assert(txMap_); - auto const& item = txMap_->peekItem(key); + auto const& item = txMap_.peekItem(key); if (!item) return {}; if (!open()) @@ -536,7 +525,7 @@ Ledger::digest(key_type const& key) const -> std::optional SHAMapHash digest; // VFALCO Unfortunately this loads the item // from the NodeStore needlessly. - if (!stateMap_->peekItem(key, digest)) + if (!stateMap_.peekItem(key, digest)) return std::nullopt; return digest.as_uint256(); } @@ -546,14 +535,14 @@ Ledger::digest(key_type const& key) const -> std::optional void Ledger::rawErase(std::shared_ptr const& sle) { - if (!stateMap_->delItem(sle->key())) + if (!stateMap_.delItem(sle->key())) LogicError("Ledger::rawErase: key not found"); } void Ledger::rawErase(uint256 const& key) { - if (!stateMap_->delItem(key)) + if (!stateMap_.delItem(key)) LogicError("Ledger::rawErase: key not found"); } @@ -562,7 +551,7 @@ Ledger::rawInsert(std::shared_ptr const& sle) { Serializer ss; sle->add(ss); - if (!stateMap_->addGiveItem( + if (!stateMap_.addGiveItem( SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice()))) LogicError("Ledger::rawInsert: key already exists"); @@ -573,7 +562,7 @@ Ledger::rawReplace(std::shared_ptr const& sle) { Serializer ss; sle->add(ss); - if (!stateMap_->updateGiveItem( + if (!stateMap_.updateGiveItem( SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice()))) LogicError("Ledger::rawReplace: key not found"); @@ -591,7 +580,7 @@ Ledger::rawTxInsert( Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); s.addVL(txn->peekData()); s.addVL(metaData->peekData()); - if (!txMap().addGiveItem( + if (!txMap_.addGiveItem( SHAMapNodeType::tnTRANSACTION_MD, make_shamapitem(key, s.slice()))) LogicError("duplicate_tx: " + to_string(key)); } @@ -610,7 +599,7 @@ Ledger::rawTxInsertWithHash( s.addVL(metaData->peekData()); auto item = make_shamapitem(key, s.slice()); auto hash = sha512Half(HashPrefix::txNode, item->slice(), item->key()); - if (!txMap().addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, std::move(item))) + if (!txMap_.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, std::move(item))) LogicError("duplicate_tx: " + to_string(key)); return hash; @@ -710,7 +699,7 @@ Ledger::defaultFees(Config const& config) std::shared_ptr Ledger::peek(Keylet const& k) const { - auto const& value = stateMap_->peekItem(k.key); + auto const& value = stateMap_.peekItem(k.key); if (!value) return nullptr; auto sle = std::make_shared(SerialIter{value->slice()}, value->key()); @@ -832,8 +821,8 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const std::vector missingNodes1; std::vector missingNodes2; - if (stateMap_->getHash().isZero() && !info_.accountHash.isZero() && - !stateMap_->fetchRoot(SHAMapHash{info_.accountHash}, nullptr)) + if (stateMap_.getHash().isZero() && !info_.accountHash.isZero() && + !stateMap_.fetchRoot(SHAMapHash{info_.accountHash}, nullptr)) { missingNodes1.emplace_back( SHAMapType::STATE, SHAMapHash{info_.accountHash}); @@ -841,9 +830,9 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const else { if (parallel) - return stateMap_->walkMapParallel(missingNodes1, 32); + return stateMap_.walkMapParallel(missingNodes1, 32); else - stateMap_->walkMap(missingNodes1, 32); + stateMap_.walkMap(missingNodes1, 32); } if (!missingNodes1.empty()) @@ -855,15 +844,15 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const } } - if (txMap_->getHash().isZero() && info_.txHash.isNonZero() && - !txMap_->fetchRoot(SHAMapHash{info_.txHash}, nullptr)) + if (txMap_.getHash().isZero() && info_.txHash.isNonZero() && + !txMap_.fetchRoot(SHAMapHash{info_.txHash}, nullptr)) { missingNodes2.emplace_back( SHAMapType::TRANSACTION, SHAMapHash{info_.txHash}); } else { - txMap_->walkMap(missingNodes2, 32); + txMap_.walkMap(missingNodes2, 32); } if (!missingNodes2.empty()) @@ -880,9 +869,9 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const bool Ledger::assertSensible(beast::Journal ledgerJ) const { - if (info_.hash.isNonZero() && info_.accountHash.isNonZero() && stateMap_ && - txMap_ && (info_.accountHash == stateMap_->getHash().as_uint256()) && - (info_.txHash == txMap_->getHash().as_uint256())) + if (info_.hash.isNonZero() && info_.accountHash.isNonZero() && + (info_.accountHash == stateMap_.getHash().as_uint256()) && + (info_.txHash == txMap_.getHash().as_uint256())) { return true; } @@ -1044,15 +1033,14 @@ pendSaveValidated( return true; } - JobType const jobType{isCurrent ? jtPUBLEDGER : jtPUBOLDLEDGER}; - char const* const jobName{ - isCurrent ? "Ledger::pendSave" : "Ledger::pendOldSave"}; - // See if we can use the JobQueue. if (!isSynchronous && - app.getJobQueue().addJob(jobType, jobName, [&app, ledger, isCurrent]() { - saveValidatedLedger(app, ledger, isCurrent); - })) + app.getJobQueue().addJob( + isCurrent ? jtPUBLEDGER : jtPUBOLDLEDGER, + std::to_string(ledger->seq()), + [&app, ledger, isCurrent]() { + saveValidatedLedger(app, ledger, isCurrent); + })) { return true; } @@ -1064,15 +1052,15 @@ pendSaveValidated( void Ledger::unshare() const { - stateMap_->unshare(); - txMap_->unshare(); + stateMap_.unshare(); + txMap_.unshare(); } void Ledger::invariants() const { - stateMap_->invariants(); - txMap_->invariants(); + stateMap_.invariants(); + txMap_.invariants(); } //------------------------------------------------------------------------------ diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index 84e65ecffc7..051b322e27a 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -83,6 +83,10 @@ class Ledger final : public std::enable_shared_from_this, Ledger& operator=(Ledger const&) = delete; + Ledger(Ledger&&) = delete; + Ledger& + operator=(Ledger&&) = delete; + /** Create the Genesis ledger. The Genesis ledger contains a single account whose @@ -290,10 +294,10 @@ class Ledger final : public std::enable_shared_from_this, void setFull() const { - txMap_->setFull(); - stateMap_->setFull(); - txMap_->setLedgerSeq(info_.seq); - stateMap_->setLedgerSeq(info_.seq); + txMap_.setFull(); + txMap_.setLedgerSeq(info_.seq); + stateMap_.setFull(); + stateMap_.setLedgerSeq(info_.seq); } void @@ -305,25 +309,25 @@ class Ledger final : public std::enable_shared_from_this, SHAMap const& stateMap() const { - return *stateMap_; + return stateMap_; } SHAMap& stateMap() { - return *stateMap_; + return stateMap_; } SHAMap const& txMap() const { - return *txMap_; + return txMap_; } SHAMap& txMap() { - return *txMap_; + return txMap_; } // returns false on error @@ -401,8 +405,11 @@ class Ledger final : public std::enable_shared_from_this, bool mImmutable; - std::shared_ptr txMap_; - std::shared_ptr stateMap_; + // A SHAMap containing the transactions associated with this ledger. + SHAMap mutable txMap_; + + // A SHAMap containing the state objects for this ledger. + SHAMap mutable stateMap_; // Protects fee variables std::mutex mutable mutex_; diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index 53c723e1469..ed2ccd07434 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -51,7 +51,9 @@ LedgerHistory::LedgerHistory( } bool -LedgerHistory::insert(std::shared_ptr ledger, bool validated) +LedgerHistory::insert( + std::shared_ptr const& ledger, + bool validated) { if (!ledger->isImmutable()) LogicError("mutable Ledger in insert"); @@ -72,12 +74,9 @@ LedgerHash LedgerHistory::getLedgerHash(LedgerIndex index) { std::unique_lock sl(m_ledgers_by_hash.peekMutex()); - auto it = mLedgersByIndex.find(index); - - if (it != mLedgersByIndex.end()) + if (auto it = mLedgersByIndex.find(index); it != mLedgersByIndex.end()) return it->second; - - return uint256(); + return {}; } std::shared_ptr @@ -167,19 +166,19 @@ log_metadata_difference( uint256 const& tx, beast::Journal j) { - auto getMeta = [](ReadView const& ledger, - uint256 const& txID) -> std::shared_ptr { - auto meta = ledger.txRead(txID).second; - if (!meta) - return {}; - return std::make_shared(txID, ledger.seq(), *meta); + auto getMeta = [](ReadView const& ledger, uint256 const& txID) { + std::optional ret; + if (auto meta = ledger.txRead(txID).second) + ret.emplace(txID, ledger.seq(), *meta); + return ret; }; auto validMetaData = getMeta(validLedger, tx); auto builtMetaData = getMeta(builtLedger, tx); - assert(validMetaData != nullptr || builtMetaData != nullptr); - if (validMetaData != nullptr && builtMetaData != nullptr) + assert(validMetaData || builtMetaData); + + if (validMetaData && builtMetaData) { auto const& validNodes = validMetaData->getNodes(); auto const& builtNodes = builtMetaData->getNodes(); @@ -280,17 +279,21 @@ log_metadata_difference( << validNodes.getJson(JsonOptions::none); } } + + return; } - else if (validMetaData != nullptr) + + if (validMetaData) { JLOG(j.error()) << "MISMATCH on TX " << tx - << ": Metadata Difference (built has none)\n" + << ": Metadata Difference. Valid=\n" << validMetaData->getJson(JsonOptions::none); } - else // builtMetaData != nullptr + + if (builtMetaData) { JLOG(j.error()) << "MISMATCH on TX " << tx - << ": Metadata Difference (valid has none)\n" + << ": Metadata Difference. Built=\n" << builtMetaData->getJson(JsonOptions::none); } } diff --git a/src/ripple/app/ledger/LedgerHistory.h b/src/ripple/app/ledger/LedgerHistory.h index be5c559beed..5733ca76375 100644 --- a/src/ripple/app/ledger/LedgerHistory.h +++ b/src/ripple/app/ledger/LedgerHistory.h @@ -44,7 +44,7 @@ class LedgerHistory @return `true` if the ledger was already tracked */ bool - insert(std::shared_ptr ledger, bool validated); + insert(std::shared_ptr const& ledger, bool validated); /** Get the ledgers_by_hash cache hit rate @return the hit rate diff --git a/src/ripple/app/ledger/impl/LedgerToJson.cpp b/src/ripple/app/ledger/impl/LedgerToJson.cpp index e32303c492d..558757d511b 100644 --- a/src/ripple/app/ledger/impl/LedgerToJson.cpp +++ b/src/ripple/app/ledger/impl/LedgerToJson.cpp @@ -131,14 +131,14 @@ fillJsonTx( if (stMeta) { txJson[jss::metaData] = stMeta->getJson(JsonOptions::none); + + // If applicable, insert delivered amount if (txnType == ttPAYMENT || txnType == ttCHECK_CASH) - { - // Insert delivered amount - auto txMeta = std::make_shared( - txn->getTransactionID(), fill.ledger.seq(), *stMeta); RPC::insertDeliveredAmount( - txJson[jss::metaData], fill.ledger, txn, *txMeta); - } + txJson[jss::metaData], + fill.ledger, + txn, + {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); } } diff --git a/src/ripple/app/rdb/impl/UnitaryShard.cpp b/src/ripple/app/rdb/impl/UnitaryShard.cpp index 72441d0b75a..37cbfd55ac3 100644 --- a/src/ripple/app/rdb/impl/UnitaryShard.cpp +++ b/src/ripple/app/rdb/impl/UnitaryShard.cpp @@ -103,22 +103,24 @@ updateLedgerDBs( for (auto const& item : ledger->txs) { - if (stop) + if (stop.load(std::memory_order_relaxed)) return false; - auto const txID{item.first->getTransactionID()}; - auto const sTxID{to_string(txID)}; - auto const txMeta{std::make_shared( - txID, ledger->seq(), *item.second)}; + TxMeta const txMeta{ + item.first->getTransactionID(), + ledger->seq(), + *item.second}; + + auto const sTxID = to_string(txMeta.getTxID()); session << "DELETE FROM AccountTransactions " "WHERE TransID = :txID;", soci::use(sTxID); - auto const& accounts = txMeta->getAffectedAccounts(); + auto const& accounts = txMeta.getAffectedAccounts(); if (!accounts.empty()) { - auto const sTxnSeq{std::to_string(txMeta->getIndex())}; + auto const sTxnSeq{std::to_string(txMeta.getIndex())}; auto const s{boost::str( boost::format("('%s','%s',%s,%s)") % sTxID % "%s" % sSeq % sTxnSeq)}; diff --git a/src/ripple/nodestore/impl/DecodedBlob.cpp b/src/ripple/nodestore/impl/DecodedBlob.cpp index debb907b73b..13175d36295 100644 --- a/src/ripple/nodestore/impl/DecodedBlob.cpp +++ b/src/ripple/nodestore/impl/DecodedBlob.cpp @@ -38,7 +38,6 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) m_success = false; m_key = key; - // VFALCO NOTE Ledger indexes should hav e started at 1 m_objectType = hotUNKNOWN; m_objectData = nullptr; m_dataBytes = std::max(0, valueBytes - 9); diff --git a/src/ripple/protocol/impl/TxMeta.cpp b/src/ripple/protocol/impl/TxMeta.cpp index 9e199176515..20fa61de2a8 100644 --- a/src/ripple/protocol/impl/TxMeta.cpp +++ b/src/ripple/protocol/impl/TxMeta.cpp @@ -126,8 +126,7 @@ TxMeta::getAffectedAccounts() const if (index != -1) { - const STObject* inner = - dynamic_cast(&it.peekAtIndex(index)); + auto inner = dynamic_cast(&it.peekAtIndex(index)); assert(inner); if (inner) { @@ -145,8 +144,7 @@ TxMeta::getAffectedAccounts() const (field.getFName() == sfTakerPays) || (field.getFName() == sfTakerGets)) { - const STAmount* lim = - dynamic_cast(&field); + auto lim = dynamic_cast(&field); assert(lim); if (lim != nullptr) diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index 2170cf020e9..2d1aa192fc6 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -124,10 +124,14 @@ class SHAMap boost::intrusive_ptr>; using Delta = std::map; + SHAMap() = delete; SHAMap(SHAMap const&) = delete; SHAMap& operator=(SHAMap const&) = delete; + // Take a snapshot of the given map: + SHAMap(SHAMap const& other, bool isMutable); + // build new map SHAMap(SHAMapType t, Family& f); diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 51a11680c93..d6348c86c48 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -66,28 +66,28 @@ SHAMap::SHAMap(SHAMapType t, uint256 const& hash, Family& f) root_ = std::make_shared(cowid_); } -std::shared_ptr -SHAMap::snapShot(bool isMutable) const +SHAMap::SHAMap(SHAMap const& other, bool isMutable) + : f_(other.f_) + , journal_(other.f_.journal()) + , cowid_(other.cowid_ + 1) + , ledgerSeq_(other.ledgerSeq_) + , root_(other.root_) + , state_(isMutable ? SHAMapState::Modifying : SHAMapState::Immutable) + , type_(other.type_) + , backed_(other.backed_) { - auto ret = std::make_shared(type_, f_); - SHAMap& newMap = *ret; - - if (!isMutable) - newMap.state_ = SHAMapState::Immutable; - - newMap.cowid_ = cowid_ + 1; - newMap.ledgerSeq_ = ledgerSeq_; - newMap.root_ = root_; - newMap.backed_ = backed_; - + // If either map may change, they cannot share nodes if ((state_ != SHAMapState::Immutable) || - (newMap.state_ != SHAMapState::Immutable)) + (other.state_ != SHAMapState::Immutable)) { - // If either map may change, they cannot share nodes - newMap.unshare(); + unshare(); } +} - return ret; +std::shared_ptr +SHAMap::snapShot(bool isMutable) const +{ + return std::make_shared(*this, isMutable); } void @@ -174,7 +174,6 @@ SHAMap::finishFetch( { assert(backed_); - std::shared_ptr node; try { if (!object) @@ -187,27 +186,23 @@ SHAMap::finishFetch( return {}; } - node = + auto node = SHAMapTreeNode::makeFromPrefix(makeSlice(object->getData()), hash); if (node) canonicalize(hash, node); return node; } - - catch (SHAMapMissingNode const& e) - { - JLOG(journal_.warn()) << "Missing node: " << hash << " : " << e.what(); - } catch (std::runtime_error const& e) { - JLOG(journal_.warn()) << __func__ << " : " << e.what(); + JLOG(journal_.warn()) << "finishFetch exception: " << e.what(); } catch (...) { - JLOG(journal_.warn()) << "Invalid DB node " << hash; + JLOG(journal_.warn()) + << "finishFetch exception: unknonw exception: " << hash; } - return std::shared_ptr(); + return {}; } // See if a sync filter has a node