added params to disable the use of cache when retrieving msg and grp data and metadata. Made GxsUtil::check() not use the cache

This commit is contained in:
csoler 2020-12-26 23:35:39 +01:00
parent 22ceec6c43
commit 5ff58e6a5f
7 changed files with 25 additions and 32 deletions

View File

@ -1059,7 +1059,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, bool cache)
{
#ifdef RS_DATA_SERVICE_DEBUG_TIME
rstime::RsScopeTimer timer("");
@ -1067,8 +1067,8 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
int requestedGroups = grp.size();
#endif
if(grp.empty()){
if(grp.empty())
{
RsStackMutex stack(mDbMutex);
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, withMeta ? mGrpColumnsWithMeta : mGrpColumns, "", "");
@ -1076,7 +1076,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
{
std::vector<RsNxsGrp*> grps;
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0,cache);
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
#ifdef RS_DATA_SERVICE_DEBUG_TIME
@ -1091,8 +1091,9 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
delete c;
}
}else{
}
else
{
RsStackMutex stack(mDbMutex);
std::map<RsGxsGroupId, RsNxsGrp *>::iterator mit = grp.begin();
@ -1106,7 +1107,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
if(c)
{
std::vector<RsNxsGrp*> grps;
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0);
locked_retrieveGroups(c, grps, withMeta ? mColGrp_WithMetaOffset : 0,cache);
if(!grps.empty())
{
@ -1138,7 +1139,7 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
return 1;
}
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset)
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset,bool use_cache)
{
if(c){
bool valid = c->moveToFirst();
@ -1150,7 +1151,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
if(g)
{
if (metaOffset)
g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset,true));
g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset,use_cache));
else
g->metaData = nullptr;
@ -1161,9 +1162,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
}
}
int RsDataService::retrieveNxsMsgs(
const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */,
bool withMeta )
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool withMeta, bool cache)
{
#ifdef RS_DATA_SERVICE_DEBUG_TIME
rstime::RsScopeTimer timer("");
@ -1186,9 +1185,7 @@ int RsDataService::retrieveNxsMsgs(
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);
}
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0,cache);
delete c;
}
@ -1207,7 +1204,7 @@ int RsDataService::retrieveNxsMsgs(
if(c)
{
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0,cache);
}
delete c;
@ -1230,7 +1227,7 @@ int RsDataService::retrieveNxsMsgs(
return 1;
}
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset)
void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs, int metaOffset,bool use_cache)
{
bool valid = c->moveToFirst();
while(valid){
@ -1238,7 +1235,7 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
if(m){
if (metaOffset)
m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset,false));
m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset,use_cache));
else
m->metaData = nullptr;

View File

@ -143,9 +143,7 @@ public:
* @param strictFilter if true do not request any message if reqIds is empty
* @return error code
*/
int retrieveNxsMsgs(
const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache,
bool withMeta = false );
int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false, bool cache=true );
/*!
* Retrieves groups, if empty, retrieves all grps, if map is not empty
@ -274,7 +272,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);
void locked_retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs, int metaOffset, bool use_cache);
/*!
* Retrieves all the grp results from a cursor
@ -282,7 +280,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);
void locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset, bool use_cache);
/*!
* Retrieves all the msg meta results from a cursor

View File

@ -142,9 +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 cache,
bool withMeta = false ) = 0;
virtual int retrieveNxsMsgs( const GxsMsgReq& reqIds, GxsMsgResult& msg, bool withMeta = false , bool cache=true) = 0;
/*!
* Retrieves all groups stored. Caller owns the memory and is supposed to delete the RsNxsGrp pointers after use.

View File

@ -2802,7 +2802,7 @@ void RsGenExchange::publishGrps()
RsNxsGrpDataTemporaryMap oldGrpDatas;
oldGrpDatas.insert(std::make_pair(grpId, (RsNxsGrp*)NULL));
if(mDataStore->retrieveNxsGrps(oldGrpDatas,true,false) && oldGrpDatas.size() == 1)
if(mDataStore->retrieveNxsGrps(oldGrpDatas,true,true) && oldGrpDatas.size() == 1)
{
auto oldGrp = oldGrpDatas[grpId];
c->mOldGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(oldGrp->grp.bin_data,&oldGrp->grp.bin_len));
@ -3330,7 +3330,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,false))
if(grpDatas.empty() || !mDataStore->retrieveNxsGrps(grpDatas,true,true))
{
if(grpDatas.empty())
RsErr() << __PRETTY_FUNCTION__ << " Validation of multiple group updates failed: no group in list!" << std::endl;

View File

@ -3551,7 +3551,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
#endif
#endif
mDataStore->retrieveNxsMsgs(msgIds, msgs, false, false);
mDataStore->retrieveNxsMsgs(msgIds, msgs, false);
NxsTransaction* newTr = new NxsTransaction();
newTr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM;

View File

@ -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, true);
mds->retrieveNxsGrps(grp, true, false);
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, false, true);
mds->retrieveNxsMsgs(grps, msgs, true,false);
// 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.

View File

@ -389,7 +389,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run()
std::list<RsGxsTransId> received_msgs ;
GxsMsgResult msgs;
mDs->retrieveNxsMsgs(grps, msgs, false, true);
mDs->retrieveNxsMsgs(grps, msgs, true, false);
for(GxsMsgResult::iterator mit = msgs.begin();mit != msgs.end(); ++mit)
{