Skip to content

src/account/MigrationManager.hpp

Versioned migration manager. More...

Namespaces

Name
sgns

Classes

Name
class sgns::MigrationManager
Executes a sequence of migration steps to update a CRDT store.

Functions

Name
OUTCOME_HPP_DECLARE_ERROR_2(sgns , MigrationManager::Error )

Detailed Description

Versioned migration manager.

Date: 2025-05-29 Luiz Guilherme Rizzatto Zucchi Henrique A. Klein ([email protected])

Functions Documentation

function OUTCOME_HPP_DECLARE_ERROR_2

OUTCOME_HPP_DECLARE_ERROR_2(
    sgns ,
    MigrationManager::Error 
)

Source code

#pragma once

#include <memory>
#include <deque>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <string>

#include <boost/asio/io_context.hpp>
#include <ipfs_pubsub/gossip_pubsub_topic.hpp>
#include "base/logger.hpp"
#include "upnp.hpp"
#include "crdt/globaldb/globaldb.hpp"
#include "outcome/outcome.hpp"
#include <ipfs_lite/ipfs/graphsync/impl/network/network.hpp>
#include <ipfs_lite/ipfs/graphsync/impl/local_requests.hpp>
#include <libp2p/protocol/common/asio/asio_scheduler.hpp>

#include "IMigrationStep.hpp"

namespace sgns
{
    class GeniusAccount;

    class MigrationManager : public std::enable_shared_from_this<MigrationManager>
    {
    public:
        enum class Error
        {
            BLOCKCHAIN_INIT_FAILED = 1,
        };
        static std::shared_ptr<MigrationManager> New(
            std::shared_ptr<boost::asio::io_context>                        ioContext,
            std::shared_ptr<ipfs_pubsub::GossipPubSub>                      pubSub,
            std::shared_ptr<ipfs_lite::ipfs::graphsync::Network>            graphsync,
            std::shared_ptr<libp2p::protocol::Scheduler>                    scheduler,
            std::shared_ptr<ipfs_lite::ipfs::graphsync::RequestIdGenerator> generator,
            std::string                                                     writeBasePath,
            std::string                                                     base58key,
            std::shared_ptr<GeniusAccount>                                  account );

        void RegisterStep( std::shared_ptr<IMigrationStep> step );

        outcome::result<void> Migrate();

        static constexpr std::string_view VERSION_INFO_KEY = "kSGNSCRDTVersion";

    private:
        MigrationManager();

        std::deque<std::shared_ptr<IMigrationStep>> steps_;               
        base::Logger m_logger = base::createLogger( "MigrationManager" ); 
    };
} // namespace sgns

OUTCOME_HPP_DECLARE_ERROR_2( sgns, MigrationManager::Error );

Updated on 2026-03-04 at 13:10:44 -0800