Skip to content

Commit 26d058b

Browse files
committed
psi support retry
1 parent 860fcc0 commit 26d058b

File tree

29 files changed

+64
-42
lines changed

29 files changed

+64
-42
lines changed

cpp/ppc-framework/protocol/DataResource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ class DataResource
119119

120120
inline std::string printDataResourceInfo(DataResource::ConstPtr _dataResource)
121121
{
122+
if (!_dataResource)
123+
{
124+
return "empty";
125+
}
122126
std::ostringstream stringstream;
123127
stringstream << LOG_KV("dataResource", _dataResource->resourceID());
124128
if (_dataResource->desc())

cpp/ppc-framework/protocol/PartyResource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ using ConstParties = std::vector<PartyResource::ConstPtr>;
6767

6868
inline std::string printPartyInfo(PartyResource::ConstPtr _party)
6969
{
70+
if (!_party)
71+
{
72+
return "empty";
73+
}
7074
std::ostringstream stringstream;
7175
stringstream << LOG_KV("partyId", _party->id()) << LOG_KV("partyIndex", _party->partyIndex())
7276
<< LOG_KV("desc", _party->desc());

cpp/ppc-framework/protocol/Task.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ class Task
143143
// decode the task
144144
virtual void decode(std::string_view _taskData) = 0;
145145
virtual std::string encode() const = 0;
146+
147+
virtual bool enableOutputExists() const { return m_enableOutputExists; }
148+
virtual void setEnableOutputExists(bool enableOutputExists)
149+
{
150+
m_enableOutputExists = enableOutputExists;
151+
}
152+
153+
protected:
154+
bool m_enableOutputExists = false;
146155
};
147156

148157
class TaskFactory
@@ -160,9 +169,14 @@ class TaskFactory
160169
inline std::string printTaskInfo(Task::ConstPtr _task)
161170
{
162171
std::ostringstream stringstream;
172+
if (!task)
173+
{
174+
return "empty";
175+
}
163176
stringstream << LOG_KV("id", _task->id())
164177
<< LOG_KV("type", (ppc::protocol::TaskType)_task->type())
165178
<< LOG_KV("algorithm", (ppc::protocol::TaskAlgorithmType)_task->algorithm())
179+
<< LOG_KV("enableOutputExists", _task->enableOutputExists())
166180
<< LOG_KV("taskPtr", _task);
167181
if (_task->selfParty())
168182
{

cpp/wedpr-computing/ppc-pir/src/OtPIRImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ void OtPIRImpl::asyncRunTask()
445445
<< LOG_KV("requestAgencyDataset", taskMessage.requestAgencyDataset)
446446
<< LOG_KV("prefixLength", taskMessage.prefixLength)
447447
<< LOG_KV("searchId", taskMessage.searchId);
448-
auto writer = loadWriter(task->id(), dataResource, m_enableOutputExists);
448+
auto writer =
449+
loadWriter(task->id(), dataResource, m_taskState->task()->enableOutputExists());
449450
m_taskState->setWriter(writer);
450451
runSenderGenerateCipher(taskMessage);
451452
}

cpp/wedpr-computing/ppc-pir/src/OtPIRImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ class OtPIRImpl : public std::enable_shared_from_this<OtPIRImpl>,
150150
m_senders.erase(it);
151151
}
152152
}
153-
// allow the output-path exists, for ut
154-
bool m_enableOutputExists = false;
155153
// 为true时启动时会从配置中加载文件作为匹配源
156154
bool m_enableMemoryFile = false;
157155
ppc::protocol::DataResource m_resource;

cpp/wedpr-computing/ppc-pir/tests/FakeOtPIRFactory.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ class FakeOtPIRImpl : public OtPIRImpl
4646
using Ptr = std::shared_ptr<FakeOtPIRImpl>;
4747
FakeOtPIRImpl(OtPIRConfig::Ptr const& _config, unsigned _idleTimeMs = 0)
4848
: OtPIRImpl(_config, _idleTimeMs)
49-
{
50-
m_enableOutputExists = true;
51-
}
49+
{}
5250
~FakeOtPIRImpl() override = default;
5351
};
5452

cpp/wedpr-computing/ppc-pir/tests/TestBaseOT.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ void testOTPIRImplFunc(const std::string& _taskID, const std::string& _params, b
194194
auto senderPIRTask = std::make_shared<JsonTaskImpl>(senderAgencyName);
195195
senderPIRTask->setId(_taskID);
196196
senderPIRTask->setParam(_params);
197+
senderPIRTask->setEnableOutputExists(true);
197198
senderPIRTask->setSelf(_senderParty);
198199
senderPIRTask->addParty(_receiverParty);
199200
senderPIRTask->setSyncResultToPeer(_syncResults);
@@ -203,6 +204,7 @@ void testOTPIRImplFunc(const std::string& _taskID, const std::string& _params, b
203204
auto receiverPIRTask = std::make_shared<JsonTaskImpl>(receiverAgencyName);
204205
receiverPIRTask->setId(_taskID);
205206
receiverPIRTask->setParam(_params);
207+
receiverPIRTask->setEnableOutputExists(true);
206208
receiverPIRTask->setSelf(_receiverParty);
207209
receiverPIRTask->addParty(_senderParty);
208210
receiverPIRTask->setSyncResultToPeer(_syncResults);

cpp/wedpr-computing/ppc-psi/src/cm2020-psi/CM2020PSIImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void CM2020PSIImpl::asyncRunTask()
168168
auto role = task->selfParty()->partyIndex();
169169
if (role == uint16_t(PartyType::Client) || task->syncResultToPeer())
170170
{
171-
auto writer = loadWriter(task->id(), dataResource, m_enableOutputExists);
171+
auto writer = loadWriter(task->id(), dataResource, task->enableOutputExists());
172172
taskState->setWriter(writer);
173173
}
174174

cpp/wedpr-computing/ppc-psi/src/cm2020-psi/CM2020PSIImpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ class CM2020PSIImpl : public bcos::Worker,
148148
}
149149
}
150150

151-
protected:
152-
// allow the output-path exists, for ut
153-
bool m_enableOutputExists = false;
154-
155151
private:
156152
void waitSignal()
157153
{

cpp/wedpr-computing/ppc-psi/src/ecdh-conn-psi/EcdhConnPSIImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void EcdhConnPSIImpl::asyncRunTask(
5555
if (role == uint16_t(PartyType::Client))
5656
{
5757
ECDH_CONN_LOG(INFO) << LOG_DESC("Client do the Task") << LOG_KV("taskID", _task->id());
58-
auto writer = loadWriter(_task->id(), dataResource, m_enableOutputExists);
58+
auto writer = loadWriter(_task->id(), dataResource, _task->enableOutputExists());
5959
ecdhTaskState->setWriter(writer);
6060
auto client = std::make_shared<EcdhConnPSIClient>(m_config, ecdhTaskState);
6161
addClient(client);
@@ -66,7 +66,7 @@ void EcdhConnPSIImpl::asyncRunTask(
6666
ECDH_CONN_LOG(INFO) << LOG_DESC("Server do the Task") << LOG_KV("taskID", _task->id());
6767
if (_task->syncResultToPeer())
6868
{
69-
auto writer = loadWriter(_task->id(), dataResource, m_enableOutputExists);
69+
auto writer = loadWriter(_task->id(), dataResource, _task->enableOutputExists());
7070
ecdhTaskState->setWriter(writer);
7171
}
7272
auto server = std::make_shared<EcdhConnPSIServer>(m_config, ecdhTaskState);

0 commit comments

Comments
 (0)