Commit f22476cb authored by jan.koester's avatar jan.koester
Browse files

test

parent db9743af
Loading
Loading
Loading
Loading
Loading
+17 −0
Changes for src/cluster.cpp: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -224,6 +224,23 @@ namespace authdb {

        server_ = std::make_unique<paritypp::server>(scfg, store_, auth_);

        // Register peer status callback so GET_STATUS reports correct peer counts.
        // We use the config peer count as total, and probe each peer for online count.
        server_->set_peer_status_callback([this]() -> std::pair<uint32_t, uint32_t> {
            if (!pclient_) return {0, 0};
            std::lock_guard<std::mutex> lock(client_mutex_);
            uint32_t total = static_cast<uint32_t>(cfg_.peers.size() - 1); // minus self
            uint32_t online = 0;
            // Quick probe: try get_node_status on each peer
            for (uint32_t i = 0; i < total; i++) {
                paritypp::status_info info;
                if (pclient_->get_node_status(i, info)) {
                    online++;
                }
            }
            return {total, online};
        });

        // Setup client for talking to peers — filter out self
        if (!cfg_.peers.empty()) {
            char hostname[256] = {};