enabled MsgMetaData cache in rsgxsdataaccess.cc and witched metas to const, and removed deletion of retrieved metas since now the cache handles it

This commit is contained in:
csoler 2020-05-28 15:11:14 +02:00
parent ebf32bf955
commit eb6af15b1a
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
12 changed files with 277 additions and 229 deletions

View File

@ -507,8 +507,8 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
else else
grpMeta = new RsGxsGrpMetaData(); grpMeta = new RsGxsGrpMetaData();
// if(!grpMeta->mGroupId.isNull()) // the grpMeta is already initialized because it comes from the cache if(!grpMeta->mGroupId.isNull()) // the grpMeta is already initialized because it comes from the cache
// return grpMeta; return grpMeta;
grpMeta->mGroupId = RsGxsGroupId(tempId); grpMeta->mGroupId = RsGxsGroupId(tempId);
c.getString(mColGrpMeta_NxsIdentity + colOffset, tempId); c.getString(mColGrpMeta_NxsIdentity + colOffset, tempId);
@ -664,13 +664,13 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset
RsGxsMsgMetaData* msgMeta = nullptr; RsGxsMsgMetaData* msgMeta = nullptr;
// if(use_cache) if(use_cache)
// msgMeta = mMsgMetaDataCache[group_id].getOrCreateMeta(msg_id); msgMeta = mMsgMetaDataCache[group_id].getOrCreateMeta(msg_id);
// else else
msgMeta = new RsGxsMsgMetaData(); msgMeta = new RsGxsMsgMetaData();
//if(!msgMeta->mGroupId.isNull()) // we cannot do that because the cursor needs to advance. Is there a method to skip some data in the db? if(!msgMeta->mGroupId.isNull()) // we cannot do that because the cursor needs to advance. Is there a method to skip some data in the db?
// return msgMeta; return msgMeta;
msgMeta->mGroupId = group_id; msgMeta->mGroupId = group_id;
msgMeta->mMsgId = msg_id; msgMeta->mMsgId = msg_id;
@ -838,6 +838,7 @@ int RsDataService::storeMessage(const std::list<RsNxsMsg*>& msg)
// This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded. // This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded.
mGrpMetaDataCache.clear(msgMetaPtr->mGroupId); mGrpMetaDataCache.clear(msgMetaPtr->mGroupId);
mMsgMetaDataCache[msgMetaPtr->mGroupId].updateMeta(msgMetaPtr->mMsgId,*msgMetaPtr);
} }
// finish transaction // finish transaction
@ -1240,7 +1241,7 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
return; return;
} }
int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaResult &msgMeta) int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaResult& msgMeta)
{ {
RsStackMutex stack(mDbMutex); RsStackMutex stack(mDbMutex);
@ -1249,52 +1250,66 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
int resultCount = 0; int resultCount = 0;
#endif #endif
GxsMsgReq::const_iterator mit = reqIds.begin(); for(auto mit(reqIds.begin()); mit != reqIds.end(); ++mit)
for(; mit != reqIds.end(); ++mit)
{ {
const RsGxsGroupId& grpId = mit->first; const RsGxsGroupId& grpId = mit->first;
const std::set<RsGxsMessageId>& msgIdV = mit->second;
// if vector empty then request all messages // if vector empty then request all messages
const std::set<RsGxsMessageId>& msgIdV = mit->second;
std::vector<RsGxsMsgMetaData*> metaSet;
if(msgIdV.empty()){ t_MetaDataCache<RsGxsMessageId,RsGxsMsgMetaData>& cache(mMsgMetaDataCache[grpId]);
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
if (c) if(msgIdV.empty())
{ {
locked_retrieveMsgMeta(c, metaSet); if(cache.isCacheUpToDate())
cache.getFullMetaList(msgMeta[grpId]);
else
{
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
if (c)
{
locked_retrieveMsgMetaList(c, msgMeta[grpId]);
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << mDbName << ": Retrieving (all) Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl; std::cerr << mDbName << ": Retrieving (all) Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl;
#endif #endif
} cache.setCacheUpToDate(true);
}else{ }
delete c;
// request each grp }
std::set<RsGxsMessageId>::const_iterator sit = msgIdV.begin();
for(; sit!=msgIdV.end(); ++sit){
const RsGxsMessageId& msgId = *sit;
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString()
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
if (c)
{
locked_retrieveMsgMeta(c, metaSet);
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << mDbName << ": Retrieving Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl;
#endif
}
}
} }
else
{
// request each msg meta
auto& metaSet(msgMeta[grpId]);
#ifdef RS_DATA_SERVICE_DEBUG_TIME for(auto sit(msgIdV.begin()); sit!=msgIdV.end(); ++sit)
resultCount += metaSet.size(); {
const RsGxsMessageId& msgId = *sit;
RsGxsMsgMetaData *meta = cache.getMeta(msgId);
if(meta)
metaSet.push_back(meta);
else
{
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
c->moveToFirst();
RsGxsMsgMetaData* meta = locked_getMsgMeta(*c, 0,true);
if(meta)
metaSet.push_back(meta);
delete c;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << mDbName << ": Retrieving Msg metadata grpId=" << grpId << ", " << std::dec << metaSet.size() << " messages" << std::endl;
#endif #endif
}
msgMeta[grpId] = metaSet; }
}
} }
#ifdef RS_DATA_SERVICE_DEBUG_TIME #ifdef RS_DATA_SERVICE_DEBUG_TIME
@ -1305,22 +1320,43 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
return 1; return 1;
} }
void RsDataService::locked_retrieveMsgMeta(RetroCursor *c, std::vector<RsGxsMsgMetaData *> &msgMeta) void RsDataService::locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGroupId,RsGxsGrpMetaData *>& grpMeta)
{ {
if(!c)
{
RsErr() << __PRETTY_FUNCTION__ << ": attempt to retrieve Group Meta data from the DB with null cursor!" << std::endl;
return;
}
if(c) bool valid = c->moveToFirst();
{
bool valid = c->moveToFirst();
while(valid){
RsGxsMsgMetaData* m = locked_getMsgMeta(*c, 0,true);
if(m != NULL) while(valid)
msgMeta.push_back(m); {
RsGxsGrpMetaData* m = locked_getGrpMeta(*c, 0,true);
valid = c->moveToNext(); if(m)
} grpMeta[m->mGroupId] = m;
delete c;
} valid = c->moveToNext();
}
}
void RsDataService::locked_retrieveMsgMetaList(RetroCursor *c, std::vector<const RsGxsMsgMetaData *>& msgMeta)
{
if(!c)
{
RsErr() << __PRETTY_FUNCTION__ << ": attempt to retrieve Msg Meta data from the DB with null cursor!" << std::endl;
return;
}
bool valid = c->moveToFirst();
while(valid){
const RsGxsMsgMetaData* m = locked_getMsgMeta(*c, 0,true);
if(m != NULL)
msgMeta.push_back(m);
valid = c->moveToNext();
}
} }
int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
@ -1346,7 +1382,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
std::cerr << (void*)this << ": RsDataService::retrieveGxsGrpMetaData() retrieving all from cache!" << std::endl; std::cerr << (void*)this << ": RsDataService::retrieveGxsGrpMetaData() retrieving all from cache!" << std::endl;
#endif #endif
grp = mGrpMetaDataCache.getFullMetaMap() ; mGrpMetaDataCache.getFullMetaList(grp) ;
} }
else else
{ {
@ -1357,87 +1393,99 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "", ""); RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "", "");
if(c) if(c)
{ {
bool valid = c->moveToFirst(); locked_retrieveGrpMetaList(c,grp);
while(valid) mGrpMetaDataCache.setCacheUpToDate(true);
{
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
if(g)
{
grp[g->mGroupId] = g;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void *)this << " " << mDbName << ": Retrieving (all) Grp metadata grpId=" << g->mGroupId << std::endl;
#endif
}
valid = c->moveToNext();
#ifdef RS_DATA_SERVICE_DEBUG_TIME
++resultCount;
#endif
}
delete c;
} }
delete c;
mGrpMetaDataCache.setCacheUpToDate(true); // if(c)
// {
// bool valid = c->moveToFirst();
//
// while(valid)
// {
// RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
//
// if(g)
// {
// grp[g->mGroupId] = g;
//#ifdef RS_DATA_SERVICE_DEBUG_CACHE
// std::cerr << (void *)this << " " << mDbName << ": Retrieving (all) Grp metadata grpId=" << g->mGroupId << std::endl;
//#endif
// }
// valid = c->moveToNext();
//
//#ifdef RS_DATA_SERVICE_DEBUG_TIME
// ++resultCount;
//#endif
// }
// delete c;
// }
} }
} }
else else
{ {
std::map<RsGxsGroupId, RsGxsGrpMetaData *>::iterator mit = grp.begin(); for(auto mit(grp.begin()); mit != grp.end(); ++mit)
{
RsGxsGrpMetaData *meta = mGrpMetaDataCache.getMeta(mit->first) ;
for(; mit != grp.end(); ++mit) if(meta)
{ grp[mit->first] = meta;
RsGxsGrpMetaData *meta = mGrpMetaDataCache.getMeta(mit->first) ; else
{
if(meta)
grp[mit->first] = meta;
else
{
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << mDbName << ": Retrieving Grp metadata grpId=" << mit->first ; std::cerr << mDbName << ": Retrieving Grp metadata grpId=" << mit->first ;
#endif #endif
const RsGxsGroupId& grpId = mit->first; const RsGxsGroupId& grpId = mit->first;
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", ""); RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", "");
if(c) c->moveToFirst();
{ RsGxsGrpMetaData* meta = locked_getGrpMeta(*c, 0,true);
bool valid = c->moveToFirst();
if(meta)
grp[mit->first] = meta;
delete c;
// if(c)
// {
// bool valid = c->moveToFirst();
//
//#ifdef RS_DATA_SERVICE_DEBUG_CACHE
// if(!valid)
// std::cerr << " Empty query! GrpId " << grpId << " is not in database" << std::endl;
//#endif
// while(valid)
// {
// RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
//
// if(g)
// {
// grp[g->mGroupId] = g;
//#ifdef RS_DATA_SERVICE_DEBUG_CACHE
// std::cerr << ". Got it. Updating cache." << std::endl;
//#endif
// }
// valid = c->moveToNext();
//
//#ifdef RS_DATA_SERVICE_DEBUG_TIME
// ++resultCount;
//#endif
// }
// delete c;
// }
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
if(!valid) else
std::cerr << " Empty query! GrpId " << grpId << " is not in database" << std::endl; std::cerr << ". not found!" << std::endl;
#endif #endif
while(valid) }
{ }
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
if(g) }
{
grp[g->mGroupId] = g;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << ". Got it. Updating cache." << std::endl;
#endif
}
valid = c->moveToNext();
#ifdef RS_DATA_SERVICE_DEBUG_TIME
++resultCount;
#endif
}
delete c;
}
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
else
std::cerr << ". not found!" << std::endl;
#endif
}
}
}
#ifdef RS_DATA_SERVICE_DEBUG_TIME #ifdef RS_DATA_SERVICE_DEBUG_TIME
std::cerr << "RsDataService::retrieveGxsGrpMetaData() " << mDbName << ", Requests: " << requestedGroups << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl; std::cerr << "RsDataService::retrieveGxsGrpMetaData() " << mDbName << ", Requests: " << requestedGroups << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
@ -1474,14 +1522,14 @@ int RsDataService::resetDataStore()
return 1; return 1;
} }
int RsDataService::updateGroupMetaData(GrpLocMetaData &meta) int RsDataService::updateGroupMetaData(const GrpLocMetaData& meta)
{ {
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": Updating Grp Meta data: grpId = " << meta.grpId << std::endl; std::cerr << (void*)this << ": Updating Grp Meta data: grpId = " << meta.grpId << std::endl;
#endif #endif
RsStackMutex stack(mDbMutex); RsStackMutex stack(mDbMutex);
RsGxsGroupId& grpId = meta.grpId; const RsGxsGroupId& grpId = meta.grpId;
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": erasing old entry from cache." << std::endl; std::cerr << (void*)this << ": erasing old entry from cache." << std::endl;
@ -1492,17 +1540,19 @@ int RsDataService::updateGroupMetaData(GrpLocMetaData &meta)
return mDb->sqlUpdate(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", meta.val) ? 1 : 0; return mDb->sqlUpdate(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", meta.val) ? 1 : 0;
} }
int RsDataService::updateMessageMetaData(MsgLocMetaData &metaData) int RsDataService::updateMessageMetaData(const MsgLocMetaData& metaData)
{ {
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
std::cerr << (void*)this << ": Updating Msg Meta data: grpId = " << metaData.msgId.first << " msgId = " << metaData.msgId.second << std::endl; std::cerr << (void*)this << ": Updating Msg Meta data: grpId = " << metaData.msgId.first << " msgId = " << metaData.msgId.second << std::endl;
#endif #endif
RsStackMutex stack(mDbMutex); RsStackMutex stack(mDbMutex);
RsGxsGroupId& grpId = metaData.msgId.first; const RsGxsGroupId& grpId = metaData.msgId.first;
RsGxsMessageId& msgId = metaData.msgId.second; const RsGxsMessageId& msgId = metaData.msgId.second;
return mDb->sqlUpdate(MSG_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString()
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", metaData.val) ? 1 : 0; mMsgMetaDataCache[grpId].clear(msgId);
return mDb->sqlUpdate(MSG_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", metaData.val) ? 1 : 0;
} }
int RsDataService::removeMsgs(const GxsMsgReq& msgIds) int RsDataService::removeMsgs(const GxsMsgReq& msgIds)
@ -1627,13 +1677,13 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
{ {
const RsGxsGroupId& grpId = mit->first; const RsGxsGroupId& grpId = mit->first;
const std::set<RsGxsMessageId>& msgsV = mit->second; const std::set<RsGxsMessageId>& msgsV = mit->second;
std::set<RsGxsMessageId>::const_iterator vit = msgsV.begin(); auto& cache(mMsgMetaDataCache[grpId]);
for(; vit != msgsV.end(); ++vit) for(auto& msgId:msgsV)
{ {
const RsGxsMessageId& msgId = *vit; mDb->sqlDelete(MSG_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
mDb->sqlDelete(MSG_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString()
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", ""); cache.clear(msgId);
} }
} }

View File

@ -42,7 +42,9 @@ public:
bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; } bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; }
void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; } void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; }
const std::map<ID,MetaDataClass*> getFullMetaMap() const { return mMetas ; }
void getFullMetaList(std::map<ID,MetaDataClass*>& mp) const { mp = mMetas ; }
void getFullMetaList(std::vector<const MetaDataClass*>& mp) const { for(auto& m:mMetas) mp.push_back(m.second) ; }
MetaDataClass *getMeta(const ID& id) MetaDataClass *getMeta(const ID& id)
{ {
@ -128,7 +130,7 @@ private:
std::map<ID,MetaDataClass*> mMetas; std::map<ID,MetaDataClass*> mMetas;
std::list<std::pair<rstime_t,MetaDataClass*> > mOldCachedItems ; // dead list, where items get deleted after being unused for a while. This is due to not using smart ptrs. std::list<std::pair<rstime_t,MetaDataClass*> > mOldCachedItems ; // dead list, where items get deleted after being unused for a while. This is due to not using smart ptrs.
static const uint32_t CACHE_ENTRY_GRACE_PERIOD = 600 ; // 10 minutes static const uint32_t CACHE_ENTRY_GRACE_PERIOD = 600 ; // Unused items are deleted 10 minutes after last usage.
bool mCache_ContainsAllMetas ; bool mCache_ContainsAllMetas ;
}; };
@ -245,13 +247,13 @@ public:
* @param metaData The meta data item to update * @param metaData The meta data item to update
* @return error code * @return error code
*/ */
int updateMessageMetaData(MsgLocMetaData& metaData); int updateMessageMetaData(const MsgLocMetaData& metaData);
/*! /*!
* @param metaData The meta data item to update * @param metaData The meta data item to update
* @return error code * @return error code
*/ */
int updateGroupMetaData(GrpLocMetaData& meta); int updateGroupMetaData(const GrpLocMetaData &meta);
/*! /*!
* Completely clear out data stored in * Completely clear out data stored in
@ -292,9 +294,16 @@ private:
/*! /*!
* Retrieves all the msg meta results from a cursor * Retrieves all the msg meta results from a cursor
* @param c cursor to result set * @param c cursor to result set
* @param metaSet message metadata retrieved from cursor are stored here * @param msgMeta message metadata retrieved from cursor are stored here
*/ */
void locked_retrieveMsgMeta(RetroCursor* c, std::vector<RsGxsMsgMetaData*>& msgMeta); void locked_retrieveMsgMetaList(RetroCursor* c, std::vector<const RsGxsMsgMetaData*>& msgMeta);
/*!
* Retrieves all the grp meta results from a cursor
* @param c cursor to result set
* @param grpMeta group metadata retrieved from cursor are stored here
*/
void locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGroupId,RsGxsGrpMetaData *>& grpMeta);
/*! /*!
* extracts a msg meta item from a cursor at its * extracts a msg meta item from a cursor at its

View File

@ -239,12 +239,12 @@ public:
/*! /*!
* @param metaData * @param metaData
*/ */
virtual int updateMessageMetaData(MsgLocMetaData& metaData) = 0; virtual int updateMessageMetaData(const MsgLocMetaData& metaData) = 0;
/*! /*!
* @param metaData * @param metaData
*/ */
virtual int updateGroupMetaData(GrpLocMetaData& meta) = 0; virtual int updateGroupMetaData(const GrpLocMetaData& meta) = 0;
virtual int updateGroupKeys(const RsGxsGroupId& grpId,const RsTlvSecurityKeySet& keys,uint32_t subscribed_flags) = 0 ; virtual int updateGroupKeys(const RsGxsGroupId& grpId,const RsTlvSecurityKeySet& keys,uint32_t subscribed_flags) = 0 ;

