mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
moved all metadata cache switches into DataStore as a single internal variable
This commit is contained in:
parent
637d5f360a
commit
71f2e273ea
@ -123,6 +123,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
bool isNewDatabase = !RsDirUtil::fileExists(mDbPath);
|
||||
|
||||
mDb = new RetroDb(mDbPath, RetroDb::OPEN_READWRITE_CREATE, key);
|
||||
mUseCache = true;
|
||||
|
||||
initialise(isNewDatabase);
|
||||
|
||||
@ -482,7 +483,7 @@ bool RsDataService::finishReleaseUpdate(int release, bool result)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<RsGxsGrpMetaData> RsDataService::locked_getGrpMeta(RetroCursor& c, int colOffset,bool use_cache)
|
||||
std::shared_ptr<RsGxsGrpMetaData> RsDataService::locked_getGrpMeta(RetroCursor& c, int colOffset)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::locked_getGrpMeta()" << std::endl;
|
||||
@ -505,7 +506,7 @@ std::shared_ptr<RsGxsGrpMetaData> RsDataService::locked_getGrpMeta(RetroCursor&
|
||||
if(grpId.isNull()) // not in the DB!
|
||||
return nullptr;
|
||||
|
||||
if(use_cache)
|
||||
if(mUseCache)
|
||||
grpMeta = mGrpMetaDataCache.getOrCreateMeta(grpId);
|
||||
else
|
||||
grpMeta = std::make_shared<RsGxsGrpMetaData>();
|
||||
@ -641,7 +642,7 @@ RsNxsGrp* RsDataService::locked_getGroup(RetroCursor &c)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::shared_ptr<RsGxsMsgMetaData> RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset,bool use_cache)
|
||||
std::shared_ptr<RsGxsMsgMetaData> RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset)
|
||||
{
|
||||
bool ok = true;
|
||||
uint32_t data_len = 0,
|
||||
@ -664,7 +665,7 @@ std::shared_ptr<RsGxsMsgMetaData> RsDataService::locked_getMsgMeta(RetroCursor &
|
||||
|
||||
std::shared_ptr<RsGxsMsgMetaData> msgMeta;
|
||||
|
||||
if(use_cache)
|
||||
if(mUseCache)
|
||||
msgMeta = mMsgMetaDataCache[group_id].getOrCreateMeta(msg_id);
|
||||
else
|
||||
msgMeta = std::make_shared<RsGxsMsgMetaData>();
|
||||
@ -1059,7 +1060,7 @@ bool RsDataService::validSize(RsNxsGrp* grp) const
|
||||
return false;
|
||||
}
|
||||
|
||||
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool cache)
|
||||
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
rstime::RsScopeTimer timer("");
|
||||
@ -1076,7 +1077,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
{
|
||||
std::vector<RsNxsGrp*> grps;
|
||||
|
||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0,cache);
|
||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
|
||||
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
@ -1107,7 +1108,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
if(c)
|
||||
{
|
||||
std::vector<RsNxsGrp*> grps;
|
||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0,cache);
|
||||
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
|
||||
|
||||
if(!grps.empty())
|
||||
{
|
||||
@ -1139,7 +1140,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset,bool use_cache)
|
||||
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset)
|
||||
{
|
||||
if(c){
|
||||
bool valid = c->moveToFirst();
|
||||
@ -1151,7 +1152,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
||||
if(g)
|
||||
{
|
||||
if (metaOffset)
|
||||
g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset,use_cache));
|
||||
g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset));
|
||||
else
|
||||
g->metaData = nullptr;
|
||||
|
||||
@ -1162,7 +1163,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
||||
}
|
||||
}
|
||||
|
||||
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool withMeta, bool cache)
|
||||
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool withMeta)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
rstime::RsScopeTimer timer("");
|
||||
@ -1185,7 +1186,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, withMeta ? mMsgColumnsWithMeta : mMsgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||
|
||||
if(c)
|
||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0,cache);
|
||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
|
||||
|
||||
delete c;
|
||||
}
|
||||
@ -1204,7 +1205,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
|
||||
|
||||
if(c)
|
||||
{
|
||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0,cache);
|
||||
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
|
||||
}
|
||||
|
||||
delete c;
|
||||
@ -1227,7 +1228,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset,bool use_cache)
|
||||
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
while(valid){
|
||||
@ -1235,7 +1236,7 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
|
||||
|
||||
if(m){
|
||||
if (metaOffset)
|
||||
m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset,use_cache));
|
||||
m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset));
|
||||
else
|
||||
m->metaData = nullptr;
|
||||
|
||||
@ -1268,7 +1269,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
||||
|
||||
if(msgIdV.empty())
|
||||
{
|
||||
if(cache.isCacheUpToDate())
|
||||
if(mUseCache && cache.isCacheUpToDate())
|
||||
cache.getFullMetaList(msgMeta[grpId]);
|
||||
else
|
||||
{
|
||||
@ -1276,8 +1277,10 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
||||
|
||||
if (c)
|
||||
{
|
||||
locked_retrieveMsgMetaList(c, msgMeta[grpId]);
|
||||
cache.setCacheUpToDate(true);
|
||||
locked_retrieveMsgMetaList(c, msgMeta[grpId]);
|
||||
|
||||
if(mUseCache)
|
||||
cache.setCacheUpToDate(true);
|
||||
}
|
||||
delete c;
|
||||
}
|
||||
@ -1294,7 +1297,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
||||
{
|
||||
const RsGxsMessageId& msgId = *sit;
|
||||
|
||||
auto meta = cache.getMeta(msgId);
|
||||
auto meta = mUseCache?cache.getMeta(msgId): (std::shared_ptr<RsGxsMsgMetaData>());
|
||||
|
||||
if(meta)
|
||||
metaSet.push_back(meta);
|
||||
@ -1303,7 +1306,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
|
||||
|
||||
c->moveToFirst();
|
||||
auto meta = locked_getMsgMeta(*c, 0,true);
|
||||
auto meta = locked_getMsgMeta(*c, 0);
|
||||
|
||||
if(meta)
|
||||
metaSet.push_back(meta);
|
||||
@ -1337,7 +1340,7 @@ void RsDataService::locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGro
|
||||
|
||||
while(valid)
|
||||
{
|
||||
auto m = locked_getGrpMeta(*c, 0,true);
|
||||
auto m = locked_getGrpMeta(*c, 0);
|
||||
|
||||
if(m != nullptr)
|
||||
grpMeta[m->mGroupId] = m;
|
||||
@ -1357,7 +1360,7 @@ void RsDataService::locked_retrieveMsgMetaList(RetroCursor *c, std::vector<std::
|
||||
bool valid = c->moveToFirst();
|
||||
while(valid)
|
||||
{
|
||||
auto m = locked_getMsgMeta(*c, 0,true);
|
||||
auto m = locked_getMsgMeta(*c, 0);
|
||||
|
||||
if(m != nullptr)
|
||||
msgMeta.push_back(m);
|
||||
@ -1383,7 +1386,7 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId,std::shared_ptr<
|
||||
|
||||
if(grp.empty())
|
||||
{
|
||||
if(mGrpMetaDataCache.isCacheUpToDate()) // grab all the stash from the cache, so as to avoid decryption costs.
|
||||
if(mUseCache && mGrpMetaDataCache.isCacheUpToDate()) // grab all the stash from the cache, so as to avoid decryption costs.
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
|
||||
std::cerr << (void*)this << ": RsDataService::retrieveGxsGrpMetaData() retrieving all from cache!" << std::endl;
|
||||
@ -1402,9 +1405,10 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId,std::shared_ptr<
|
||||
|
||||
if(c)
|
||||
{
|
||||
locked_retrieveGrpMetaList(c,grp);
|
||||
locked_retrieveGrpMetaList(c,grp);
|
||||
|
||||
mGrpMetaDataCache.setCacheUpToDate(true);
|
||||
if(mUseCache)
|
||||
mGrpMetaDataCache.setCacheUpToDate(true);
|
||||
}
|
||||
delete c;
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
@ -1417,7 +1421,7 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId,std::shared_ptr<
|
||||
{
|
||||
for(auto mit(grp.begin()); mit != grp.end(); ++mit)
|
||||
{
|
||||
auto meta = mGrpMetaDataCache.getMeta(mit->first) ;
|
||||
auto meta = mUseCache?mGrpMetaDataCache.getMeta(mit->first): (std::shared_ptr<RsGxsGrpMetaData>()) ;
|
||||
|
||||
if(meta)
|
||||
mit->second = meta;
|
||||
@ -1431,7 +1435,8 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId,std::shared_ptr<
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", "");
|
||||
|
||||
c->moveToFirst();
|
||||
auto meta = locked_getGrpMeta(*c, 0,true);
|
||||
|
||||
auto meta = locked_getGrpMeta(*c, 0);
|
||||
|
||||
if(meta)
|
||||
mit->second = meta;
|
||||
|
@ -138,26 +138,23 @@ public:
|
||||
* Retrieves all msgs
|
||||
* @param reqIds requested msg ids (grpId,msgId), leave msg list empty to get all msgs for the grp
|
||||
* @param msg result of msg retrieval
|
||||
* @param cache IGNORED whether to store results of this retrieval in memory
|
||||
* for faster later retrieval
|
||||
* @param strictFilter if true do not request any message if reqIds is empty
|
||||
* @param withMeta true will also retrieve metadata
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false, bool cache=true );
|
||||
int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false);
|
||||
|
||||
/*!
|
||||
* Retrieves groups, if empty, retrieves all grps, if map is not empty
|
||||
* only retrieve entries, if entry cannot be found, it is removed from map
|
||||
* @param grp retrieved groups
|
||||
* @param withMeta this initialise the metaData member of the nxsgroups retrieved
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp*>& grp, bool withMeta, bool cache);
|
||||
int retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp*>& grp, bool withMeta);
|
||||
|
||||
/*!
|
||||
* Retrieves meta data of all groups stored (most current versions only)
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @param grp output group meta data
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveGxsGrpMetaData(std::map<RsGxsGroupId, std::shared_ptr<RsGxsGrpMetaData> > &grp);
|
||||
@ -166,7 +163,6 @@ public:
|
||||
* Retrieves meta data of all groups stored (most current versions only)
|
||||
* @param grpIds grpIds for which to retrieve meta data
|
||||
* @param msgMeta meta data result as map of grpIds to array of metadata for that grpId
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaResult& msgMeta);
|
||||
@ -272,7 +268,7 @@ private:
|
||||
* @param c cursor to result set
|
||||
* @param msgs messages retrieved from cursor are stored here
|
||||
*/
|
||||
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs, int metaOffset, bool use_cache);
|
||||
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs, int metaOffset);
|
||||
|
||||
/*!
|
||||
* Retrieves all the grp results from a cursor
|
||||
@ -280,7 +276,7 @@ private:
|
||||
* @param grps groups retrieved from cursor are stored here
|
||||
* @param withMeta this initialise the metaData member of the nxsgroups retrieved
|
||||
*/
|
||||
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset, bool use_cache);
|
||||
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset);
|
||||
|
||||
/*!
|
||||
* Retrieves all the msg meta results from a cursor
|
||||
@ -300,13 +296,13 @@ private:
|
||||
* extracts a msg meta item from a cursor at its
|
||||
* current position
|
||||
*/
|
||||
std::shared_ptr<RsGxsMsgMetaData> locked_getMsgMeta(RetroCursor& c, int colOffset, bool use_cache);
|
||||
std::shared_ptr<RsGxsMsgMetaData> locked_getMsgMeta(RetroCursor& c, int colOffset);
|
||||
|
||||
/*!
|
||||
* extracts a grp meta item from a cursor at its
|
||||
* current position
|
||||
*/
|
||||
std::shared_ptr<RsGxsGrpMetaData> locked_getGrpMeta(RetroCursor& c, int colOffset, bool use_cache);
|
||||
std::shared_ptr<RsGxsGrpMetaData> locked_getGrpMeta(RetroCursor& c, int colOffset);
|
||||
|
||||
/*!
|
||||
* extracts a msg item from a cursor at its
|
||||
@ -448,6 +444,8 @@ private:
|
||||
|
||||
t_MetaDataCache<RsGxsGroupId,RsGxsGrpMetaData> mGrpMetaDataCache;
|
||||
std::map<RsGxsGroupId,t_MetaDataCache<RsGxsMessageId,RsGxsMsgMetaData> > mMsgMetaDataCache;
|
||||
|
||||
bool mUseCache;
|
||||
};
|
||||
|
||||
#endif // RSDATASERVICE_H
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
* @param strictFilter if true do not request any message if reqIds is empty
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false , bool cache=true) = 0;
|
||||
virtual int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false ) = 0;
|
||||
|
||||
/*!
|
||||
* Retrieves all groups stored. Caller owns the memory and is supposed to delete the RsNxsGrp pointers after use.
|
||||
@ -151,7 +151,7 @@ public:
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp*>& grp, bool withMeta, bool cache) = 0;
|
||||
virtual int retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp*>& grp, bool withMeta) = 0;
|
||||
|
||||
/*!
|
||||
* Retrieves meta data of all groups stored (most current versions only)
|
||||
@ -168,7 +168,6 @@ public:
|
||||
* Retrieves meta data of all groups stored (most current versions only)
|
||||
* @param grpIds grpIds for which to retrieve meta data
|
||||
* @param msgMeta meta data result as map of grpIds to array of metadata for that grpId
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveGxsMsgMetaData(const GxsMsgReq& msgIds, GxsMsgMetaResult& msgMeta) = 0;
|
||||
|
@ -1414,7 +1414,7 @@ bool RsGenExchange::retrieveNxsIdentity(const RsGxsGroupId& group_id,RsNxsGrp *&
|
||||
grp[group_id]=nullptr;
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::const_iterator grp_it;
|
||||
|
||||
if(! mDataStore->retrieveNxsGrps(grp, true,true) || grp.end()==(grp_it=grp.find(group_id)) || !grp_it->second)
|
||||
if(! mDataStore->retrieveNxsGrps(grp, true) || grp.end()==(grp_it=grp.find(group_id)) || !grp_it->second)
|
||||
{
|
||||
std::cerr << "(EE) Cannot retrieve group data for group " << group_id << " in service " << mServType << std::endl;
|
||||
return false;
|
||||
@ -2802,7 +2802,7 @@ void RsGenExchange::publishGrps()
|
||||
RsNxsGrpDataTemporaryMap oldGrpDatas;
|
||||
oldGrpDatas.insert(std::make_pair(grpId, (RsNxsGrp*)NULL));
|
||||
|
||||
if(mDataStore->retrieveNxsGrps(oldGrpDatas,true,true) && oldGrpDatas.size() == 1)
|
||||
if(mDataStore->retrieveNxsGrps(oldGrpDatas,true) && oldGrpDatas.size() == 1)
|
||||
{
|
||||
auto oldGrp = oldGrpDatas[grpId];
|
||||
c->mOldGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(oldGrp->grp.bin_data,&oldGrp->grp.bin_len));
|
||||
@ -3329,7 +3329,7 @@ void RsGenExchange::performUpdateValidation()
|
||||
for(auto vit(mGroupUpdates.begin()); vit != mGroupUpdates.end(); ++vit)
|
||||
grpDatas.insert(std::make_pair(vit->newGrp->grpId, (RsNxsGrp*)NULL));
|
||||
|
||||
if(grpDatas.empty() || !mDataStore->retrieveNxsGrps(grpDatas,true,true))
|
||||
if(grpDatas.empty() || !mDataStore->retrieveNxsGrps(grpDatas,true))
|
||||
{
|
||||
if(grpDatas.empty())
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Validation of multiple group updates failed: no group in list!" << std::endl;
|
||||
|
@ -860,7 +860,7 @@ bool RsGxsDataAccess::getGroupSerializedData(GroupSerializedDataReq* req)
|
||||
for(std::list<RsGxsGroupId>::iterator lit = grpIdsOut.begin();lit != grpIdsOut.end();++lit)
|
||||
grpData[*lit] = nullptr;
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true);
|
||||
req->mGroupData.clear();
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
@ -888,7 +888,7 @@ bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
||||
grpData[*lit] = nullptr;
|
||||
}
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true);
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
for(; mit != grpData.end(); ++mit)
|
||||
@ -911,7 +911,7 @@ bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req)
|
||||
for(auto lit = grpIdsOut.begin();lit != grpIdsOut.end(); ++lit)
|
||||
grpMeta[*lit] = nullptr;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
for(auto mit = grpMeta.begin(); mit != grpMeta.end(); ++mit)
|
||||
req->mGroupMetaData.push_back(mit->second);
|
||||
@ -954,7 +954,7 @@ bool RsGxsDataAccess::getMsgData(MsgDataReq* req)
|
||||
if((opts.mMsgFlagMask || opts.mStatusMask) && msgIdOut.empty())
|
||||
return true;
|
||||
|
||||
mDataStore->retrieveNxsMsgs(msgIdOut, req->mMsgData, true, true);
|
||||
mDataStore->retrieveNxsMsgs(msgIdOut, req->mMsgData, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1439,7 +1439,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
||||
else if(req->Options.mReqType == GXS_REQUEST_TYPE_MSG_RELATED_DATA)
|
||||
{
|
||||
GxsMsgResult msgResult;
|
||||
mDataStore->retrieveNxsMsgs(filteredOutMsgIds, msgResult, true, true);
|
||||
mDataStore->retrieveNxsMsgs(filteredOutMsgIds, msgResult, true);
|
||||
req->mMsgDataResult[grpMsgIdPair] = msgResult[grpId];
|
||||
}
|
||||
}
|
||||
@ -1699,7 +1699,7 @@ bool RsGxsDataAccess::getGroupData(const RsGxsGroupId& grpId, RsNxsGrp *& grp_da
|
||||
|
||||
grps[grpId] = nullptr ;
|
||||
|
||||
if(mDataStore->retrieveNxsGrps(grps, false, true)) // the false here is very important: it removes the private key parts.
|
||||
if(mDataStore->retrieveNxsGrps(grps, false)) // the false here is very important: it removes the private key parts.
|
||||
{
|
||||
grp_data = grps.begin()->second;
|
||||
return true;
|
||||
|
@ -511,6 +511,8 @@ private:
|
||||
|
||||
std::set<std::pair<uint32_t,GxsRequest*> > mRequestQueue;
|
||||
std::map<uint32_t, GxsRequest*> mCompletedRequests;
|
||||
|
||||
bool mUseMetaCache;
|
||||
};
|
||||
|
||||
#endif // RSGXSDATAACCESS_H
|
||||
|
@ -926,7 +926,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
|
||||
RsGxsGrpMetaTemporaryMap grpMetas;
|
||||
grpMetas[grs->grpId] = NULL;
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetas);
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetas);
|
||||
|
||||
const auto& grpMeta = grpMetas[grs->grpId];
|
||||
|
||||
@ -957,7 +957,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
|
||||
#ifdef NXS_NET_DEBUG_6
|
||||
GXSNETDEBUG_PG(grs->PeerId(),grs->grpId) << " retrieving message information." << std::endl;
|
||||
#endif
|
||||
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
|
||||
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
|
||||
|
||||
const auto& vec(result[grs->grpId]) ;
|
||||
|
||||
@ -2115,7 +2115,7 @@ void RsGxsNetService::updateServerSyncTS()
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
// retrieve all grps and update TS
|
||||
mDataStore->retrieveGxsGrpMetaData(gxsMap);
|
||||
mDataStore->retrieveGxsGrpMetaData(gxsMap);
|
||||
|
||||
// (cyril) This code was previously removed because it sounded inconsistent: the list of grps normally does not need to be updated when
|
||||
// new posts arrive. The two (grp list and msg list) are handled independently. Still, when group meta data updates are received,
|
||||
@ -3311,7 +3311,7 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr)
|
||||
}
|
||||
|
||||
if(!grps.empty())
|
||||
mDataStore->retrieveNxsGrps(grps, false, false);
|
||||
mDataStore->retrieveNxsGrps(grps, false);
|
||||
else
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
@ -5525,7 +5525,7 @@ bool RsGxsNetService::search(const Sha1CheckSum& hashed_group_id,unsigned char *
|
||||
RsNxsGrpDataTemporaryMap grpDataMap;
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
mDataStore->retrieveNxsGrps(grpDataMap, true, true);
|
||||
mDataStore->retrieveNxsGrps(grpDataMap, true);
|
||||
mLastCacheReloadTS = time(NULL);
|
||||
}
|
||||
|
||||
|
@ -626,6 +626,8 @@ private:
|
||||
std::map<TurtleRequestId,RsGxsGroupId> mSearchRequests;
|
||||
std::map<RsGxsGroupId,GroupRequestRecord> mSearchedGroups ;
|
||||
rstime_t mLastCacheReloadTS ;
|
||||
|
||||
bool mUseMetaCache;
|
||||
};
|
||||
|
||||
#endif // RSGXSNETSERVICE_H
|
||||
|
@ -233,7 +233,7 @@ bool RsGxsIntegrityCheck::check(uint16_t service_type, RsGixs *mgixs, RsGeneralD
|
||||
|
||||
// first take out all the groups
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grp;
|
||||
mds->retrieveNxsGrps(grp, true, false);
|
||||
mds->retrieveNxsGrps(grp, true);
|
||||
GxsMsgReq msgIds;
|
||||
GxsMsgReq grps;
|
||||
|
||||
@ -334,7 +334,7 @@ bool RsGxsIntegrityCheck::check(uint16_t service_type, RsGixs *mgixs, RsGeneralD
|
||||
// now messages
|
||||
GxsMsgResult msgs;
|
||||
|
||||
mds->retrieveNxsMsgs(grps, msgs, true,false);
|
||||
mds->retrieveNxsMsgs(grps, msgs, true);
|
||||
|
||||
// Check msg ids and messages. Go through all message IDs referred to by the db call
|
||||
// and verify that the message belongs to the nxs msg data that was just retrieved.
|
||||
|
@ -361,7 +361,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
|
||||
// first take out all the groups
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grp;
|
||||
mDs->retrieveNxsGrps(grp, true, true);
|
||||
mDs->retrieveNxsGrps(grp, true);
|
||||
|
||||
#ifdef DEBUG_GXSTRANS
|
||||
std::cerr << "GxsTransIntegrityCleanupThread::run()" << std::endl;
|
||||
@ -389,7 +389,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
|
||||
std::list<RsGxsTransId> received_msgs ;
|
||||
|
||||
GxsMsgResult msgs;
|
||||
mDs->retrieveNxsMsgs(grps, msgs, true, false);
|
||||
mDs->retrieveNxsMsgs(grps, msgs, true);
|
||||
|
||||
for(GxsMsgResult::iterator mit = msgs.begin();mit != msgs.end(); ++mit)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user