From 0cff742029a3d6389b64745ef8ec29545758739d Mon Sep 17 00:00:00 2001 From: Tarunkumar Banda Date: Tue, 24 May 2022 22:25:17 -0700 Subject: [PATCH] renamed concord client request cmf file --- client/client_pool/CMakeLists.txt | 2 +- .../client_pool/concord_client_pool.hpp | 2 +- .../client/client_pool/external_client.hpp | 10 ++++----- .../client_pool/src/concord_client_pool.cpp | 6 ++--- client/client_pool/src/external_client.cpp | 22 +++++++++---------- client/concordclient/CMakeLists.txt | 2 +- client/concordclient/cmf/CMakeLists.txt | 8 +++---- ...request.cmf => concord_client_message.cmf} | 8 +++++-- 8 files changed, 32 insertions(+), 28 deletions(-) rename client/concordclient/cmf/{concord_client_request.cmf => concord_client_message.cmf} (52%) diff --git a/client/client_pool/CMakeLists.txt b/client/client_pool/CMakeLists.txt index e310bd13f9..8420368739 100755 --- a/client/client_pool/CMakeLists.txt +++ b/client/client_pool/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries(concord_client_pool PUBLIC bftclient bftclient_new corebft - concord_client_request + concord_client_message ) install (TARGETS concord_client_pool DESTINATION lib${LIB_SUFFIX}) diff --git a/client/client_pool/include/client/client_pool/concord_client_pool.hpp b/client/client_pool/include/client/client_pool/concord_client_pool.hpp index 4c06356d7c..2e661a702f 100644 --- a/client/client_pool/include/client/client_pool/concord_client_pool.hpp +++ b/client/client_pool/include/client/client_pool/concord_client_pool.hpp @@ -120,7 +120,7 @@ class ConcordClientPool { std::string correlation_id = {}, const std::string& span_context = std::string(), const bftEngine::RequestType request_type = bftEngine::RequestType::RAW_MESSAGE, - const std::string& subscriptionId = std::string(), + const std::string& client_service_id = std::string(), const bftEngine::RequestCallBack& callback = {}); // This method is responsible to get write requests with the new client diff --git a/client/client_pool/include/client/client_pool/external_client.hpp b/client/client_pool/include/client/client_pool/external_client.hpp index dc25c1b1a7..54b4b0b7cd 100644 --- a/client/client_pool/include/client/client_pool/external_client.hpp +++ b/client/client_pool/include/client/client_pool/external_client.hpp @@ -21,7 +21,7 @@ #include "client_pool_config.hpp" #include "communication/StatusInfo.h" #include "external_client_exception.hpp" -#include "concord_client_request.cmf.hpp" +#include "concord_client_message.cmf.hpp" namespace concord { @@ -105,11 +105,11 @@ class ConcordClient { std::string messageSignature(bft::client::Msg&); - static void createConcordClientRequest(bft::client::Msg& request, - bftEngine::RequestType typed_request, - const std::string& subscriptionId); + static void prepareConcordClientRequest(bft::client::Msg& request, + bftEngine::RequestType request_type, + const std::string& client_service_id); - static void createConcordClientResponse(bft::client::Msg& response); + static void prepareConcordClientResponse(bft::client::Msg& response); private: void CreateClient(std::shared_ptr aggregator); diff --git a/client/client_pool/src/concord_client_pool.cpp b/client/client_pool/src/concord_client_pool.cpp index d5e03a575d..907db47c42 100644 --- a/client/client_pool/src/concord_client_pool.cpp +++ b/client/client_pool/src/concord_client_pool.cpp @@ -45,7 +45,7 @@ SubmitResult ConcordClientPool::SendRequest(std::vector &&request, std::string correlation_id, const std::string &span_context, const bftEngine::RequestType request_type, - const std::string &subscriptionId, + const std::string &client_service_id, const bftEngine::RequestCallBack &callback) { if (callback && timeout_ms.count() == 0) { callback(bftEngine::SendResult{static_cast(OperationResult::INVALID_REQUEST)}); @@ -58,7 +58,7 @@ SubmitResult ConcordClientPool::SendRequest(std::vector &&request, while (!clients_.empty() && serving_candidates != 0) { auto client = clients_.front(); - external_client::ConcordClient::createConcordClientRequest(request, request_type, subscriptionId); + external_client::ConcordClient::prepareConcordClientRequest(request, request_type, client_service_id); client_id = client->getClientId(); if (is_overloaded_) { is_overloaded_ = false; @@ -495,7 +495,7 @@ void SingleRequestProcessingJob::execute() { reply_size = res.matched_data.size(); if (callback_) { if (operation_result == OperationResult::SUCCESS) { - external_client::ConcordClient::createConcordClientResponse(res.matched_data); + external_client::ConcordClient::prepareConcordClientResponse(res.matched_data); reply_size = res.matched_data.size(); callback_(res); } else { diff --git a/client/client_pool/src/external_client.cpp b/client/client_pool/src/external_client.cpp index ff4e88a5b7..c1fc2d0342 100644 --- a/client/client_pool/src/external_client.cpp +++ b/client/client_pool/src/external_client.cpp @@ -195,7 +195,7 @@ std::pair ConcordClient::SendPendingRequ } auto cid = pending_seq_num_to_cid_entry->second; cid_response_map_[cid] = std::chrono::steady_clock::now(); - createConcordClientResponse(received_reply_entry.second.matched_data); + prepareConcordClientResponse(received_reply_entry.second.matched_data); auto data_size = received_reply_entry.second.matched_data.size(); for (auto& pending_reply : pending_replies_) { if (pending_reply.cid != cid) continue; @@ -386,20 +386,20 @@ OperationResult ConcordClient::getRequestExecutionResult() { return clientReques std::string ConcordClient::messageSignature(bft::client::Msg& message) { return new_client_->signMessage(message); } -void ConcordClient::createConcordClientRequest(bft::client::Msg& request, - bftEngine::RequestType typed_request, - const std::string& subscriptionId) { - concord::client::request::messages::ConcordClientRequest concord_request; - concord_request.type = static_cast(typed_request); - concord_request.client_id = static_cast(subscriptionId); +void ConcordClient::prepareConcordClientRequest(bft::client::Msg& request, + bftEngine::RequestType request_type, + const std::string& client_service_id) { + concord::client::message::ConcordClientRequest concord_request; + concord_request.request_type = static_cast(request_type); + concord_request.client_service_id = static_cast(client_service_id); concord_request.application_request = std::vector(request.begin(), request.end()); request.clear(); - concord::client::request::messages::serialize(request, concord_request); + concord::client::message::serialize(request, concord_request); } -void ConcordClient::createConcordClientResponse(bft::client::Msg& response) { - concord::client::request::messages::ConcordClientResponse concord_response; - concord::client::request::messages::deserialize(response, concord_response); +void ConcordClient::prepareConcordClientResponse(bft::client::Msg& response) { + concord::client::message::ConcordClientResponse concord_response; + concord::client::message::deserialize(response, concord_response); response.clear(); response.assign(concord_response.application_response.begin(), concord_response.application_response.end()); } diff --git a/client/concordclient/CMakeLists.txt b/client/concordclient/CMakeLists.txt index 77718332e2..2446ddef5a 100644 --- a/client/concordclient/CMakeLists.txt +++ b/client/concordclient/CMakeLists.txt @@ -6,7 +6,7 @@ add_subdirectory("cmf") target_link_libraries(concordclient PUBLIC thin_replica_client_lib - concord_client_request + concord_client_message concord_client_pool concordclient-event-api util diff --git a/client/concordclient/cmf/CMakeLists.txt b/client/concordclient/cmf/CMakeLists.txt index b4a8dbe0f7..5937916099 100644 --- a/client/concordclient/cmf/CMakeLists.txt +++ b/client/concordclient/cmf/CMakeLists.txt @@ -1,4 +1,4 @@ -cmf_generate_cpp(header cpp concord::client::request::messages concord_client_request.cmf) -add_library(concord_client_request ${cpp}) -set_target_properties(concord_client_request PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(concord_client_request PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +cmf_generate_cpp(header cpp concord::client::message concord_client_message.cmf) +add_library(concord_client_message ${cpp}) +set_target_properties(concord_client_message PROPERTIES LINKER_LANGUAGE CXX) +target_include_directories(concord_client_message PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/client/concordclient/cmf/concord_client_request.cmf b/client/concordclient/cmf/concord_client_message.cmf similarity index 52% rename from client/concordclient/cmf/concord_client_request.cmf rename to client/concordclient/cmf/concord_client_message.cmf index 083ab11b51..33f02f9e34 100644 --- a/client/concordclient/cmf/concord_client_request.cmf +++ b/client/concordclient/cmf/concord_client_message.cmf @@ -2,8 +2,12 @@ # with clientservice specific information to the blockchain network. Msg ConcordClientRequest 1 { - uint32 type - string client_id + # request_type is type of input request, which can be of RAW or ANY request + uint32 request_type + # Client service ID or thin replica client's subscription ID + # used for filtering events for this client. + string client_service_id + # Required application request which gets evaluated by the execution engine. bytes application_request }