From 9af0ab9eda9bf5a694239081d4a3a4f1058496c3 Mon Sep 17 00:00:00 2001 From: cyjseagull Date: Wed, 4 Dec 2024 16:31:34 +0800 Subject: [PATCH] add agencyID to psi/mpc serviceName --- cpp/wedpr-helper/ppc-utilities/Utilities.h | 5 +++++ cpp/wedpr-initializer/Initializer.cpp | 6 ++++-- cpp/wedpr-main/mpc-node/MPCInitializer.cpp | 11 ++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cpp/wedpr-helper/ppc-utilities/Utilities.h b/cpp/wedpr-helper/ppc-utilities/Utilities.h index c5e52009..9832b65d 100644 --- a/cpp/wedpr-helper/ppc-utilities/Utilities.h +++ b/cpp/wedpr-helper/ppc-utilities/Utilities.h @@ -64,6 +64,11 @@ inline std::string generateUUID() static thread_local auto uuid_gen = boost::uuids::basic_random_generator(); return boost::uuids::to_string(uuid_gen()); } + +inline std::string getServiceName(std::string const& agencyID, std::string const& serviceID) +{ + return agencyID + "_" + serviceID; +} template inline std::string printVector(T const& list) { diff --git a/cpp/wedpr-initializer/Initializer.cpp b/cpp/wedpr-initializer/Initializer.cpp index 384fd44a..a0ecaea0 100644 --- a/cpp/wedpr-initializer/Initializer.cpp +++ b/cpp/wedpr-initializer/Initializer.cpp @@ -40,6 +40,7 @@ #include "ppc-psi/src/labeled-psi/LabeledPSIFactory.h" #include "ppc-psi/src/ra2018-psi/RA2018PSIFactory.h" #include "ppc-tools/src/config/PPCConfig.h" +#include "wedpr-helper/ppc-utilities/Utilities.h" #include #include @@ -86,8 +87,9 @@ void Initializer::init(ppc::gateway::IGateway::Ptr const& gateway) TransportBuilder transportBuilder; // register the serviceInfo auto serviceConfig = m_serviceConfigBuilder.buildServiceConfig(); - auto entryPoint = - m_serviceConfigBuilder.buildEntryPoint(PSI_SERVICE_TYPE, m_config->accessEntrypoint()); + auto entryPoint = m_serviceConfigBuilder.buildEntryPoint( + getServiceName(m_config->agencyID(), PSI_SERVICE_TYPE), m_config->accessEntrypoint()); + serviceConfig.addEntryPoint(entryPoint); auto serviceMeta = serviceConfig.encode(); m_config->frontConfig()->setMeta(serviceMeta); diff --git a/cpp/wedpr-main/mpc-node/MPCInitializer.cpp b/cpp/wedpr-main/mpc-node/MPCInitializer.cpp index afe8dd20..36187f03 100644 --- a/cpp/wedpr-main/mpc-node/MPCInitializer.cpp +++ b/cpp/wedpr-main/mpc-node/MPCInitializer.cpp @@ -22,6 +22,7 @@ #include "ppc-framework/protocol/Constant.h" #include "ppc-mpc/src/MPCService.h" #include "ppc-tools/src/config/PPCConfig.h" +#include "wedpr-helper/ppc-utilities/Utilities.h" #include "wedpr-protocol/protocol/src/ServiceConfig.h" #include "wedpr-transport/sdk/src/TransportBuilder.h" @@ -61,7 +62,7 @@ void MPCInitializer::init(std::string const& _configPath) auto threadPool = std::make_shared("mpc-pool", threadPoolSize); INIT_LOG(INFO) << LOG_DESC("init the mpc threadpool") - << LOG_KV("threadPoolSize", threadPoolSize); + << LOG_KV("threadPoolSize", threadPoolSize); auto mpcService = std::make_shared(); mpcService->setMPCConfig(mpcConfig); @@ -71,11 +72,11 @@ void MPCInitializer::init(std::string const& _configPath) m_rpc->registerHandler("run", std::bind(&MPCService::runMpcRpc, mpcService, std::placeholders::_1, std::placeholders::_2)); m_rpc->registerHandler("asyncRun", std::bind(&MPCService::asyncRunMpcRpc, mpcService, - std::placeholders::_1, std::placeholders::_2)); + std::placeholders::_1, std::placeholders::_2)); m_rpc->registerHandler("kill", std::bind(&MPCService::killMpcRpc, mpcService, std::placeholders::_1, std::placeholders::_2)); m_rpc->registerHandler("query", std::bind(&MPCService::queryMpcRpc, mpcService, - std::placeholders::_1, std::placeholders::_2)); + std::placeholders::_1, std::placeholders::_2)); INIT_LOG(INFO) << LOG_DESC("init the mpc rpc success"); // init the transport initTransport(pt); @@ -89,8 +90,8 @@ void MPCInitializer::initTransport(boost::property_tree::ptree const& property) // add the service meta ServiceConfigBuilder serviceConfigBuilder; - auto entryPoint = - serviceConfigBuilder.buildEntryPoint(MPC_SERVICE_TYPE, m_config->accessEntrypoint()); + auto entryPoint = serviceConfigBuilder.buildEntryPoint( + getServiceName(m_config->agencyID(), MPC_SERVICE_TYPE), m_config->accessEntrypoint()); auto serviceConfig = serviceConfigBuilder.buildServiceConfig(); serviceConfig.addEntryPoint(entryPoint); auto serviceMeta = serviceConfig.encode();