diff --git a/kvbc/include/Replica.h b/kvbc/include/Replica.h index 5fffc1c3d6..9281201cc7 100644 --- a/kvbc/include/Replica.h +++ b/kvbc/include/Replica.h @@ -244,7 +244,7 @@ class Replica : public IReplica, bftEngine::IReplica::IReplicaPtr m_replicaPtr = nullptr; std::shared_ptr m_cmdHandler = nullptr; bftEngine::IStateTransfer *m_stateTransfer = nullptr; - concord::storage::DBMetadataStorage *m_metadataStorage = nullptr; + std::unique_ptr m_metadataStorage; std::unique_ptr replicaStateSync_; std::shared_ptr aggregator_; std::shared_ptr pm_; diff --git a/kvbc/src/Replica.cpp b/kvbc/src/Replica.cpp index 7b3e3663fc..2a62be2fb7 100644 --- a/kvbc/src/Replica.cpp +++ b/kvbc/src/Replica.cpp @@ -65,7 +65,7 @@ Status Replica::initInternals() { auto requestHandler = bftEngine::IRequestsHandler::createRequestsHandler(m_cmdHandler, cronTableRegistry_); requestHandler->setReconfigurationHandler(std::make_shared(*this)); m_replicaPtr = bftEngine::IReplica::createNewRoReplica( - replicaConfig_, requestHandler, m_stateTransfer, m_ptrComm.get(), m_metadataStorage); + replicaConfig_, requestHandler, m_stateTransfer, m_ptrComm.get(), m_metadataStorage.get()); m_stateTransfer->addOnTransferringCompleteCallback([this](std::uint64_t) { std::vector stateFromReservedPages; uint64_t wedgePt{0}; @@ -308,7 +308,7 @@ void Replica::createReplicaAndSyncState() { requestHandler, m_stateTransfer, m_ptrComm.get(), - m_metadataStorage, + m_metadataStorage.get(), pm_, secretsManager_, std::bind(&AdaptivePruningManager::setPrimary, &AdaptivePruningManager_, std::placeholders::_1)); @@ -604,10 +604,11 @@ Replica::Replica(ICommunication *comm, if (!replicaConfig.isReadOnly) { stReconfigurationSM_ = std::make_unique( *m_stateTransfer, *this, this->AdaptivePruningManager_, this->replicaResources_); - m_metadataStorage = new DBMetadataStorage(m_metadataDBClient.get(), storageFactory->newMetadataKeyManipulator()); + m_metadataStorage.reset( + new DBMetadataStorage(m_metadataDBClient.get(), storageFactory->newMetadataKeyManipulator())); } else { - m_metadataStorage = - new storage::DBMetadataStorageUnbounded(m_metadataDBClient.get(), storageFactory->newMetadataKeyManipulator()); + m_metadataStorage.reset( + new storage::DBMetadataStorageUnbounded(m_metadataDBClient.get(), storageFactory->newMetadataKeyManipulator())); } // Instantiate IControlHandler. // If an application instantiation has already taken a place this will have no effect.