MCPcopy Create free account
hub / github.com/XTXMarkets/ternfs / fetchCDCReplicas

Function fetchCDCReplicas

cpp/core/RegistryClient.cpp:372–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372std::pair<int, std::string> fetchCDCReplicas(
373 const std::string& addr, uint16_t port, Duration timeout, std::array<AddrsInfo, 5>& replicas
374) {
375 const auto [sock, errStr] = registrySock(addr, port, timeout);
376 if (sock.error()) {
377 return {sock.getErrno(), errStr};
378 }
379
380 RegistryReqContainer reqContainer;
381 auto& req = reqContainer.setCdcReplicasDEPRECATED();
382
383 {
384 const auto [err, errStr] = writeRegistryRequest(sock.get(), reqContainer, timeout);
385 if (err) { return {err, errStr}; }
386 }
387
388 RegistryRespContainer respContainer;
389 {
390 const auto [err, errStr] = readRegistryResponse(sock.get(), respContainer, timeout);
391 if (err) { return {err, errStr}; }
392 }
393
394 if (respContainer.getCdcReplicasDEPRECATED().replicas.els.size() != replicas.size()) {
395 throw TERN_EXCEPTION("expecting %s replicas, got %s", replicas.size(), respContainer.getCdcReplicasDEPRECATED().replicas.els.size());
396 }
397 for (int i = 0; i < replicas.size(); i++) {
398 replicas[i] = respContainer.getCdcReplicasDEPRECATED().replicas.els[i];
399 }
400
401 return {};
402}
403
404std::pair<int, std::string> fetchLocalShards(const std::string& host, uint16_t port, Duration timeout, std::array<ShardInfo, 256>& shards) {
405 const auto [sock, errStr] = registrySock(host, port, timeout);

Callers 1

periodicStepMethod · 0.85

Calls 7

registrySockFunction · 0.85
getErrnoMethod · 0.80
getMethod · 0.80
writeRegistryRequestFunction · 0.70
readRegistryResponseFunction · 0.70
errorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected