#pragma once

#include "daemon_controller.h"
#include "../util/async_task_manager.h"

#include <atomic>
#include <filesystem>

namespace dragonx {
namespace daemon {

class AsyncLifecycleTaskContext final : public DaemonController::LifecycleTaskContext {
public:
    AsyncLifecycleTaskContext(const util::AsyncTaskManager::Token& token,
                              const std::atomic<bool>& shuttingDown);

    bool cancelled() const override;
    bool shuttingDown() const override;
    void sleepForMs(int milliseconds) override;

private:
    const util::AsyncTaskManager::Token& token_;
    const std::atomic<bool>& shuttingDown_;
};

class ImmediateLifecycleTaskContext final : public DaemonController::LifecycleTaskContext {
public:
    bool cancelled() const override;
    bool shuttingDown() const override;
    void sleepForMs(int milliseconds) override;
};

class BlockchainDataCleaner final {
public:
    static int removeBlockchainData(const std::filesystem::path& dataDir);
};

} // namespace daemon
} // namespace dragonx