mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
Merge pull request #1288 from csoler/v0.6-GxsFix
changed std::vector into std::set in notification system, hence remov…
This commit is contained in:
commit
2f159efb10
36 changed files with 210 additions and 273 deletions
|
@ -1217,7 +1217,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||
const RsGxsGroupId& grpId = mit->first;
|
||||
|
||||
// if vector empty then request all messages
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const std::set<RsGxsMessageId>& msgIdV = mit->second;
|
||||
std::vector<RsNxsMsg*> msgSet;
|
||||
|
||||
if(msgIdV.empty()){
|
||||
|
@ -1235,7 +1235,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||
}else{
|
||||
|
||||
// request each grp
|
||||
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
|
||||
for(; sit!=msgIdV.end();++sit){
|
||||
const RsGxsMessageId& msgId = *sit;
|
||||
|
@ -1305,7 +1305,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||
const RsGxsGroupId& grpId = mit->first;
|
||||
|
||||
// if vector empty then request all messages
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const std::set<RsGxsMessageId>& msgIdV = mit->second;
|
||||
std::vector<RsGxsMsgMetaData*> metaSet;
|
||||
|
||||
if(msgIdV.empty()){
|
||||
|
@ -1321,7 +1321,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||
}else{
|
||||
|
||||
// request each grp
|
||||
std::vector<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
|
||||
|
||||
for(; sit!=msgIdV.end(); ++sit){
|
||||
const RsGxsMessageId& msgId = *sit;
|
||||
|
@ -1561,7 +1561,7 @@ int RsDataService::removeMsgs(const GxsMsgReq& msgIds)
|
|||
|
||||
for(; mit != msgIds.end(); ++mit)
|
||||
{
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const std::set<RsGxsMessageId>& msgIdV = mit->second;
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
|
||||
// delete messages
|
||||
|
@ -1622,7 +1622,7 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgIds)
|
||||
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgIds)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
rstime::RsScopeTimer timer("");
|
||||
|
@ -1643,7 +1643,7 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std
|
|||
if(c->columnCount() != 1)
|
||||
std::cerr << "(EE) ********* not retrieving all columns!!" << std::endl;
|
||||
|
||||
msgIds.push_back(RsGxsMessageId(msgId));
|
||||
msgIds.insert(RsGxsMessageId(msgId));
|
||||
valid = c->moveToNext();
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
|
@ -1674,8 +1674,8 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
|
|||
for(; mit != msgIds.end(); ++mit)
|
||||
{
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
const std::vector<RsGxsMessageId>& msgsV = mit->second;
|
||||
std::vector<RsGxsMessageId>::const_iterator vit = msgsV.begin();
|
||||
const std::set<RsGxsMessageId>& msgsV = mit->second;
|
||||
std::set<RsGxsMessageId>::const_iterator vit = msgsV.begin();
|
||||
|
||||
for(; vit != msgsV.end(); ++vit)
|
||||
{
|
||||
|
|
|
@ -110,7 +110,7 @@ public:
|
|||
* @param msgId msgsids retrieved
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId);
|
||||
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId);
|
||||
|
||||
/*!
|
||||
* @return the cache size set for this RsGeneralDataService in bytes
|
||||
|
|
|
@ -208,7 +208,7 @@ public:
|
|||
* @param msgId msgsids retrieved
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId) = 0;
|
||||
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId) = 0;
|
||||
|
||||
/*!
|
||||
* @return the cache size set for this RsGeneralDataService in bytes
|
||||
|
|
|
@ -217,7 +217,7 @@ void RsGenExchange::tick()
|
|||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgIds;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
|
||||
mIntegrityCheck->getDeletedIds(grpIds, msgIds);
|
||||
|
||||
if (!grpIds.empty())
|
||||
|
@ -1078,23 +1078,19 @@ bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& fla
|
|||
}
|
||||
}
|
||||
|
||||
static void addMessageChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChanged)
|
||||
static void addMessageChanged(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgs, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChanged)
|
||||
{
|
||||
if (msgs.empty()) {
|
||||
msgs = msgChanged;
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
|
||||
for (mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt) {
|
||||
for (auto mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt)
|
||||
{
|
||||
const RsGxsGroupId &grpId = mapIt->first;
|
||||
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::vector<RsGxsMessageId> &destMsgIds = msgs[grpId];
|
||||
const std::set<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::set<RsGxsMessageId> &destMsgIds = msgs[grpId];
|
||||
|
||||
std::vector<RsGxsMessageId>::const_iterator msgIt;
|
||||
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
|
||||
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
|
||||
destMsgIds.push_back(*msgIt);
|
||||
}
|
||||
}
|
||||
for (auto msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt)
|
||||
destMsgIds.insert(*msgIt) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1789,8 +1785,8 @@ void RsGenExchange::deleteMsgs(uint32_t& token, const GxsMsgReq& msgs)
|
|||
|
||||
if(mNetService != NULL)
|
||||
for(GxsMsgReq::const_iterator it(msgs.begin());it!=msgs.end();++it)
|
||||
for(uint32_t i=0;i<it->second.size();++i)
|
||||
mNetService->rejectMessage(it->second[i]) ;
|
||||
for(auto it2(it->second.begin());it2!=it->second.end();++it2)
|
||||
mNetService->rejectMessage(*it2);
|
||||
}
|
||||
|
||||
void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
|
||||
|
@ -1961,8 +1957,8 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
if(m.val.getAsInt32(RsGeneralDataService::MSG_META_STATUS+GXS_MASK, mask))
|
||||
{
|
||||
GxsMsgReq req;
|
||||
std::vector<RsGxsMessageId> msgIdV;
|
||||
msgIdV.push_back(m.msgId.second);
|
||||
std::set<RsGxsMessageId> msgIdV;
|
||||
msgIdV.insert(m.msgId.second);
|
||||
req.insert(std::make_pair(m.msgId.first, msgIdV));
|
||||
GxsMsgMetaResult result;
|
||||
mDataStore->retrieveGxsMsgMetaData(req, result);
|
||||
|
@ -1994,7 +1990,7 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
|
||||
if (changed)
|
||||
{
|
||||
msgIds[m.msgId.first].push_back(m.msgId.second);
|
||||
msgIds[m.msgId.first].insert(m.msgId.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2145,7 +2141,7 @@ void RsGenExchange::publishMsgs()
|
|||
mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem));
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
|
||||
|
||||
for(; mit != mMsgsToPublish.end(); ++mit)
|
||||
|
@ -2273,7 +2269,7 @@ void RsGenExchange::publishMsgs()
|
|||
mDataAccess->addMsgData(msg);
|
||||
delete msg ;
|
||||
|
||||
msgChangeMap[grpId].push_back(msgId);
|
||||
msgChangeMap[grpId].insert(msgId);
|
||||
|
||||
delete[] metaDataBuff;
|
||||
|
||||
|
@ -2972,10 +2968,10 @@ void RsGenExchange::processRecvdMessages()
|
|||
msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
|
||||
msgs_to_store.push_back(msg);
|
||||
|
||||
std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
|
||||
|
||||
if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
|
||||
msgv.push_back(msg->msgId);
|
||||
msgIds[msg->grpId].insert(msg->msgId);
|
||||
// std::vector<RsGxsMessageId> &msgv = msgIds[msg->grpId];
|
||||
// if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end())
|
||||
// msgv.push_back(msg->msgId);
|
||||
|
||||
computeHash(msg->msg, msg->metaData->mHash);
|
||||
msg->metaData->recvTS = time(NULL);
|
||||
|
@ -3330,7 +3326,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
|
|||
|
||||
//RsGxsGroupId::std_list grpIds(mGrpIdsUnique.begin(), mGrpIdsUnique.end());
|
||||
//RsGxsGroupId::std_list::const_iterator it = grpIds.begin();
|
||||
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_vector> MsgIdReq;
|
||||
typedef std::map<RsGxsGroupId, RsGxsMessageId::std_set> MsgIdReq;
|
||||
MsgIdReq msgIdReq;
|
||||
|
||||
// now get a list of all msgs ids for each group
|
||||
|
@ -3350,7 +3346,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
|
|||
// now for each msg to be stored that exist in the retrieved msg/grp "index" delete and erase from map
|
||||
for(std::list<RsNxsMsg*>::iterator cit2 = msgs.begin(); cit2 != msgs.end();)
|
||||
{
|
||||
const RsGxsMessageId::std_vector& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
|
||||
const RsGxsMessageId::std_set& msgIds = msgIdReq[(*cit2)->metaData->mGroupId];
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " grpid=" << (*cit2)->grpId << ", msgid=" << (*cit2)->msgId ;
|
||||
|
@ -3358,12 +3354,13 @@ void RsGenExchange::removeDeleteExistingMessages( std::list<RsNxsMsg*>& msgs, Gx
|
|||
|
||||
// Avoid storing messages that are already in the database, as well as messages that are too old (or generally do not pass the database storage test)
|
||||
//
|
||||
if(std::find(msgIds.begin(), msgIds.end(), (*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
|
||||
if(msgIds.find((*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData))
|
||||
{
|
||||
// msg exist in retrieved index. We should use a std::set here instead of a vector.
|
||||
|
||||
RsGxsMessageId::std_vector& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
|
||||
RsGxsMessageId::std_vector::iterator it2 = std::find(notifyIds.begin(), notifyIds.end(), (*cit2)->metaData->mMsgId);
|
||||
RsGxsMessageId::std_set& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId];
|
||||
RsGxsMessageId::std_set::iterator it2 = notifyIds.find((*cit2)->metaData->mMsgId);
|
||||
|
||||
if(it2 != notifyIds.end())
|
||||
{
|
||||
notifyIds.erase(it2);
|
||||
|
|
|
@ -225,7 +225,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
|||
MsgMetaReq* mmr = new MsgMetaReq();
|
||||
|
||||
for(; lit != grpIds.end(); ++lit)
|
||||
mmr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
|
||||
mmr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mmr;
|
||||
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
|
||||
|
@ -233,7 +233,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
|||
MsgDataReq* mdr = new MsgDataReq();
|
||||
|
||||
for(; lit != grpIds.end(); ++lit)
|
||||
mdr->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
|
||||
mdr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mdr;
|
||||
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
|
||||
|
@ -241,7 +241,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
|||
MsgIdReq* mir = new MsgIdReq();
|
||||
|
||||
for(; lit != grpIds.end(); ++lit)
|
||||
mir->mMsgIds[*lit] = std::vector<RsGxsMessageId>();
|
||||
mir->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mir;
|
||||
}
|
||||
|
@ -1191,7 +1191,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
|
|||
// Add the discovered Latest Msgs.
|
||||
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
|
||||
{
|
||||
msgIdsOut[grpId].push_back(oit->second.first);
|
||||
msgIdsOut[grpId].insert(oit->second.first);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1228,7 +1228,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions&
|
|||
|
||||
if (add)
|
||||
{
|
||||
msgIdsOut[grpId].push_back(msgMeta->mMsgId);
|
||||
msgIdsOut[grpId].insert(msgMeta->mMsgId);
|
||||
metaFilter[grpId].insert(std::make_pair(msgMeta->mMsgId, msgMeta));
|
||||
}
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
// get meta data for all in group
|
||||
GxsMsgMetaResult result;
|
||||
GxsMsgReq msgIds;
|
||||
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::vector<RsGxsMessageId>()));
|
||||
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>()));
|
||||
mDataStore->retrieveGxsMsgMetaData(msgIds, result);
|
||||
std::vector<RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first];
|
||||
std::vector<RsGxsMsgMetaData*>::iterator vit_meta;
|
||||
|
@ -1382,7 +1382,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
const RsGxsMessageId& msgId = grpMsgIdPair.second;
|
||||
const RsGxsGroupId& grpId = grpMsgIdPair.first;
|
||||
|
||||
std::vector<RsGxsMessageId> outMsgIds;
|
||||
std::set<RsGxsMessageId> outMsgIds;
|
||||
|
||||
RsGxsMsgMetaData* origMeta = NULL;
|
||||
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
|
||||
|
@ -1477,7 +1477,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
// Add the discovered Latest Msgs.
|
||||
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit)
|
||||
{
|
||||
outMsgIds.push_back(oit->second.first);
|
||||
outMsgIds.insert(oit->second.first);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1502,7 +1502,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
}
|
||||
}
|
||||
}
|
||||
outMsgIds.push_back(latestMsgId);
|
||||
outMsgIds.insert(latestMsgId);
|
||||
metaMap.insert(std::make_pair(latestMsgId, latestMeta));
|
||||
}
|
||||
}
|
||||
|
@ -1514,7 +1514,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
|
||||
if (meta->mOrigMsgId == origMsgId)
|
||||
{
|
||||
outMsgIds.push_back(meta->mMsgId);
|
||||
outMsgIds.insert(meta->mMsgId);
|
||||
metaMap.insert(std::make_pair(meta->mMsgId, meta));
|
||||
}
|
||||
}
|
||||
|
@ -1556,7 +1556,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
|||
{
|
||||
// filter based on options
|
||||
GxsMsgIdResult metaReq;
|
||||
metaReq[req->mGrpId] = std::vector<RsGxsMessageId>();
|
||||
metaReq[req->mGrpId] = std::set<RsGxsMessageId>();
|
||||
GxsMsgMetaResult metaResult;
|
||||
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
|
||||
|
||||
|
@ -1672,7 +1672,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
|
|||
for(; vit != vit_end; ++vit)
|
||||
{
|
||||
RsGxsMsgMetaData* meta = *vit;
|
||||
req->mMsgIdResult[grpId].push_back(meta->mMsgId);
|
||||
req->mMsgIdResult[grpId].insert(meta->mMsgId);
|
||||
delete meta; // discard meta data mem
|
||||
}
|
||||
}
|
||||
|
@ -1718,8 +1718,8 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption
|
|||
if(cit == msgMetas.end())
|
||||
continue;
|
||||
|
||||
std::vector<RsGxsMessageId>& msgs = mit->second;
|
||||
std::vector<RsGxsMessageId>::iterator vit = msgs.begin();
|
||||
std::set<RsGxsMessageId>& msgs = mit->second;
|
||||
std::set<RsGxsMessageId>::iterator vit = msgs.begin();
|
||||
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& meta = cit->second;
|
||||
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;
|
||||
|
||||
|
|
|
@ -784,7 +784,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
|
|||
// now count available messages
|
||||
|
||||
GxsMsgReq reqIds;
|
||||
reqIds[grs->grpId] = std::vector<RsGxsMessageId>();
|
||||
reqIds[grs->grpId] = std::set<RsGxsMessageId>();
|
||||
GxsMsgMetaResult result;
|
||||
|
||||
#ifdef NXS_NET_DEBUG_6
|
||||
|
@ -2757,7 +2757,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
#endif
|
||||
|
||||
GxsMsgReq reqIds;
|
||||
reqIds[grpId] = std::vector<RsGxsMessageId>();
|
||||
reqIds[grpId] = std::set<RsGxsMessageId>();
|
||||
GxsMsgMetaResult result;
|
||||
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
|
||||
std::vector<RsGxsMsgMetaData*> &msgMetaV = result[grpId];
|
||||
|
@ -3296,7 +3296,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
|
|||
RsNxsSyncMsgItem* item = dynamic_cast<RsNxsSyncMsgItem*>(*lit);
|
||||
if (item)
|
||||
{
|
||||
msgIds[item->grpId].push_back(item->msgId);
|
||||
msgIds[item->grpId].insert(item->msgId);
|
||||
|
||||
if(grpId.isNull())
|
||||
grpId = item->grpId;
|
||||
|
@ -4127,7 +4127,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
|
|||
}
|
||||
|
||||
GxsMsgReq req;
|
||||
req[item->grpId] = std::vector<RsGxsMessageId>();
|
||||
req[item->grpId] = std::set<RsGxsMessageId>();
|
||||
|
||||
GxsMsgMetaResult metaResult;
|
||||
mDataStore->retrieveGxsMsgMetaData(req, metaResult);
|
||||
|
|
|
@ -67,7 +67,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
GxsMsgReq req;
|
||||
GxsMsgMetaResult result;
|
||||
|
||||
req[grpId] = std::vector<RsGxsMessageId>();
|
||||
req[grpId] = std::set<RsGxsMessageId>();
|
||||
mDs->retrieveGxsMsgMetaData(req, result);
|
||||
|
||||
GxsMsgMetaResult::iterator mit = result.begin();
|
||||
|
@ -117,7 +117,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
|
||||
if( remove )
|
||||
{
|
||||
req[grpId].push_back(meta->mMsgId);
|
||||
req[grpId].insert(meta->mMsgId);
|
||||
|
||||
#ifdef DEBUG_GXSUTIL
|
||||
std::cerr << " Scheduling for removal." << std::endl;
|
||||
|
@ -241,9 +241,9 @@ bool RsGxsIntegrityCheck::check()
|
|||
for (msgIdsIt = msgIds.begin(); msgIdsIt != msgIds.end(); ++msgIdsIt)
|
||||
{
|
||||
const RsGxsGroupId& grpId = msgIdsIt->first;
|
||||
std::vector<RsGxsMessageId> &msgIdV = msgIdsIt->second;
|
||||
std::set<RsGxsMessageId> &msgIdV = msgIdsIt->second;
|
||||
|
||||
std::vector<RsGxsMessageId>::iterator msgIdIt;
|
||||
std::set<RsGxsMessageId>::iterator msgIdIt;
|
||||
for (msgIdIt = msgIdV.begin(); msgIdIt != msgIdV.end(); ++msgIdIt)
|
||||
{
|
||||
const RsGxsMessageId& msgId = *msgIdIt;
|
||||
|
@ -261,7 +261,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
|
||||
if (nxsMsgIt == nxsMsgV.end())
|
||||
{
|
||||
msgsToDel[grpId].push_back(msgId);
|
||||
msgsToDel[grpId].insert(msgId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
if(msg->metaData == NULL || currHash != msg->metaData->mHash)
|
||||
{
|
||||
std::cerr << "(EE) deleting message data with wrong hash or null meta data. meta=" << (void*)msg->metaData << std::endl;
|
||||
msgsToDel[msg->grpId].push_back(msg->msgId);
|
||||
msgsToDel[msg->grpId].insert(msg->msgId);
|
||||
}
|
||||
else if(!msg->metaData->mAuthorId.isNull() && subscribed_groups.find(msg->metaData->mGroupId)!=subscribed_groups.end())
|
||||
{
|
||||
|
@ -377,7 +377,7 @@ bool RsGxsIntegrityCheck::isDone()
|
|||
return mDone;
|
||||
}
|
||||
|
||||
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds)
|
||||
void RsGxsIntegrityCheck::getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds)
|
||||
{
|
||||
RsStackMutex stack(mIntegrityMutex);
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ public:
|
|||
|
||||
void run();
|
||||
|
||||
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
|
||||
void getDeletedIds(std::list<RsGxsGroupId>& grpIds, std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -217,7 +217,7 @@ private:
|
|||
bool mDone;
|
||||
RsMutex mIntegrityMutex;
|
||||
std::list<RsGxsGroupId> mDeletedGrps;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mDeletedMsgs;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mDeletedMsgs;
|
||||
|
||||
RsGixs *mGixs ;
|
||||
};
|
||||
|
|
|
@ -455,7 +455,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
|
|||
|
||||
if(stored_msgs.end() != it2)
|
||||
{
|
||||
msgsToDel[it2->second.first].push_back(it2->second.second);
|
||||
msgsToDel[it2->second.first].insert(it2->second.second);
|
||||
|
||||
#ifdef DEBUG_GXSTRANS
|
||||
std::cerr << " scheduling msg " << std::hex << it2->second.first << "," << it2->second.second << " for deletion." << std::endl;
|
||||
|
|
|
@ -40,8 +40,8 @@ class RsGxsChanges
|
|||
public:
|
||||
RsGxsChanges(): mService(0){}
|
||||
RsTokenService *mService;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgs;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgsMeta;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgs;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgsMeta;
|
||||
std::list<RsGxsGroupId> mGrps;
|
||||
std::list<RsGxsGroupId> mGrpsMeta;
|
||||
};
|
||||
|
|
|
@ -43,10 +43,10 @@ typedef Sha1CheckSum RsGxsMessageId;
|
|||
typedef GXSId RsGxsId;
|
||||
typedef GXSCircleId RsGxsCircleId;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
|
||||
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgReq;
|
||||
|
||||
struct RsMsgMetaData;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class RsGxsMsgChange : public RsGxsNotify
|
|||
{
|
||||
public:
|
||||
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
||||
bool metaChange() { return mMetaChange; }
|
||||
private:
|
||||
|
|
|
@ -241,16 +241,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
/* message received */
|
||||
if (notify)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMessageId>::iterator mit1;
|
||||
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,9 +257,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
|
||||
|
@ -807,10 +802,7 @@ void p3GxsChannels::request_SpecificUnprocessedPosts(std::list<std::pair<RsGxsGr
|
|||
GxsMsgReq msgIds;
|
||||
std::list<std::pair<RsGxsGroupId, RsGxsMessageId> >::iterator it;
|
||||
for(it = ids.begin(); it != ids.end(); ++it)
|
||||
{
|
||||
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[it->first];
|
||||
vect_msgIds.push_back(it->second);
|
||||
}
|
||||
msgIds[it->first].insert(it->second);
|
||||
|
||||
RsGenExchange::getTokenService()->requestMsgInfo(token, ansType, opts, msgIds);
|
||||
GxsTokenQueue::queueRequest(token, GXSCHANNELS_UNPROCESSED_SPECIFIC);
|
||||
|
|
|
@ -212,14 +212,14 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Found circle Message Change Notification" << std::endl;
|
||||
#endif
|
||||
for(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
|
||||
for(auto mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
||||
#endif
|
||||
force_cache_reload(RsGxsCircleId(mit->first));
|
||||
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVE) )
|
||||
for (std::vector<RsGxsMessageId>::const_iterator msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
||||
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
||||
{
|
||||
const RsGxsMessageId& msgId = *msgIdIt;
|
||||
notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_MEMB_REQ,RsGxsCircleId(mit->first).toStdString(),msgId.toStdString());
|
||||
|
@ -2120,7 +2120,7 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
|
|||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Older than last known (" << time(NULL)-info.last_subscription_TS << " seconds ago): deleting." << std::endl;
|
||||
#endif
|
||||
messages_to_delete[RsGxsGroupId(cid)].push_back(it->second[i]->meta.mMsgId) ;
|
||||
messages_to_delete[RsGxsGroupId(cid)].insert(it->second[i]->meta.mMsgId) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -502,8 +502,8 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote)
|
|||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::vector<RsGxsMessageId> &vect_msgIds = msgIds[parentId.first];
|
||||
vect_msgIds.push_back(parentId.second);
|
||||
std::set<RsGxsMessageId> &vect_msgIds = msgIds[parentId.first];
|
||||
vect_msgIds.insert(parentId.second);
|
||||
|
||||
uint32_t int_token;
|
||||
mExchange->getTokenService()->requestMsgInfo(int_token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, msgIds);
|
||||
|
|
|
@ -205,15 +205,12 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange*>(c);
|
||||
if (msgChange)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMessageId>::iterator mit1;
|
||||
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -562,8 +562,8 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
|
|
|
@ -110,9 +110,8 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef POSTBASE_DEBUG
|
||||
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
||||
|
@ -125,8 +124,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVE)
|
||||
{
|
||||
std::vector<RsGxsMessageId>::iterator mit1;
|
||||
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
|
||||
}
|
||||
|
@ -431,7 +429,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
mBgIncremental = unprocessed;
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > postMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > postMap;
|
||||
|
||||
// generate vector of changes to push to the GUI.
|
||||
std::vector<RsGxsNotify *> changes;
|
||||
|
@ -487,7 +485,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
#endif
|
||||
|
||||
/* but we need to notify GUI about them */
|
||||
msgChanges->msgChangeMap[mit->first].push_back((*vit)->meta.mMsgId);
|
||||
msgChanges->msgChangeMap[mit->first].insert((*vit)->meta.mMsgId);
|
||||
}
|
||||
else if (NULL != (commentItem = dynamic_cast<RsGxsCommentItem *>(*vit)))
|
||||
{
|
||||
|
@ -546,7 +544,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
if (sit == mBgStatsMap.end())
|
||||
{
|
||||
// add to map of ones to update.
|
||||
postMap[groupId].push_back(threadId);
|
||||
postMap[groupId].insert(threadId);
|
||||
|
||||
mBgStatsMap[threadId] = PostStats(0,0,0);
|
||||
sit = mBgStatsMap.find(threadId);
|
||||
|
@ -704,7 +702,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
|||
#endif
|
||||
|
||||
stats.increment(it->second);
|
||||
msgChanges->msgChangeMap[mit->first].push_back(vit->mMsgId);
|
||||
msgChanges->msgChangeMap[mit->first].insert(vit->mMsgId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue