mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 16:45:11 -04:00
merged upstream/master
This commit is contained in:
commit
95e8fc4404
38 changed files with 785 additions and 340 deletions
|
@ -113,6 +113,8 @@ const std::string RsGeneralDataService::MSG_META_STATUS = KEY_MSG_STATUS;
|
|||
|
||||
const uint32_t RsGeneralDataService::GXS_MAX_ITEM_SIZE = 1572864; // 1.5 Mbytes
|
||||
|
||||
static const uint32_t CACHE_ENTRY_GRACE_PERIOD = 600 ; // 10 minutes
|
||||
|
||||
static int addColumn(std::list<std::string> &list, const std::string &attribute)
|
||||
{
|
||||
list.push_back(attribute);
|
||||
|
@ -486,15 +488,13 @@ bool RsDataService::finishReleaseUpdate(int release, bool result)
|
|||
return result;
|
||||
}
|
||||
|
||||
RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset)
|
||||
RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset,bool use_cache)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::locked_getGrpMeta()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsGxsGrpMetaData* grpMeta = new RsGxsGrpMetaData();
|
||||
|
||||
bool ok = true;
|
||||
|
||||
// for extracting raw data
|
||||
|
@ -505,6 +505,25 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
|
|||
// grpId
|
||||
std::string tempId;
|
||||
c.getString(mColGrpMeta_GrpId + colOffset, tempId);
|
||||
|
||||
RsGxsGrpMetaData* grpMeta ;
|
||||
RsGxsGroupId grpId(tempId) ;
|
||||
|
||||
if(use_cache)
|
||||
{
|
||||
auto it = mGrpMetaDataCache.find(grpId) ;
|
||||
|
||||
if(it != mGrpMetaDataCache.end())
|
||||
grpMeta = it->second ;
|
||||
else
|
||||
{
|
||||
grpMeta = new RsGxsGrpMetaData();
|
||||
mGrpMetaDataCache[grpId] = grpMeta ;
|
||||
}
|
||||
}
|
||||
else
|
||||
grpMeta = new RsGxsGrpMetaData();
|
||||
|
||||
grpMeta->mGroupId = RsGxsGroupId(tempId);
|
||||
c.getString(mColGrpMeta_NxsIdentity + colOffset, tempId);
|
||||
grpMeta->mAuthorId = RsGxsId(tempId);
|
||||
|
@ -556,9 +575,11 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
|
|||
if(ok)
|
||||
return grpMeta;
|
||||
else
|
||||
delete grpMeta;
|
||||
|
||||
return NULL;
|
||||
{
|
||||
if(!use_cache)
|
||||
delete grpMeta;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
RsNxsGrp* RsDataService::locked_getGroup(RetroCursor &c)
|
||||
|
@ -876,7 +897,7 @@ int RsDataService::storeGroup(const std::list<RsNxsGrp*>& grp)
|
|||
cv.put(KEY_GRP_STATUS, (int32_t)grpMetaPtr->mGroupStatus);
|
||||
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
|
||||
|
||||
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
|
||||
locked_updateGrpMetaCache(*grpMetaPtr);
|
||||
|
||||
if (!mDb->sqlInsert(GRP_TABLE_NAME, "", cv))
|
||||
{
|
||||
|
@ -892,10 +913,46 @@ int RsDataService::storeGroup(const std::list<RsNxsGrp*>& grp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void RsDataService::locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta)
|
||||
{
|
||||
auto it = mGrpMetaDataCache.find(meta.mGroupId) ;
|
||||
|
||||
if(it != mGrpMetaDataCache.end())
|
||||
*(it->second) = meta ;
|
||||
}
|
||||
|
||||
void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid)
|
||||
{
|
||||
mGrpMetaDataCache.erase(gid) ; // cleans existing cache entry
|
||||
mGrpMetaDataCache_ContainsAllDatabase = false;
|
||||
time_t now = time(NULL) ;
|
||||
auto it = mGrpMetaDataCache.find(gid) ;
|
||||
|
||||
// We dont actually delete the item, because it might be used by a calling client.
|
||||
// In this case, the memory will not be used for long, so we keep it into a list for a safe amount
|
||||
// of time and delete it later. Using smart pointers here would be more elegant, but that would need
|
||||
// to be implemented thread safe, which is difficult in this case.
|
||||
|
||||
if(it != mGrpMetaDataCache.end())
|
||||
{
|
||||
std::cerr << "(II) moving database cache entry " << (void*)(*it).second << " to dead list." << std::endl;
|
||||
|
||||
mOldCachedItems.push_back(std::make_pair(now,it->second)) ;
|
||||
|
||||
mGrpMetaDataCache.erase(it) ;
|
||||
mGrpMetaDataCache_ContainsAllDatabase = false;
|
||||
}
|
||||
|
||||
// We also take that opportunity to delete old entries.
|
||||
|
||||
auto it2(mOldCachedItems.begin());
|
||||
|
||||
while(it2!=mOldCachedItems.end() && (*it2).first + CACHE_ENTRY_GRACE_PERIOD < now)
|
||||
{
|
||||
std::cerr << "(II) deleting old GXS database cache entry " << (void*)(*it2).second << ", " << now - (*it2).first << " seconds old." << std::endl;
|
||||
|
||||
delete (*it2).second ;
|
||||
it2 = mOldCachedItems.erase(it2) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int RsDataService::updateGroup(const std::list<RsNxsGrp *> &grp)
|
||||
|
@ -966,7 +1023,7 @@ int RsDataService::updateGroup(const std::list<RsNxsGrp *> &grp)
|
|||
|
||||
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
|
||||
|
||||
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
|
||||
locked_updateGrpMetaCache(*grpMetaPtr);
|
||||
}
|
||||
// finish transaction
|
||||
bool ret = mDb->commitTransaction();
|
||||
|
@ -1097,7 +1154,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
|||
if(g)
|
||||
{
|
||||
if (metaOffset) {
|
||||
g->metaData = locked_getGrpMeta(*c, metaOffset);
|
||||
g->metaData = locked_getGrpMeta(*c, metaOffset,false);
|
||||
}
|
||||
grps.push_back(g);
|
||||
}
|
||||
|
@ -1274,7 +1331,7 @@ void RsDataService::locked_retrieveMsgMeta(RetroCursor *c, std::vector<RsGxsMsgM
|
|||
}
|
||||
}
|
||||
|
||||
int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaData *>& grp)
|
||||
int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::retrieveGxsGrpMetaData()";
|
||||
|
@ -1297,100 +1354,101 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
|||
std::cerr << (void*)this << ": RsDataService::retrieveGxsGrpMetaData() retrieving all from cache!" << std::endl;
|
||||
#endif
|
||||
|
||||
for(std::map<RsGxsGroupId,RsGxsGrpMetaData>::const_iterator it(mGrpMetaDataCache.begin());it!=mGrpMetaDataCache.end();++it)
|
||||
grp[it->first] = new RsGxsGrpMetaData(it->second);
|
||||
grp = mGrpMetaDataCache ;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::retrieveGxsGrpMetaData() retrieving all" << std::endl;
|
||||
std::cerr << "RsDataService::retrieveGxsGrpMetaData() retrieving all" << std::endl;
|
||||
#endif
|
||||
// clear the cache
|
||||
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "", "");
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "", "");
|
||||
|
||||
if(c)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
if(c)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
|
||||
while(valid)
|
||||
{
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0);
|
||||
if(g)
|
||||
{
|
||||
grp[g->mGroupId] = g;
|
||||
mGrpMetaDataCache[g->mGroupId] = *g ;
|
||||
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 << ": Retrieving (all) Grp metadata grpId=" << g->mGroupId << std::endl;
|
||||
std::cerr << (void *)this << ": Retrieving (all) Grp metadata grpId=" << g->mGroupId << std::endl;
|
||||
#endif
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
++resultCount;
|
||||
++resultCount;
|
||||
#endif
|
||||
}
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
delete c;
|
||||
}
|
||||
|
||||
mGrpMetaDataCache_ContainsAllDatabase = true ;
|
||||
}
|
||||
|
||||
mGrpMetaDataCache_ContainsAllDatabase = true ;
|
||||
}
|
||||
|
||||
}else
|
||||
else
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData *>::iterator mit = grp.begin();
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData *>::iterator mit = grp.begin();
|
||||
|
||||
for(; mit != grp.end(); ++mit)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData>::const_iterator itt = mGrpMetaDataCache.find(mit->first) ;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator itt = mGrpMetaDataCache.find(mit->first) ;
|
||||
|
||||
if(itt != mGrpMetaDataCache.end())
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
|
||||
std::cerr << "Retrieving Grp metadata grpId=" << mit->first << " from cache!" << std::endl;
|
||||
#endif
|
||||
grp[mit->first] = new RsGxsGrpMetaData(itt->second) ;
|
||||
grp[mit->first] = itt->second ;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
|
||||
std::cerr << "Retrieving Grp metadata grpId=" << mit->first ;
|
||||
std::cerr << "Retrieving Grp metadata grpId=" << mit->first ;
|
||||
#endif
|
||||
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", "");
|
||||
const RsGxsGroupId& grpId = mit->first;
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", "");
|
||||
|
||||
if(c)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
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;
|
||||
if(!valid)
|
||||
std::cerr << " Empty query! GrpId " << grpId << " is not in database" << std::endl;
|
||||
#endif
|
||||
while(valid)
|
||||
{
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0);
|
||||
while(valid)
|
||||
{
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
|
||||
|
||||
if(g)
|
||||
{
|
||||
grp[g->mGroupId] = g;
|
||||
mGrpMetaDataCache[g->mGroupId] = *g ;
|
||||
if(g)
|
||||
{
|
||||
grp[g->mGroupId] = g;
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
|
||||
std::cerr << ". Got it. Updating cache." << std::endl;
|
||||
std::cerr << ". Got it. Updating cache." << std::endl;
|
||||
#endif
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
++resultCount;
|
||||
++resultCount;
|
||||
#endif
|
||||
}
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
delete c;
|
||||
}
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
|
||||
else
|
||||
std::cerr << ". not found!" << std::endl;
|
||||
else
|
||||
std::cerr << ". not found!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1607,7 +1665,7 @@ bool RsDataService::locked_removeGroupEntries(const std::vector<RsGxsGroupId>& g
|
|||
mDb->sqlDelete(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||
|
||||
// also remove the group meta from cache.
|
||||
mGrpMetaDataCache.erase(*vit) ;
|
||||
locked_clearGrpMetaCache(*vit) ;
|
||||
}
|
||||
|
||||
ret &= mDb->commitTransaction();
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaData*>& grp);
|
||||
int retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp);
|
||||
|
||||
/*!
|
||||
* Retrieves meta data of all groups stored (most current versions only)
|
||||
|
@ -208,7 +208,7 @@ private:
|
|||
* extracts a grp meta item from a cursor at its
|
||||
* current position
|
||||
*/
|
||||
RsGxsGrpMetaData* locked_getGrpMeta(RetroCursor& c, int colOffset);
|
||||
RsGxsGrpMetaData* locked_getGrpMeta(RetroCursor& c, int colOffset, bool use_cache);
|
||||
|
||||
/*!
|
||||
* extracts a msg item from a cursor at its
|
||||
|
@ -346,8 +346,11 @@ private:
|
|||
// the entre list of grp metadata is requested (which happens quite often)
|
||||
|
||||
void locked_clearGrpMetaCache(const RsGxsGroupId& gid);
|
||||
void locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta);
|
||||
|
||||
std::map<RsGxsGroupId,RsGxsGrpMetaData*> mGrpMetaDataCache ;
|
||||
std::list<std::pair<time_t,RsGxsGrpMetaData*> > mOldCachedItems ;
|
||||
|
||||
std::map<RsGxsGroupId,RsGxsGrpMetaData> mGrpMetaDataCache ;
|
||||
bool mGrpMetaDataCache_ContainsAllDatabase ;
|
||||
};
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
#include "rsitems/rsnxsitems.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
#include "rsgxs.h"
|
||||
#include "rsgxsutil.h"
|
||||
#include "util/contentvalue.h"
|
||||
|
||||
|
||||
class RsGxsSearchModule {
|
||||
|
||||
public:
|
||||
|
@ -61,6 +61,8 @@ public:
|
|||
ContentValue val;
|
||||
};
|
||||
|
||||
typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap;
|
||||
|
||||
/*!
|
||||
* This allows modification of local
|
||||
* meta data items of a group
|
||||
|
@ -168,7 +170,7 @@ public:
|
|||
* , if grpId is failed to be retrieved it will be erased from map
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaData*>& grp) = 0;
|
||||
virtual int retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) = 0;
|
||||
|
||||
/*!
|
||||
* Retrieves meta data of all groups stored (most current versions only)
|
||||
|
|
|
@ -533,7 +533,7 @@ int RsGenExchange::createGroupSignatures(RsTlvKeySignatureSet& signSet, RsTlvBin
|
|||
}
|
||||
|
||||
int RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBinaryData& msgData,
|
||||
const RsGxsMsgMetaData& msgMeta, RsGxsGrpMetaData& grpMeta)
|
||||
const RsGxsMsgMetaData& msgMeta, const RsGxsGrpMetaData& grpMeta)
|
||||
{
|
||||
bool needPublishSign = false, needIdentitySign = false;
|
||||
uint32_t grpFlag = grpMeta.mGroupFlags;
|
||||
|
@ -714,8 +714,7 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
|
|||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::createMessage() " << std::endl;
|
||||
#endif
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> metaMap;
|
||||
|
||||
RsGxsGrpMetaTemporaryMap metaMap ;
|
||||
metaMap.insert(std::make_pair(id, (RsGxsGrpMetaData*)(NULL)));
|
||||
mDataStore->retrieveGxsGrpMetaData(metaMap);
|
||||
|
||||
|
@ -730,7 +729,7 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
|
|||
else
|
||||
{
|
||||
// get publish key
|
||||
RsGxsGrpMetaData* grpMeta = metaMap[id];
|
||||
const RsGxsGrpMetaData* grpMeta = metaMap[id];
|
||||
|
||||
uint32_t metaDataLen = meta.serial_size();
|
||||
uint32_t allMsgDataLen = metaDataLen + msg->msg.bin_len;
|
||||
|
@ -763,8 +762,6 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
|
|||
|
||||
delete[] metaData;
|
||||
delete[] allMsgData;
|
||||
|
||||
delete grpMeta;
|
||||
}
|
||||
|
||||
if(ret_val == SIGN_FAIL)
|
||||
|
@ -1196,14 +1193,14 @@ bool RsGenExchange::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult
|
|||
|
||||
bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
|
||||
{
|
||||
std::list<RsGxsGrpMetaData*> metaL;
|
||||
std::list<const RsGxsGrpMetaData*> metaL;
|
||||
bool ok = mDataAccess->getGroupSummary(token, metaL);
|
||||
|
||||
RsGroupMetaData m;
|
||||
|
||||
for( std::list<RsGxsGrpMetaData*>::iterator lit = metaL.begin(); lit != metaL.end(); ++lit)
|
||||
for( auto lit = metaL.begin(); lit != metaL.end(); ++lit)
|
||||
{
|
||||
RsGxsGrpMetaData& gMeta = *(*lit);
|
||||
const RsGxsGrpMetaData& gMeta = *(*lit);
|
||||
|
||||
m = gMeta;
|
||||
RsGroupNetworkStats sts ;
|
||||
|
@ -1223,7 +1220,6 @@ bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaDat
|
|||
}
|
||||
|
||||
groupInfo.push_back(m);
|
||||
delete (*lit);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -2080,10 +2076,10 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
|
|||
// first find out which mask is involved
|
||||
int32_t value, mask, currValue;
|
||||
std::string key;
|
||||
RsGxsGrpMetaData* grpMeta = NULL;
|
||||
const RsGxsGrpMetaData* grpMeta = NULL;
|
||||
bool ok = false;
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData* > grpMetaMap;
|
||||
RsGxsGrpMetaTemporaryMap grpMetaMap;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData* >::iterator mit;
|
||||
grpMetaMap.insert(std::make_pair(grpId, (RsGxsGrpMetaData*)(NULL)));
|
||||
|
||||
|
@ -2092,6 +2088,7 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
|
|||
if((mit = grpMetaMap.find(grpId)) != grpMetaMap.end())
|
||||
{
|
||||
grpMeta = mit->second;
|
||||
|
||||
if (!grpMeta)
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
|
@ -2112,12 +2109,9 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
|
|||
{
|
||||
key = RsGeneralDataService::GRP_META_SUBSCRIBE_FLAG;
|
||||
currValue = grpMeta->mSubscribeFlags;
|
||||
}else
|
||||
{
|
||||
if(grpMeta)
|
||||
delete grpMeta;
|
||||
return !(grpCv.empty());
|
||||
}
|
||||
else
|
||||
return !(grpCv.empty());
|
||||
|
||||
ok &= grpCv.getAsInt32(key+GXS_MASK, mask);
|
||||
|
||||
|
@ -2129,9 +2123,6 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
|
|||
|
||||
grpCv.put(key, value);
|
||||
|
||||
if(grpMeta)
|
||||
delete grpMeta;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -2350,7 +2341,7 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||
// get keys for group update publish
|
||||
|
||||
// first build meta request map for groups to be updated
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||
RsGxsGrpMetaTemporaryMap grpMeta;
|
||||
std::vector<GroupUpdatePublish>::iterator vit = mGroupUpdatePublish.begin();
|
||||
|
||||
for(; vit != mGroupUpdatePublish.end(); ++vit)
|
||||
|
@ -2360,8 +2351,8 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||
grpMeta.insert(std::make_pair(groupId, (RsGxsGrpMetaData*)(NULL)));
|
||||
}
|
||||
|
||||
if(grpMeta.empty())
|
||||
return;
|
||||
if(grpMeta.empty())
|
||||
return;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
|
@ -2373,18 +2364,16 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.find(groupId);
|
||||
|
||||
RsGxsGrpMetaData* meta = NULL;
|
||||
const RsGxsGrpMetaData* meta = NULL;
|
||||
if(mit == grpMeta.end() || mit->second == NULL)
|
||||
{
|
||||
std::cerr << "Error! could not find meta of old group to update!" << std::endl;
|
||||
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
|
||||
delete gup.grpItem;
|
||||
continue;
|
||||
}else
|
||||
{
|
||||
meta = mit->second;
|
||||
}
|
||||
|
||||
else
|
||||
meta = mit->second;
|
||||
|
||||
//gup.grpItem->meta = *meta;
|
||||
GxsGrpPendingSign ggps(gup.grpItem, gup.mToken);
|
||||
|
@ -2402,14 +2391,13 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||
ggps.mToken = gup.mToken;
|
||||
mGrpsToPublish.push_back(ggps);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl;
|
||||
|
||||
delete gup.grpItem;
|
||||
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
|
||||
}
|
||||
delete meta;
|
||||
}
|
||||
|
||||
mGroupUpdatePublish.clear();
|
||||
|
@ -2814,23 +2802,20 @@ bool RsGenExchange::getGroupKeys(const RsGxsGroupId &grpId, RsTlvSecurityKeySet
|
|||
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||
RsGxsGrpMetaTemporaryMap grpMeta;
|
||||
grpMeta[grpId] = NULL;
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
if(grpMeta.empty())
|
||||
return false;
|
||||
|
||||
RsGxsGrpMetaData* meta = grpMeta[grpId];
|
||||
const RsGxsGrpMetaData* meta = grpMeta[grpId];
|
||||
|
||||
if(meta == NULL)
|
||||
return false;
|
||||
|
||||
keySet = meta->keys;
|
||||
GxsSecurity::createPublicKeysFromPrivateKeys(keySet) ;
|
||||
|
||||
for(std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator it=grpMeta.begin();it!=grpMeta.end();++it)
|
||||
delete it->second ;
|
||||
GxsSecurity::createPublicKeysFromPrivateKeys(keySet) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2958,11 +2943,12 @@ void RsGenExchange::processRecvdMessages()
|
|||
continue ;
|
||||
}
|
||||
|
||||
RsGxsGrpMetaData *grpMeta = mit->second;
|
||||
const RsGxsGrpMetaData *grpMeta = mit->second;
|
||||
RsTlvSecurityKeySet keys = grpMeta->keys ;
|
||||
|
||||
GxsSecurity::createPublicKeysFromPrivateKeys(grpMeta->keys); // make sure we have the public keys that correspond to the private ones, as it happens. Most of the time this call does nothing.
|
||||
GxsSecurity::createPublicKeysFromPrivateKeys(keys); // make sure we have the public keys that correspond to the private ones, as it happens. Most of the time this call does nothing.
|
||||
|
||||
int validateReturn = validateMsg(msg, grpMeta->mGroupFlags, grpMeta->mSignFlags, grpMeta->keys);
|
||||
int validateReturn = validateMsg(msg, grpMeta->mGroupFlags, grpMeta->mSignFlags, keys);
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " grpMeta.mSignFlags: " << std::hex << grpMeta->mSignFlags << std::dec << std::endl;
|
||||
|
@ -3176,7 +3162,7 @@ void RsGenExchange::processRecvdGroups()
|
|||
|
||||
void RsGenExchange::performUpdateValidation()
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
if(mGroupUpdates.empty())
|
||||
return;
|
||||
|
@ -3185,7 +3171,7 @@ void RsGenExchange::performUpdateValidation()
|
|||
std::cerr << "RsGenExchange::performUpdateValidation() " << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetas;
|
||||
RsGxsGrpMetaTemporaryMap grpMetas;
|
||||
|
||||
std::vector<GroupUpdate>::iterator vit = mGroupUpdates.begin();
|
||||
for(; vit != mGroupUpdates.end(); ++vit)
|
||||
|
@ -3200,8 +3186,7 @@ void RsGenExchange::performUpdateValidation()
|
|||
for(; vit != mGroupUpdates.end(); ++vit)
|
||||
{
|
||||
GroupUpdate& gu = *vit;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit =
|
||||
grpMetas.find(gu.newGrp->grpId);
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(gu.newGrp->grpId);
|
||||
gu.oldGrpMeta = mit->second;
|
||||
gu.validUpdate = updateValid(*(gu.oldGrpMeta), *(gu.newGrp));
|
||||
}
|
||||
|
@ -3223,51 +3208,50 @@ void RsGenExchange::performUpdateValidation()
|
|||
if(gu.newGrp->metaData->mCircleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||
gu.newGrp->metaData->mOriginator = gu.newGrp->PeerId();
|
||||
|
||||
// Keep subscriptionflag to what it was. This avoids clearing off the flag when updates to group meta information
|
||||
// is received.
|
||||
|
||||
gu.newGrp->metaData->mSubscribeFlags = gu.oldGrpMeta->mSubscribeFlags ;
|
||||
|
||||
// Keep subscriptionflag to what it was. This avoids clearing off the flag when updates to group meta information
|
||||
// is received.
|
||||
|
||||
gu.newGrp->metaData->mSubscribeFlags = gu.oldGrpMeta->mSubscribeFlags ;
|
||||
|
||||
grps.push_back(gu.newGrp);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete gu.newGrp;
|
||||
gu.newGrp = NULL ;
|
||||
gu.newGrp = NULL ;
|
||||
}
|
||||
|
||||
delete gu.oldGrpMeta;
|
||||
gu.oldGrpMeta = NULL ;
|
||||
gu.oldGrpMeta = NULL ;
|
||||
}
|
||||
// notify the client
|
||||
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, true);
|
||||
|
||||
for(uint32_t i=0;i<mGroupUpdates.size();++i)
|
||||
if(mGroupUpdates[i].newGrp != NULL)
|
||||
{
|
||||
c->mGrpIdList.push_back(mGroupUpdates[i].newGrp->grpId) ;
|
||||
// notify the client
|
||||
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, true);
|
||||
|
||||
for(uint32_t i=0;i<mGroupUpdates.size();++i)
|
||||
if(mGroupUpdates[i].newGrp != NULL)
|
||||
{
|
||||
c->mGrpIdList.push_back(mGroupUpdates[i].newGrp->grpId) ;
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " " << mGroupUpdates[i].newGrp->grpId << std::endl;
|
||||
std::cerr << " " << mGroupUpdates[i].newGrp->grpId << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
mNotifications.push_back(c);
|
||||
|
||||
// Warning: updateGroup will destroy the objects in grps. Dont use it afterwards!
|
||||
|
||||
}
|
||||
|
||||
mNotifications.push_back(c);
|
||||
|
||||
// Warning: updateGroup will destroy the objects in grps. Dont use it afterwards!
|
||||
|
||||
mDataStore->updateGroup(grps);
|
||||
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||
#endif
|
||||
|
||||
// cleanup
|
||||
|
||||
|
||||
// cleanup
|
||||
|
||||
mGroupUpdates.clear();
|
||||
}
|
||||
|
||||
bool RsGenExchange::updateValid(RsGxsGrpMetaData& oldGrpMeta, RsNxsGrp& newGrp) const
|
||||
bool RsGenExchange::updateValid(const RsGxsGrpMetaData& oldGrpMeta, RsNxsGrp& newGrp) const
|
||||
{
|
||||
std::map<SignType, RsTlvKeySignature>& signSet = newGrp.metaData->signSet.keySignSet;
|
||||
std::map<SignType, RsTlvKeySignature>::iterator mit = signSet.find(INDEX_AUTHEN_ADMIN);
|
||||
|
@ -3283,10 +3267,11 @@ bool RsGenExchange::updateValid(RsGxsGrpMetaData& oldGrpMeta, RsNxsGrp& newGrp)
|
|||
}
|
||||
|
||||
RsTlvKeySignature adminSign = mit->second;
|
||||
RsTlvSecurityKeySet old_keys = oldGrpMeta.keys ;
|
||||
|
||||
GxsSecurity::createPublicKeysFromPrivateKeys(oldGrpMeta.keys); // make sure we have the public keys that correspond to the private ones, as it happens. Most of the time this call does nothing.
|
||||
GxsSecurity::createPublicKeysFromPrivateKeys(old_keys); // make sure we have the public keys that correspond to the private ones, as it happens. Most of the time this call does nothing.
|
||||
|
||||
std::map<RsGxsId, RsTlvPublicRSAKey>& keys = oldGrpMeta.keys.public_keys;
|
||||
std::map<RsGxsId, RsTlvPublicRSAKey>& keys = old_keys.public_keys;
|
||||
std::map<RsGxsId, RsTlvPublicRSAKey>::iterator keyMit = keys.find(RsGxsId(oldGrpMeta.mGroupId));
|
||||
|
||||
if(keyMit == keys.end())
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
* @param groupInfo
|
||||
* @return false if could not redeem token
|
||||
*/
|
||||
bool getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
|
||||
bool getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData>& groupInfo);
|
||||
|
||||
/*!
|
||||
* retrieves message meta data associated to a request token
|
||||
|
@ -765,7 +765,7 @@ private:
|
|||
* SIGN_FAIL_TRY_LATER for Id sign key not avail (but requested), try later
|
||||
*/
|
||||
int createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBinaryData& msgData,
|
||||
const RsGxsMsgMetaData& msgMeta, RsGxsGrpMetaData& grpMeta);
|
||||
const RsGxsMsgMetaData& msgMeta, const RsGxsGrpMetaData& grpMeta);
|
||||
|
||||
/*!
|
||||
* convenience function to create sign for groups
|
||||
|
@ -835,7 +835,7 @@ private:
|
|||
* @param newGrp the new group that updates the old group (must have meta data member initialised)
|
||||
* @return
|
||||
*/
|
||||
bool updateValid(RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
|
||||
bool updateValid(const RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
|
||||
|
||||
/*!
|
||||
* convenience function for checking private publish and admin keys are present
|
||||
|
|
|
@ -33,7 +33,7 @@ RsGxsGrpMetaData::RsGxsGrpMetaData()
|
|||
clear();
|
||||
}
|
||||
|
||||
uint32_t RsGxsGrpMetaData::serial_size(uint32_t api_version)
|
||||
uint32_t RsGxsGrpMetaData::serial_size(uint32_t api_version) const
|
||||
{
|
||||
uint32_t s = 8; // header size
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
RsGxsGrpMetaData();
|
||||
bool deserialise(void *data, uint32_t &pktsize);
|
||||
bool serialise(void* data, uint32_t &pktsize, uint32_t api_version);
|
||||
uint32_t serial_size(uint32_t api_version);
|
||||
uint32_t serial_size(uint32_t api_version) const;
|
||||
void clear();
|
||||
void operator =(const RsGroupMetaData& rMeta);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#include "rsgxsutil.h"
|
||||
#include "rsgxsdataaccess.h"
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
||||
|
@ -377,7 +378,7 @@ bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<RsGxsGrpMetaData*>& groupInfo)
|
||||
bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<const RsGxsGrpMetaData*>& groupInfo)
|
||||
{
|
||||
|
||||
RS_STACK_MUTEX(mDataMutex);
|
||||
|
@ -1000,18 +1001,17 @@ bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
|||
bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req)
|
||||
{
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||
RsGxsGrpMetaTemporaryMap grpMeta;
|
||||
std::list<RsGxsGroupId> grpIdsOut;
|
||||
|
||||
std::list<RsGxsGroupId> grpIdsOut;
|
||||
getGroupList(req->mGroupIds, req->Options, grpIdsOut);
|
||||
|
||||
getGroupList(req->mGroupIds, req->Options, grpIdsOut);
|
||||
if(grpIdsOut.empty())
|
||||
return true;
|
||||
|
||||
if(grpIdsOut.empty())
|
||||
return true;
|
||||
std::list<RsGxsGroupId>::const_iterator lit = grpIdsOut.begin();
|
||||
|
||||
std::list<RsGxsGroupId>::const_iterator lit = grpIdsOut.begin();
|
||||
|
||||
for(; lit != grpIdsOut.end(); ++lit)
|
||||
for(; lit != grpIdsOut.end(); ++lit)
|
||||
grpMeta[*lit] = NULL;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
@ -1033,29 +1033,18 @@ bool RsGxsDataAccess::getGroupList(GroupIdReq* req)
|
|||
|
||||
bool RsGxsDataAccess::getGroupList(const std::list<RsGxsGroupId>& grpIdsIn, const RsTokReqOptions& opts, std::list<RsGxsGroupId>& grpIdsOut)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||
RsGxsGrpMetaTemporaryMap grpMeta;
|
||||
|
||||
std::list<RsGxsGroupId>::const_iterator lit = grpIdsIn.begin();
|
||||
|
||||
for(; lit != grpIdsIn.end(); ++lit)
|
||||
grpMeta[*lit] = NULL;
|
||||
for(auto lit = grpIdsIn.begin(); lit != grpIdsIn.end(); ++lit)
|
||||
grpMeta[*lit] = NULL;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
|
||||
|
||||
for(; mit != grpMeta.end(); ++mit)
|
||||
{
|
||||
grpIdsOut.push_back(mit->first);
|
||||
}
|
||||
for(auto mit = grpMeta.begin() ; mit != grpMeta.end(); ++mit)
|
||||
grpIdsOut.push_back(mit->first);
|
||||
|
||||
filterGrpList(grpIdsOut, opts, grpMeta);
|
||||
|
||||
for(mit = grpMeta.begin(); mit != grpMeta.end(); ++mit)
|
||||
{
|
||||
delete mit->second; // so wasteful!!
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1622,12 +1611,10 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
|||
// potentially very expensive!
|
||||
bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||
RsGxsGrpMetaTemporaryMap grpMeta ;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
|
||||
|
||||
req->mServiceStatistic.mNumGrps = grpMeta.size();
|
||||
req->mServiceStatistic.mNumMsgs = 0;
|
||||
req->mServiceStatistic.mSizeOfGrps = 0;
|
||||
|
@ -1638,9 +1625,9 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
|||
req->mServiceStatistic.mNumChildMsgsNew = 0;
|
||||
req->mServiceStatistic.mNumChildMsgsUnread = 0;
|
||||
|
||||
for(; mit != grpMeta.end(); ++mit)
|
||||
for(auto mit = grpMeta.begin(); mit != grpMeta.end(); ++mit)
|
||||
{
|
||||
RsGxsGrpMetaData* m = mit->second;
|
||||
const RsGxsGrpMetaData* m = mit->second;
|
||||
req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size(RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(m->mSubscribeFlags))
|
||||
|
@ -1658,8 +1645,6 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
|||
req->mServiceStatistic.mNumChildMsgsNew += gr.mGroupStatistic.mNumChildMsgsNew;
|
||||
req->mServiceStatistic.mNumChildMsgsUnread += gr.mGroupStatistic.mNumChildMsgsUnread;
|
||||
}
|
||||
|
||||
delete m;
|
||||
}
|
||||
|
||||
req->mServiceStatistic.mSizeStore = req->mServiceStatistic.mSizeOfGrps + req->mServiceStatistic.mSizeOfMsgs;
|
||||
|
|
|
@ -209,7 +209,7 @@ public:
|
|||
* @param token request token to be redeemed
|
||||
* @param groupInfo
|
||||
*/
|
||||
bool getGroupSummary(const uint32_t &token, std::list<RsGxsGrpMetaData*> &groupInfo);
|
||||
bool getGroupSummary(const uint32_t &token, std::list<const RsGxsGrpMetaData*>& groupInfo);
|
||||
|
||||
/*!
|
||||
*
|
||||
|
|
|
@ -689,7 +689,7 @@ void RsGxsNetService::syncGrpStatistics()
|
|||
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
for(std::map<RsGxsGroupId,RsGxsGrpMetaData*>::const_iterator it(grpMeta.begin());it!=grpMeta.end();++it)
|
||||
for(auto it(grpMeta.begin());it!=grpMeta.end();++it)
|
||||
{
|
||||
const RsGxsGrpConfig& rec = locked_getGrpConfig(it->first) ;
|
||||
|
||||
|
@ -755,7 +755,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
|
|||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetas);
|
||||
|
||||
RsGxsGrpMetaData* grpMeta = grpMetas[grs->grpId];
|
||||
const RsGxsGrpMetaData* grpMeta = grpMetas[grs->grpId];
|
||||
|
||||
if(grpMeta == NULL)
|
||||
{
|
||||
|
@ -1951,7 +1951,7 @@ void RsGxsNetService::updateServerSyncTS()
|
|||
// finally, update timestamps.
|
||||
bool change = false;
|
||||
|
||||
for(std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator mit = gxsMap.begin();mit != gxsMap.end(); ++mit)
|
||||
for(auto mit = gxsMap.begin();mit != gxsMap.end(); ++mit)
|
||||
{
|
||||
// Check if the group is subscribed and restricted to a circle. If the circle has changed, update the
|
||||
// global TS to reflect that change to clients who may be able to see/subscribe to that particular group.
|
||||
|
@ -2722,7 +2722,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
grpMetaMap[grpId] = NULL;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
RsGxsGrpMetaData* grpMeta = grpMetaMap[grpId];
|
||||
const RsGxsGrpMetaData* grpMeta = grpMetaMap[grpId];
|
||||
|
||||
if(grpMeta == NULL) // this should not happen, but just in case...
|
||||
{
|
||||
|
@ -3825,9 +3825,9 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrpReqItem *item)
|
|||
GXSNETDEBUG_P_(peer) << " Group list beings being sent: " << std::endl;
|
||||
#endif
|
||||
|
||||
for(std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grp.begin(); mit != grp.end(); ++mit)
|
||||
for(auto mit = grp.begin(); mit != grp.end(); ++mit)
|
||||
{
|
||||
RsGxsGrpMetaData* grpMeta = mit->second;
|
||||
const RsGxsGrpMetaData* grpMeta = mit->second;
|
||||
|
||||
// Only send info about subscribed groups.
|
||||
|
||||
|
@ -3899,7 +3899,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrpReqItem *item)
|
|||
|
||||
|
||||
|
||||
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& /* toVet */, bool& should_encrypt)
|
||||
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, const RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& /* toVet */, bool& should_encrypt)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendGrpId()"<< std::endl;
|
||||
|
@ -4092,7 +4092,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
|
|||
grpMetas[item->grpId] = NULL;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetas);
|
||||
RsGxsGrpMetaData* grpMeta = grpMetas[item->grpId];
|
||||
const RsGxsGrpMetaData* grpMeta = grpMetas[item->grpId];
|
||||
|
||||
if(grpMeta == NULL)
|
||||
{
|
||||
|
@ -4633,7 +4633,7 @@ void RsGxsNetService::sharePublishKeysPending()
|
|||
|
||||
// Find the publish keys in the retrieved info
|
||||
|
||||
RsGxsGrpMetaData *grpMeta = grpMetaMap[mit->first] ;
|
||||
const RsGxsGrpMetaData *grpMeta = grpMetaMap[mit->first] ;
|
||||
|
||||
if(grpMeta == NULL)
|
||||
{
|
||||
|
@ -4718,7 +4718,7 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item)
|
|||
|
||||
// update the publish keys in this group meta info
|
||||
|
||||
RsGxsGrpMetaData *grpMeta = grpMetaMap[item->grpId] ;
|
||||
const RsGxsGrpMetaData *grpMeta = grpMetaMap[item->grpId] ;
|
||||
if (!grpMeta) {
|
||||
std::cerr << "(EE) RsGxsNetService::handleRecvPublishKeys() grpMeta not found." << std::endl;
|
||||
return ;
|
||||
|
@ -4760,9 +4760,10 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item)
|
|||
|
||||
// Store/update the info.
|
||||
|
||||
grpMeta->keys.private_keys[item->private_key.keyId] = item->private_key ;
|
||||
RsTlvSecurityKeySet keys = grpMeta->keys ;
|
||||
keys.private_keys[item->private_key.keyId] = item->private_key ;
|
||||
|
||||
bool ret = mDataStore->updateGroupKeys(item->grpId,grpMeta->keys, grpMeta->mSubscribeFlags | GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) ;
|
||||
bool ret = mDataStore->updateGroupKeys(item->grpId,keys, grpMeta->mSubscribeFlags | GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) ;
|
||||
|
||||
if(ret)
|
||||
{
|
||||
|
|
|
@ -370,7 +370,7 @@ private:
|
|||
* @param toVet groupid/peer to vet are stored here if their circle id is not cached
|
||||
* @return false, if you cannot send to this peer, true otherwise
|
||||
*/
|
||||
bool canSendGrpId(const RsPeerId& sslId, 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);
|
||||
|
||||
/*!
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
|
||||
GroupMetaReq::~GroupMetaReq()
|
||||
{
|
||||
rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end());
|
||||
//rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end()); // now memory ownership is kept by the cache.
|
||||
mGroupMetaData.clear();
|
||||
}
|
||||
|
||||
GroupDataReq::~GroupDataReq()
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGrpMetaData*> mGroupMetaData;
|
||||
std::list<const RsGxsGrpMetaData*> mGroupMetaData;
|
||||
};
|
||||
|
||||
class GroupIdReq : public GxsRequest
|
||||
|
|
|
@ -42,13 +42,10 @@ static const uint32_t MAX_GXS_IDS_REQUESTS_NET = 10 ; // max number of reques
|
|||
RsGxsMessageCleanUp::RsGxsMessageCleanUp(RsGeneralDataService* const dataService, RsGenExchange *genex, uint32_t chunkSize)
|
||||
: mDs(dataService), mGenExchangeClient(genex), CHUNK_SIZE(chunkSize)
|
||||
{
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||
RsGxsGrpMetaTemporaryMap grpMeta;
|
||||
mDs->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator cit = grpMeta.begin();
|
||||
|
||||
for(;cit != grpMeta.end(); ++cit)
|
||||
for(auto cit=grpMeta.begin();cit != grpMeta.end(); ++cit)
|
||||
mGrpMeta.push_back(cit->second);
|
||||
}
|
||||
|
||||
|
@ -64,7 +61,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
#endif
|
||||
while(!mGrpMeta.empty())
|
||||
{
|
||||
RsGxsGrpMetaData* grpMeta = mGrpMeta.back();
|
||||
const RsGxsGrpMetaData* grpMeta = mGrpMeta.back();
|
||||
const RsGxsGroupId& grpId = grpMeta->mGroupId;
|
||||
mGrpMeta.pop_back();
|
||||
GxsMsgReq req;
|
||||
|
@ -137,8 +134,6 @@ bool RsGxsMessageCleanUp::clean()
|
|||
|
||||
mDs->removeMsgs(req);
|
||||
|
||||
delete grpMeta;
|
||||
|
||||
i++;
|
||||
if(i > CHUNK_SIZE) break;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
class RsGixs ;
|
||||
class RsGenExchange ;
|
||||
class RsGeneralDataService ;
|
||||
|
||||
// temporary holds a map of pointers to class T, and destroys all pointers on delete.
|
||||
|
||||
|
@ -104,7 +105,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef t_RsGxsGenericDataTemporaryMap<RsGxsGroupId,RsGxsGrpMetaData> RsGxsGrpMetaTemporaryMap;
|
||||
typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap;
|
||||
typedef t_RsGxsGenericDataTemporaryMap<RsGxsGroupId,RsNxsGrp> RsNxsGrpDataTemporaryMap;
|
||||
|
||||
typedef t_RsGxsGenericDataTemporaryMapVector<RsGxsMsgMetaData> RsGxsMsgMetaTemporaryMap ;
|
||||
|
@ -178,7 +179,7 @@ private:
|
|||
RsGeneralDataService* const mDs;
|
||||
RsGenExchange *mGenExchangeClient;
|
||||
uint32_t CHUNK_SIZE;
|
||||
std::vector<RsGxsGrpMetaData*> mGrpMeta;
|
||||
std::vector<const RsGxsGrpMetaData*> mGrpMeta;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -226,7 +227,7 @@ class GroupUpdate
|
|||
public:
|
||||
GroupUpdate() : oldGrpMeta(NULL), newGrp(NULL), validUpdate(false)
|
||||
{}
|
||||
RsGxsGrpMetaData* oldGrpMeta;
|
||||
const RsGxsGrpMetaData* oldGrpMeta;
|
||||
RsNxsGrp* newGrp;
|
||||
bool validUpdate;
|
||||
};
|
||||
|
|
|
@ -1658,9 +1658,8 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
|||
group.mPgpKnown = false;
|
||||
group.mPgpId.clear();
|
||||
|
||||
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString \""
|
||||
<< group.mMeta.mServiceString << "\"" ;
|
||||
std::cerr << std::endl;
|
||||
if(!group.mMeta.mServiceString.empty())
|
||||
std::cerr << "p3IdService::getGroupData() " << group.mMeta.mGroupId << " (" << group.mMeta.mGroupName << ") : Failed to decode, or no ServiceString \"" << group.mMeta.mServiceString << "\"" << std::endl;
|
||||
}
|
||||
|
||||
group.mIsAContact = (mContacts.find(RsGxsId(group.mMeta.mGroupId)) != mContacts.end());
|
||||
|
@ -2252,7 +2251,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
|
|||
#ifdef DEBUG_RECOGN
|
||||
std::cerr << "RsGxsIdCache::updateServiceString() updating recogntags";
|
||||
std::cerr << std::endl;
|
||||
#endif // DEBUG_RECOGN
|
||||
#endif
|
||||
if (ssdata.recogntags.publishTs == mPublishTs)
|
||||
{
|
||||
std::list<RsRecognTag>::iterator it;
|
||||
|
@ -2264,7 +2263,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
|
|||
#ifdef DEBUG_RECOGN
|
||||
std::cerr << "RsGxsIdCache::updateServiceString() Valid Tag: " << it->tag_class << ":" << it->tag_type;
|
||||
std::cerr << std::endl;
|
||||
#endif // DEBUG_RECOGN
|
||||
#endif
|
||||
details.mRecognTags.push_back(*it);
|
||||
}
|
||||
else
|
||||
|
@ -2272,7 +2271,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
|
|||
#ifdef DEBUG_RECOGN
|
||||
std::cerr << "RsGxsIdCache::updateServiceString() Invalid Tag: " << it->tag_class << ":" << it->tag_type;
|
||||
std::cerr << std::endl;
|
||||
#endif // DEBUG_RECOGN
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2281,7 +2280,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
|
|||
#ifdef DEBUG_RECOGN
|
||||
std::cerr << "RsGxsIdCache::updateServiceString() recogntags old publishTs";
|
||||
std::cerr << std::endl;
|
||||
#endif // DEBUG_RECOGN
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2290,7 +2289,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
|
|||
#ifdef DEBUG_RECOGN
|
||||
std::cerr << "RsGxsIdCache::updateServiceString() recogntags unprocessed";
|
||||
std::cerr << std::endl;
|
||||
#endif // DEBUG_RECOGN
|
||||
#endif
|
||||
}
|
||||
|
||||
// copy over Reputation scores.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue