Skip to content

Commit d9a6621

Browse files
committed
psi support retry
1 parent 860fcc0 commit d9a6621

File tree

27 files changed

+51
-42
lines changed

27 files changed

+51
-42
lines changed

cpp/ppc-framework/protocol/Task.h

Lines changed: 9 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

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);

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ class EcdhConnPSIImpl : public std::enable_shared_from_this<EcdhConnPSIImpl>,
6666
const std::string& _taskID, bcos::Error::Ptr _error, bool _noticePeer) override;
6767
void executeWorker() override;
6868

69-
protected:
70-
bool m_enableOutputExists = false;
71-
7269
void handlerPSIReceiveMessage(PSIConnMessage::Ptr _msg);
7370
void onHandShakeRequestHandler(const std::string& _taskId, const bcos::bytes& _msg);
7471
void onHandShakeResponseHandler(const std::string& _taskId, const bcos::bytes& _msg);

cpp/wedpr-computing/ppc-psi/src/ecdh-multi-psi/EcdhMultiPSIImpl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void EcdhMultiPSIImpl::asyncRunTask(
155155
<< LOG_KV("roleId", role);
156156
if (role == uint16_t(PartiesType::Calculator))
157157
{
158-
auto writer = loadWriter(_task->id(), dataResource, m_enableOutputExists);
158+
auto writer = loadWriter(_task->id(), dataResource, _task->enableOutputExists());
159159
taskState->setWriter(writer);
160160
ECDH_MULTI_LOG(INFO) << LOG_DESC("Calculator do the Task")
161161
<< LOG_KV("taskID", _task->id());
@@ -170,7 +170,7 @@ void EcdhMultiPSIImpl::asyncRunTask(
170170
if (_task->syncResultToPeer() && std::find(receivers.begin(), receivers.end(),
171171
m_config->selfParty()) != receivers.end())
172172
{
173-
auto writer = loadWriter(_task->id(), dataResource, m_enableOutputExists);
173+
auto writer = loadWriter(_task->id(), dataResource, _task->enableOutputExists());
174174
taskState->setWriter(writer);
175175
}
176176
auto partner = std::make_shared<EcdhMultiPSIPartner>(m_config, taskState);
@@ -183,7 +183,7 @@ void EcdhMultiPSIImpl::asyncRunTask(
183183
if (_task->syncResultToPeer() && std::find(receivers.begin(), receivers.end(),
184184
m_config->selfParty()) != receivers.end())
185185
{
186-
auto writer = loadWriter(_task->id(), dataResource, m_enableOutputExists);
186+
auto writer = loadWriter(_task->id(), dataResource, _task->enableOutputExists());
187187
taskState->setWriter(writer);
188188
}
189189
auto master = std::make_shared<EcdhMultiPSIMaster>(m_config, taskState);

0 commit comments

Comments
 (0)