diff --git a/src/ripple/app/ledger/LedgerMaster.cpp b/src/ripple/app/ledger/LedgerMaster.cpp index ee7b95dee..4a8b07fea 100644 --- a/src/ripple/app/ledger/LedgerMaster.cpp +++ b/src/ripple/app/ledger/LedgerMaster.cpp @@ -394,8 +394,9 @@ public: } if (didApply) { - mCurrentLedger.set (ledger); - getApp().getOPs ().pubProposedTransaction (ledger, txn, result); + ledger->setImmutable (); // So the next line doesn't have to copy + mCurrentLedger.set (ledger); + getApp().getOPs ().pubProposedTransaction (ledger, txn, result); } return result; } diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 3e70418eb..6cff83eac 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -1084,6 +1084,7 @@ void ApplicationImp::startNewLedger () firstLedger->updateHash (); firstLedger->setClosed (); firstLedger->setAccepted (); + firstLedger->setImmutable(); m_ledgerMaster->pushLedger (firstLedger); Ledger::pointer secondLedger = std::make_shared (true, std::ref (*firstLedger)); diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index c97cb18fe..2fac043b8 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -274,6 +274,7 @@ void SHAMap::setImmutable () { assert (state_ != SHAMapState::Invalid); + unshare (); state_ = SHAMapState::Immutable; } diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index e043e5662..962ae1207 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -75,7 +75,7 @@ SHAMap::snapShot (bool isMutable) const newMap.seq_ = seq_ + 1; newMap.root_ = root_; - if ((state_ != SHAMapState::Immutable) || !isMutable) + if ((state_ != SHAMapState::Immutable) || isMutable) { // If either map may change, they cannot share nodes newMap.unshare ();