Skip to content

src/account/Migration3_4_0To3_5_0.hpp

More...

Namespaces

Name
sgns

Classes

Name
class sgns::Migration3_4_0To3_5_0
Migration step for version 1.0.0 to 3.4.0. Changes the full node topic from CRDT heads.

Detailed Description

Date: 2025-11-11 Henrique A. Klein ([email protected])

Source code

#pragma once

#include <string>
#include <memory>
#include <atomic>

#include "IMigrationStep.hpp"
#include "blockchain/Blockchain.hpp"
#include "crdt/globaldb/globaldb.hpp"
#include "outcome/outcome.hpp"
#include "base/logger.hpp"

namespace sgns
{
    class GeniusAccount;

    class Migration3_4_0To3_5_0 : public IMigrationStep, public std::enable_shared_from_this<Migration3_4_0To3_5_0>
    {
    public:
        Migration3_4_0To3_5_0( 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 );
        ~Migration3_4_0To3_5_0() override;

        std::string FromVersion() const override;

        std::string ToVersion() const override;

        outcome::result<void> Init() override;

        outcome::result<bool> IsRequired() const override;

        outcome::result<void> Apply() override;

        outcome::result<void> ShutDown() override;

    private:
        enum class Status
        {
            ST_INIT = 0,
            ST_ERROR,
            ST_SUCCESS,
        };
        outcome::result<std::shared_ptr<crdt::GlobalDB>>                InitLegacyDb();
        outcome::result<std::shared_ptr<crdt::GlobalDB>>                InitTargetDb();
        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_;                                 
        base::Logger                    logger_ = base::createLogger( "MigrationStep" ); 
        std::shared_ptr<crdt::GlobalDB> db_3_5_0_;                                       
        std::shared_ptr<crdt::GlobalDB> db_3_4_0_;                                       
        std::shared_ptr<Blockchain>     blockchain_;
        std::shared_ptr<GeniusAccount>  account_;
        std::atomic<Status>             blockchain_status_{ Status::ST_INIT };
    };

}

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