View File

@ -1274,18 +1274,18 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token,
for(; mit != result.end(); ++mit) for(; mit != result.end(); ++mit)
{ {
std::vector<RsGxsMsgMetaData*>& metaV = mit->second; std::vector<const RsGxsMsgMetaData*>& metaV = mit->second;
std::vector<RsMsgMetaData>& msgInfoV = msgInfo[mit->first]; std::vector<RsMsgMetaData>& msgInfoV = msgInfo[mit->first];
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin(); std::vector<const RsGxsMsgMetaData*>::iterator vit = metaV.begin();
RsMsgMetaData meta; RsMsgMetaData meta;
for(; vit != metaV.end(); ++vit) for(; vit != metaV.end(); ++vit)
{ {
RsGxsMsgMetaData& m = *(*vit); const RsGxsMsgMetaData& m = *(*vit);
meta = m; meta = m;
msgInfoV.push_back(meta); msgInfoV.push_back(meta);
delete *vit; //delete *vit;
} }
metaV.clear(); metaV.clear();
} }
@ -1302,18 +1302,18 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
for(; mit != result.end(); ++mit) for(; mit != result.end(); ++mit)
{ {
std::vector<RsGxsMsgMetaData*>& metaV = mit->second; std::vector<const RsGxsMsgMetaData*>& metaV = mit->second;
std::vector<RsMsgMetaData>& msgInfoV = msgMeta[mit->first]; std::vector<RsMsgMetaData>& msgInfoV = msgMeta[mit->first];
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin(); std::vector<const RsGxsMsgMetaData*>::iterator vit = metaV.begin();
RsMsgMetaData meta; RsMsgMetaData meta;
for(; vit != metaV.end(); ++vit) for(; vit != metaV.end(); ++vit)
{ {
RsGxsMsgMetaData& m = *(*vit); const RsGxsMsgMetaData& m = *(*vit);
meta = m; meta = m;
msgInfoV.push_back(meta); msgInfoV.push_back(meta);
delete *vit; //delete *vit;
} }
metaV.clear(); metaV.clear();
} }
@ -2016,15 +2016,15 @@ void RsGenExchange::processMsgMetaChanges()
if(mit != result.end()) if(mit != result.end())
{ {
std::vector<RsGxsMsgMetaData*>& msgMetaV = mit->second; std::vector<const RsGxsMsgMetaData*>& msgMetaV = mit->second;
if(!msgMetaV.empty()) if(!msgMetaV.empty())
{ {
RsGxsMsgMetaData* meta = *(msgMetaV.begin()); const RsGxsMsgMetaData* meta = *(msgMetaV.begin());
value = (meta->mMsgStatus & ~mask) | (mask & value); value = (meta->mMsgStatus & ~mask) | (mask & value);
changed = (static_cast<int64_t>(meta->mMsgStatus) != value); changed = (static_cast<int64_t>(meta->mMsgStatus) != value);
m.val.put(RsGeneralDataService::MSG_META_STATUS, value); m.val.put(RsGeneralDataService::MSG_META_STATUS, value);
delete meta; //delete meta;
ok = true; ok = true;
} }
} }

