Skip to content

Commit

Permalink
fix ecdh-psi not return status
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Nov 5, 2024
1 parent 4b41b2c commit 461be22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions cpp/ppc-framework/protocol/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ class TaskResult
virtual void setFileInfo(FileInfo::Ptr _fileInfo) { m_fileInfo = std::move(_fileInfo); }

// serialize the taskResult to json
virtual Json::Value serializeToJson() const
virtual Json::Value serializeToJson()
{
Json::Value response;
response["taskID"] = m_taskID;
if (!m_status.empty())
{
response["status"] = m_status;
}
if (m_timeCost)
{
response["timeCost"] = std::to_string(m_timeCost) + "ms";
Expand All @@ -81,15 +77,21 @@ class TaskResult
response["fileID"] = m_fileInfo->fileID;
response["fileMd5"] = m_fileInfo->fileMd5;
}
if (m_error)
if (m_error && m_error->errorCode() != 0)
{
response["code"] = m_error->errorCode();
response["message"] = m_error->errorMessage();
setStatus(ppc::protocol::toString(TaskStatus::FAILED));
}
else
{
response["code"] = 0;
response["message"] = "success";
sestStatus(ppc::protocol::toString(TaskStatus::COMPLETED));
}
if (!m_status.empty())
{
response["status"] = m_status;
}
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BsEcdhResult : public protocol::TaskResult
[[nodiscard]] Json::Value const& data() const { return m_data; }

// serialize the taskResult to json
[[nodiscard]] Json::Value serializeToJson() const override
[[nodiscard]] Json::Value serializeToJson() override
{
Json::Value response;
if (m_error && error()->errorCode())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CM2020PSIResult : public protocol::TaskResult
}

// serialize the taskResult to json
[[nodiscard]] Json::Value serializeToJson() const override
[[nodiscard]] Json::Value serializeToJson() override
{
Json::Value response;
response["taskID"] = taskID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LabeledPSIResult : public protocol::TaskResult
const std::vector<std::vector<std::string>>& getOutputs() { return m_outputs; }

// serialize the taskResult to json
Json::Value serializeToJson() const override
Json::Value serializeToJson() override
{
Json::Value response;
response["taskID"] = taskID();
Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-transport/ppc-rpc/src/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void Rpc::runTask(Json::Value const& _req, RespFunc _respFunc)
_respFunc(result->error(), result->serializeToJson());
return;
}

result->setStatus(toString(TaskStatus::COMPLETED));
_respFunc(_result->error(), _result->serializeToJson());
});
}
Expand Down

0 comments on commit 461be22

Please sign in to comment.