#pragma once

#include <cstdint>
#include <string>
#include <vector>

namespace tw::p2p {

class PeerRegistry {
public:
    struct PeerInfo {
        uint32_t id;
        std::string address;
    };

    explicit PeerRegistry(std::string file_path);

    // Blocks until the file lock is acquired, appends this node's entry, then releases.
    void register_self(uint32_t id, const std::string& address);

    std::vector<PeerInfo> read_all() const;

private:
    std::string m_file_path;
};

}