View File

@ -29,8 +29,8 @@
/* data types used throughout Gxs from netservice to genexchange */ /* data types used throughout Gxs from netservice to genexchange */
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult; typedef std::map<RsGxsGroupId, std::vector<const RsGxsMsgMetaData*> > GxsMsgMetaResult;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgMetaData*> > MsgRelatedMetaResult; typedef std::map<RsGxsGrpMsgIdPair, std::vector<const RsGxsMsgMetaData*> > MsgRelatedMetaResult;
// Default values that are used throughout GXS code // Default values that are used throughout GXS code

View File

@ -209,7 +209,7 @@ RsGxsMsgMetaData::~RsGxsMsgMetaData(){
return; return;
} }
uint32_t RsGxsMsgMetaData::serial_size() uint32_t RsGxsMsgMetaData::serial_size() const
{ {
uint32_t s = 8; // header size uint32_t s = 8; // header size

View File

@ -94,7 +94,7 @@ public:
~RsGxsMsgMetaData(); ~RsGxsMsgMetaData();
bool deserialise(void *data, uint32_t *size); bool deserialise(void *data, uint32_t *size);
bool serialise(void* data, uint32_t *size); bool serialise(void* data, uint32_t *size);
uint32_t serial_size(); uint32_t serial_size() const;
void clear(); void clear();
void operator =(const RsMsgMetaData& rMeta); void operator =(const RsMsgMetaData& rMeta);

View File

@ -1028,7 +1028,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
//auto& filter( metaFilter[grpId] ); // does the initialization of metaFilter[grpId] and avoids further O(log(n)) calls //auto& filter( metaFilter[grpId] ); // does the initialization of metaFilter[grpId] and avoids further O(log(n)) calls
std::vector<RsGxsMsgMetaData*>& metaV = meta_it->second; std::vector<const RsGxsMsgMetaData*>& metaV = meta_it->second;
if (onlyLatestMsgs) // if we only consider latest messages, we need to first filter out messages with "children" if (onlyLatestMsgs) // if we only consider latest messages, we need to first filter out messages with "children"
{ {
@ -1062,7 +1062,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
for(uint32_t i=0;i<metaV.size();++i) for(uint32_t i=0;i<metaV.size();++i)
if(!keep[i]) if(!keep[i])
{ {
delete metaV[i]; //delete metaV[i];
metaV[i] = nullptr; metaV[i] = nullptr;
} }
} }
@ -1122,20 +1122,20 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
for(uint32_t i=0;i<metaV.size();++i) for(uint32_t i=0;i<metaV.size();++i)
if(metaV[i] != nullptr) if(metaV[i] != nullptr)
{ {
RsGxsMsgMetaData* msgMeta = metaV[i]; const RsGxsMsgMetaData* msgMeta = metaV[i];
bool add = false; bool add = false;
/* if we are grabbing thread Head... then parentId == empty. */ /* if we are grabbing thread Head... then parentId == empty. */
if (onlyThreadHeadMsgs && !msgMeta->mParentId.isNull()) if (onlyThreadHeadMsgs && !msgMeta->mParentId.isNull())
{ {
delete msgMeta; //delete msgMeta;
metaV[i] = nullptr; metaV[i] = nullptr;
continue; continue;
} }
if (onlyOrigMsgs && !msgMeta->mOrigMsgId.isNull() && msgMeta->mMsgId != msgMeta->mOrigMsgId) if (onlyOrigMsgs && !msgMeta->mOrigMsgId.isNull() && msgMeta->mMsgId != msgMeta->mOrigMsgId)
{ {
delete msgMeta; //delete msgMeta;
metaV[i] = nullptr; metaV[i] = nullptr;
continue; continue;
} }
@ -1187,7 +1187,7 @@ bool RsGxsDataAccess::getMsgIdList( const GxsMsgReq& msgIds, const RsTokReqOptio
} }
// delete meta data // delete meta data
cleanseMsgMetaMap(result); //cleanseMsgMetaMap(result);
return true; return true;
} }
@ -1296,9 +1296,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
return true; return true;
} }
std::vector<RsGxsGrpMsgIdPair>::iterator vit_msgIds = req->mMsgIds.begin(); for(auto vit_msgIds(req->mMsgIds.begin()); vit_msgIds != req->mMsgIds.end(); ++vit_msgIds)
for(; vit_msgIds != req->mMsgIds.end(); ++vit_msgIds)
{ {
MsgMetaFilter filterMap; MsgMetaFilter filterMap;
@ -1310,8 +1308,8 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
GxsMsgReq msgIds; GxsMsgReq msgIds;
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>())); msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>()));
mDataStore->retrieveGxsMsgMetaData(msgIds, result); mDataStore->retrieveGxsMsgMetaData(msgIds, result);
std::vector<RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first]; std::vector<const RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first];
std::vector<RsGxsMsgMetaData*>::iterator vit_meta; std::vector<const RsGxsMsgMetaData*>::iterator vit_meta;
// msg id to relate to // msg id to relate to
const RsGxsMessageId& msgId = grpMsgIdPair.second; const RsGxsMessageId& msgId = grpMsgIdPair.second;
@ -1319,10 +1317,11 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
std::set<RsGxsMessageId> outMsgIds; std::set<RsGxsMessageId> outMsgIds;
RsGxsMsgMetaData* origMeta = nullptr; const RsGxsMsgMetaData* origMeta = nullptr;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{ {
RsGxsMsgMetaData* meta = *vit_meta; const RsGxsMsgMetaData* meta = *vit_meta;
if(msgId == meta->mMsgId) if(msgId == meta->mMsgId)
{ {
@ -1337,12 +1336,11 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
RsDbg() << "RsGxsDataAccess::getMsgRelatedInfo(): Cannot find meta of msgId (to relate to)!" RsDbg() << "RsGxsDataAccess::getMsgRelatedInfo(): Cannot find meta of msgId (to relate to)!"
<< std::endl; << std::endl;
#endif #endif
cleanseMsgMetaMap(result);
return false; return false;
} }
const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId; const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>& metaMap = filterMap[grpId]; std::map<RsGxsMessageId, const RsGxsMsgMetaData*>& metaMap = filterMap[grpId];
if (onlyLatestMsgs) if (onlyLatestMsgs)
{ {
@ -1354,7 +1352,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{ {
RsGxsMsgMetaData* meta = *vit_meta; const RsGxsMsgMetaData* meta = *vit_meta;
// skip msgs that aren't children. // skip msgs that aren't children.
if (onlyChildMsgs) if (onlyChildMsgs)
@ -1422,11 +1420,11 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
/* first guess is potentially better than Orig (can't be worse!) */ /* first guess is potentially better than Orig (can't be worse!) */
rstime_t latestTs = 0; rstime_t latestTs = 0;
RsGxsMessageId latestMsgId; RsGxsMessageId latestMsgId;
RsGxsMsgMetaData* latestMeta=nullptr; const RsGxsMsgMetaData* latestMeta=nullptr;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{ {
RsGxsMsgMetaData* meta = *vit_meta; const RsGxsMsgMetaData* meta = *vit_meta;
if (meta->mOrigMsgId == origMsgId) if (meta->mOrigMsgId == origMsgId)
{ {
@ -1446,7 +1444,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
{ {
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{ {
RsGxsMsgMetaData* meta = *vit_meta; const RsGxsMsgMetaData* meta = *vit_meta;
if (meta->mOrigMsgId == origMsgId) if (meta->mOrigMsgId == origMsgId)
{ {
@ -1482,8 +1480,6 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
outMsgIds.clear(); outMsgIds.clear();
filteredOutMsgIds.clear(); filteredOutMsgIds.clear();
cleanseMsgMetaMap(result);
} }
return true; return true;
} }
@ -1496,7 +1492,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
GxsMsgMetaResult metaResult; GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult); mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
const std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId]; const std::vector<const RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
req->mGroupStatistic.mGrpId = req->mGrpId; req->mGroupStatistic.mGrpId = req->mGrpId;
req->mGroupStatistic.mNumMsgs = msgMetaV.size(); req->mGroupStatistic.mNumMsgs = msgMetaV.size();
@ -1514,7 +1510,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
for(uint32_t i = 0; i < msgMetaV.size(); ++i) for(uint32_t i = 0; i < msgMetaV.size(); ++i)
{ {
RsGxsMsgMetaData* m = msgMetaV[i]; const RsGxsMsgMetaData* m = msgMetaV[i];
req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size(); req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size();
if(obsolete_msgs.find(m->mMsgId) != obsolete_msgs.end()) // skip obsolete messages. if(obsolete_msgs.find(m->mMsgId) != obsolete_msgs.end()) // skip obsolete messages.
@ -1540,7 +1536,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
} }
} }
cleanseMsgMetaMap(metaResult); //cleanseMsgMetaMap(metaResult);
return true; return true;
} }
@ -1595,21 +1591,19 @@ bool RsGxsDataAccess::getMsgIdList(MsgIdReq* req)
mDataStore->retrieveGxsMsgMetaData(req->mMsgIds, result); mDataStore->retrieveGxsMsgMetaData(req->mMsgIds, result);
GxsMsgMetaResult::iterator mit = result.begin(), mit_end = result.end(); GxsMsgMetaResult::iterator mit = result.begin(), mit_end = result.end();
for(; mit != mit_end; ++mit) for(; mit != mit_end; ++mit)
{ {
const RsGxsGroupId grpId = mit->first; const RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgMetaData*>& metaV = mit->second; std::vector<const RsGxsMsgMetaData*>& metaV = mit->second;
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin(), std::vector<const RsGxsMsgMetaData*>::iterator vit = metaV.begin(),
vit_end = metaV.end(); vit_end = metaV.end();
for(; vit != vit_end; ++vit) for(; vit != vit_end; ++vit)
{ {
RsGxsMsgMetaData* meta = *vit; const RsGxsMsgMetaData* meta = *vit;
req->mMsgIdResult[grpId].insert(meta->mMsgId); req->mMsgIdResult[grpId].insert(meta->mMsgId);
delete meta; // discard meta data mem
} }
} }
@ -1622,24 +1616,24 @@ bool RsGxsDataAccess::getMsgIdList(MsgIdReq* req)
return true; return true;
} }
void RsGxsDataAccess::cleanseMsgMetaMap(GxsMsgMetaResult& result) // void RsGxsDataAccess::cleanseMsgMetaMap(GxsMsgMetaResult& result)
{ // {
GxsMsgMetaResult::iterator mit = result.begin(); // GxsMsgMetaResult::iterator mit = result.begin();
//
for(; mit !=result.end(); ++mit) // for(; mit !=result.end(); ++mit)
{ // {
//
std::vector<RsGxsMsgMetaData*>& msgMetaV = mit->second; // std::vector<RsGxsMsgMetaData*>& msgMetaV = mit->second;
std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetaV.begin(); // std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetaV.begin();
for(; vit != msgMetaV.end(); ++vit) // for(; vit != msgMetaV.end(); ++vit)
{ // {
delete *vit; // delete *vit;
} // }
} // }
//
result.clear(); // result.clear();
return; // return;
} // }
void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokReqOptions& opts, const MsgMetaFilter& msgMetas ) const void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokReqOptions& opts, const MsgMetaFilter& msgMetas ) const
{ {
@ -1659,11 +1653,11 @@ void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokRe
for( std::set<RsGxsMessageId>::iterator msgIdIt = msgsIdSet.begin(); msgIdIt != msgsIdSet.end(); ) for( std::set<RsGxsMessageId>::iterator msgIdIt = msgsIdSet.begin(); msgIdIt != msgsIdSet.end(); )
{ {
const RsGxsMessageId& msgId(*msgIdIt); const RsGxsMessageId& msgId(*msgIdIt);
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& msgsMetaMap = const std::map<RsGxsMessageId, const RsGxsMsgMetaData*>& msgsMetaMap =
cit->second; cit->second;
bool keep = false; bool keep = false;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator msgsMetaMapIt; std::map<RsGxsMessageId, const RsGxsMsgMetaData*>::const_iterator msgsMetaMapIt;
if( (msgsMetaMapIt = msgsMetaMap.find(msgId)) != msgsMetaMap.end() ) if( (msgsMetaMapIt = msgsMetaMap.find(msgId)) != msgsMetaMap.end() )
{ {

View File

@ -28,7 +28,7 @@
#include "rsgds.h" #include "rsgds.h"
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter; typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, const RsGxsMsgMetaData*> > MsgMetaFilter;
typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter; typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter;
bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2); bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2);
@ -328,11 +328,11 @@ private:
*/ */
void tokenList(std::list<uint32_t> &tokens); void tokenList(std::list<uint32_t> &tokens);
/*! // /*!
* Convenience function to delete the ids // * Convenience function to delete the ids
* @param filter the meta filter to clean // * @param filter the meta filter to clean
*/ // */
void cleanseMsgMetaMap(GxsMsgMetaResult& result); // void cleanseMsgMetaMap(GxsMsgMetaResult& result);
public: public:

View File

@ -953,7 +953,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
#endif #endif
mDataStore->retrieveGxsMsgMetaData(reqIds, result); mDataStore->retrieveGxsMsgMetaData(reqIds, result);
const std::vector<RsGxsMsgMetaData*>& vec(result[grs->grpId]) ; const std::vector<const RsGxsMsgMetaData*>& vec(result[grs->grpId]) ;
if(vec.empty()) // that means we don't have any, or there isn't any, but since the default is always 0, no need to send. if(vec.empty()) // that means we don't have any, or there isn't any, but since the default is always 0, no need to send.
return ; return ;
@ -970,12 +970,9 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
// be used to discard groups that are not used. // be used to discard groups that are not used.
for(uint32_t i=0;i<vec.size();++i) for(uint32_t i=0;i<vec.size();++i)
{
if(grs_resp->last_post_TS < vec[i]->mPublishTs) if(grs_resp->last_post_TS < vec[i]->mPublishTs)
grs_resp->last_post_TS = vec[i]->mPublishTs; grs_resp->last_post_TS = vec[i]->mPublishTs;
delete vec[i] ;
}
#ifdef NXS_NET_DEBUG_6 #ifdef NXS_NET_DEBUG_6
GXSNETDEBUG_PG(grs->PeerId(),grs->grpId) << " sending back statistics item with " << vec.size() << " elements." << std::endl; GXSNETDEBUG_PG(grs->PeerId(),grs->grpId) << " sending back statistics item with " << vec.size() << " elements." << std::endl;
#endif #endif
@ -2953,21 +2950,19 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
reqIds[grpId] = std::set<RsGxsMessageId>(); reqIds[grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult result; GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(reqIds, result); mDataStore->retrieveGxsMsgMetaData(reqIds, result);
std::vector<RsGxsMsgMetaData*> &msgMetaV = result[grpId]; std::vector<const RsGxsMsgMetaData*> &msgMetaV = result[grpId];
#ifdef NXS_NET_DEBUG_1 #ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << " retrieving grp message list..." << std::endl; GXSNETDEBUG_PG(item->PeerId(),grpId) << " retrieving grp message list..." << std::endl;
GXSNETDEBUG_PG(item->PeerId(),grpId) << " grp locally contains " << msgMetaV.size() << " messsages." << std::endl; GXSNETDEBUG_PG(item->PeerId(),grpId) << " grp locally contains " << msgMetaV.size() << " messsages." << std::endl;
#endif #endif
std::vector<RsGxsMsgMetaData*>::const_iterator vit = msgMetaV.begin(); std::vector<const RsGxsMsgMetaData*>::const_iterator vit = msgMetaV.begin();
std::set<RsGxsMessageId> msgIdSet; std::set<RsGxsMessageId> msgIdSet;
// put ids in set for each searching // put ids in set for each searching
for(; vit != msgMetaV.end(); ++vit) for(; vit != msgMetaV.end(); ++vit)
{
msgIdSet.insert((*vit)->mMsgId); msgIdSet.insert((*vit)->mMsgId);
delete(*vit);
}
msgMetaV.clear(); msgMetaV.clear();
#ifdef NXS_NET_DEBUG_1 #ifdef NXS_NET_DEBUG_1
@ -4367,7 +4362,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
GxsMsgMetaResult metaResult; GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(req, metaResult); mDataStore->retrieveGxsMsgMetaData(req, metaResult);
std::vector<RsGxsMsgMetaData*>& msgMetas = metaResult[item->grpId]; std::vector<const RsGxsMsgMetaData*>& msgMetas = metaResult[item->grpId];
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " retrieving message meta data." << std::endl; GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " retrieving message meta data." << std::endl;
@ -4395,9 +4390,9 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
if(canSendMsgIds(msgMetas, *grpMeta, peer, should_encrypt_to_this_circle_id)) if(canSendMsgIds(msgMetas, *grpMeta, peer, should_encrypt_to_this_circle_id))
{ {
for(std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin();vit != msgMetas.end(); ++vit) for(auto vit = msgMetas.begin();vit != msgMetas.end(); ++vit)
{ {
RsGxsMsgMetaData* m = *vit; const RsGxsMsgMetaData* m = *vit;
// Check reputation // Check reputation
@ -4497,8 +4492,8 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
// release meta resource // release meta resource
for(std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin(); vit != msgMetas.end(); ++vit) // for(std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin(); vit != msgMetas.end(); ++vit)
delete *vit; // delete *vit;
} }
void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const RsGxsGroupId& grp_id,const uint32_t& transN) void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const RsGxsGroupId& grp_id,const uint32_t& transN)
@ -4542,7 +4537,7 @@ void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, c
} }
} }
bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData& grpMeta, const RsPeerId& sslId,RsGxsCircleId& should_encrypt_id) bool RsGxsNetService::canSendMsgIds(std::vector<const RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData& grpMeta, const RsPeerId& sslId,RsGxsCircleId& should_encrypt_id)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendMsgIds() CIRCLE VETTING" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendMsgIds() CIRCLE VETTING" << std::endl;

View File

@ -395,7 +395,7 @@ private:
* @return false, if you cannot send to this peer, true otherwise * @return false, if you cannot send to this peer, true otherwise
*/ */
bool canSendGrpId(const RsPeerId& sslId, const RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt); bool canSendGrpId(const RsPeerId& sslId, const RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt);
bool canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id); bool canSendMsgIds(std::vector<const RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id);
/*! /*!
* \brief checkPermissionsForFriendGroup * \brief checkPermissionsForFriendGroup

View File

@ -85,7 +85,7 @@ bool RsGxsMessageCleanUp::clean()
for(; mit != result.end(); ++mit) for(; mit != result.end(); ++mit)
{ {
std::vector<RsGxsMsgMetaData*>& metaV = mit->second; std::vector<const RsGxsMsgMetaData*>& metaV = mit->second;
// First, make a map of which message have a child message. This allows to only delete messages that dont have child messages. // First, make a map of which message have a child message. This allows to only delete messages that dont have child messages.
// A more accurate way to go would be to compute the time of the oldest message and possibly delete all the branch, but in the // A more accurate way to go would be to compute the time of the oldest message and possibly delete all the branch, but in the
@ -99,7 +99,7 @@ bool RsGxsMessageCleanUp::clean()
for( uint32_t i=0;i<metaV.size();++i) for( uint32_t i=0;i<metaV.size();++i)
{ {
RsGxsMsgMetaData* meta = metaV[i]; const RsGxsMsgMetaData* meta = metaV[i];
bool have_kids = (messages_with_kids.find(meta->mMsgId)!=messages_with_kids.end()); bool have_kids = (messages_with_kids.find(meta->mMsgId)!=messages_with_kids.end());
@ -132,7 +132,7 @@ bool RsGxsMessageCleanUp::clean()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
delete meta; //delete meta;
} }
} }