Skip to content

Commit

Permalink
use uint64_t to record refInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Nov 18, 2024
1 parent 2a3824c commit 67b3499
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ void MasterCache::updateMasterDataRef(
if (!m_masterDataRef.count(data))
{
MasterCipherRef ref;
ref.refInfo.insert(_peerIndex);
ref.refInfo |= (1 << _peerIndex);
ref.updateDataIndex(dataIndex);
m_masterDataRef.insert(std::make_pair(std::move(data), ref));
return;
}
// existed data case
m_masterDataRef[data].refInfo.insert(_peerIndex);
m_masterDataRef[data].refInfo |= (1 << _peerIndex);
m_masterDataRef[data].updateDataIndex(dataIndex);
return;
}
Expand Down Expand Up @@ -157,15 +157,11 @@ void MasterCache::mergeMasterCipher(std::string const& peerId, unsigned short pe
for (auto it = m_masterDataRef.begin(); it != m_masterDataRef.end();)
{
// not has intersect-element with the finished peer
if (!it->second.refInfo.count(peerIndex))
if (!(it->second.refInfo & (1 << peerIndex)))
{
it = m_masterDataRef.erase(it);
continue;
}
// set the refCount
it->second.refCount = it->second.refInfo.size();
// release the refInfo
std::set<unsigned short>().swap(it->second.refInfo);
it++;
}
m_peerMerged = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace ppc::psi
{
struct MasterCipherRef
{
std::set<unsigned short> refInfo;
// support at least 63 peers
uint64_t refInfo = 0;
unsigned short refCount = 0;
int32_t dataIndex = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ void EcdhMultiPSIImpl::asyncRunTask(
psi->removePendingTask(taskID);
});
addPendingTask(taskState);

// over the peer limit
if (_task->getAllPeerParties().size() > c_max_peer_size)
{
auto error = std::make_shared<bcos::Error>(
-1, "at most support " + std::to_string(c_max_peer_size) + " peers, over the limit!");
ECDH_MULTI_LOG(WARNING) << LOG_DESC("asyncRunTask failed")
<< LOG_KV("msg", error->errorMessage());
onSelfError(_task->id(), error, true);
}
try
{
auto dataResource = _task->selfParty()->dataResource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ class EcdhMultiPSIImpl : public std::enable_shared_from_this<EcdhMultiPSIImpl>,
void wakeupWorker() { m_signal.notify_all(); }

const int c_popWaitMs = 5;

// at most support 63 peers
const int c_max_peer_size = 63;

EcdhMultiPSIConfig::Ptr m_config;
TaskState::Ptr m_taskMultiState;
EcdhMultiPSIMsgQueuePtr m_msgQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ void EcdhMultiPSICalculator::blindData(std::string _taskID, bcos::bytes _randA)
[self = weak_from_this(), master](bcos::Error::Ptr&& _error) {
if (!_error)
{
ECDH_CAL_LOG(INFO)
<< LOG_KV("blindData success to Master: ", master.first);
return;
}
auto psi = self.lock();
Expand Down

0 comments on commit 67b3499

Please sign in to comment.