Commit 8f644c46 authored by jan.koester's avatar jan.koester
Browse files

test

parent 743178aa
Loading
Loading
Loading
Loading
Loading
+7 −8
Changes for src/cluster.cpp: 7 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -196,19 +196,18 @@ namespace authdb {

        // Setup client for talking to peers
        if (!cfg_.peers.empty() && cfg_.peers.size() >= cfg_.data_blocks + cfg_.parity_blocks) {
            std::vector<::paritypp::client::node_info> nodes;
            std::vector<paritypp::client::node_info> nodes;
            for (const auto &peer : cfg_.peers) {
                nodes.push_back({peer.address, peer.port});
            }

            ::paritypp::client::credentials pcreds;
            paritypp::client::credentials pcreds;
            if (!cfg_.client_name.empty()) {
                pcreds.client_name = cfg_.client_name;
                pcreds.key.assign(cfg_.client_key.begin(), cfg_.client_key.end());
            }

            pclient_ = std::make_unique<PClient>();
            pclient_->impl = std::make_unique<::paritypp::client>(
            pclient_ = std::make_unique<paritypp::client>(
                cfg_.data_blocks, cfg_.parity_blocks, nodes, pcreds);
        }
    }
@@ -238,7 +237,7 @@ namespace authdb {
    }

    void Cluster::pushSession(const SessionData &sess) {
        if (!pclient_ || !pclient_->impl) return;
        if (!pclient_) return;

        auto data = SessionBlock::serialize(sess);

@@ -254,7 +253,7 @@ namespace authdb {
        // Distribute to peers with parity encoding
        try {
            std::lock_guard<std::mutex> lock(client_mutex_);
            pclient_->impl->store(data);
            pclient_->store(data);
        } catch (const std::exception &e) {
            // Log but don't fail - local session still valid
            std::cerr << "Cluster push failed: " << e.what() << std::endl;
@@ -285,10 +284,10 @@ namespace authdb {
        store_->remove_group(gid);

        // Remove from peers
        if (pclient_ && pclient_->impl) {
        if (pclient_) {
            try {
                std::lock_guard<std::mutex> lock(client_mutex_);
                pclient_->impl->remove(gid);
                pclient_->remove(gid);
            } catch (...) {}
        }
    }
+1 −3
Changes for src/cluster.h: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -117,9 +117,7 @@ namespace authdb {
        std::shared_ptr<paritypp::auth_store> auth_;
        std::unique_ptr<paritypp::server> server_;

        // Opaque pointer to avoid paritypp::client name clash with authdb::client
        struct PClient;
        std::unique_ptr<PClient> pclient_;
        std::unique_ptr<paritypp::client> pclient_;
        std::mutex client_mutex_;

        void server_loop();