fix for trigger statement, and readjusted algo to use self gen-exchange generated time stamps

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6907 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-11-24 12:37:17 +00:00
parent 24839ee237
commit 1cdf329bb1
2 changed files with 31 additions and 7 deletions

View File

@ -250,10 +250,10 @@ void RsDataService::initialise(){
KEY_SIGN_SET + " BLOB);");
mDb->execSQL("CREATE TRIGGER " + GRP_LAST_POST_UPDATE_TRIGGER +
"UPDATE OF " + KEY_RECV_TS + " ON " + MSG_TABLE_NAME +
std::string("BEGIN ") +
"UPDATE " + GRP_TABLE_NAME + "SET " + KEY_GRP_LAST_POST + "= new."
+ KEY_RECV_TS + ";"
" UPDATE OF " + KEY_RECV_TS + " ON " + MSG_TABLE_NAME +
std::string(" BEGIN ") +
" UPDATE " + GRP_TABLE_NAME + " SET " + KEY_GRP_LAST_POST + "= new."
+ KEY_RECV_TS + " WHERE " + KEY_GRP_ID + "=old." + KEY_GRP_ID + ";"
+ std::string("END;"));
}

View File

@ -868,6 +868,7 @@ void RsGxsNetService::run(){
double timeDelta = 0.2;
int updateCounter = 0;
while(isRunning()){
@ -877,7 +878,13 @@ void RsGxsNetService::run(){
Sleep((int) (timeDelta * 1000));
#endif
updateServerSyncTS();
if(updateCounter == 3)
{
updateServerSyncTS();
updateCounter = 0;
}
else
updateCounter++;
// process active transactions
processTransactions();
@ -1729,12 +1736,15 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr)
return;
}
uint32_t updateTS = 0;
if(mGrpServerUpdateItem)
updateTS = mGrpServerUpdateItem->grpUpdateTS;
RsNxsTransac* ntr = new RsNxsTransac(mServType);
ntr->transactionNumber = transN;
ntr->transactFlag = RsNxsTransac::FLAG_BEGIN_P1 |
RsNxsTransac::FLAG_TYPE_GRPS;
ntr->updateTS = time(NULL);
ntr->updateTS = updateTS;
ntr->nItems = grps.size();
ntr->PeerId(tr->mTransaction->PeerId());
@ -1850,12 +1860,17 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
return;
}
std::string grpId = "";
for(;lit != tr->mItems.end(); lit++)
{
RsNxsSyncMsgItem* item = dynamic_cast<RsNxsSyncMsgItem*>(*lit);
if (item)
{
msgIds[item->grpId].push_back(item->msgId);
if(grpId.empty())
grpId = item->grpId;
}
else
{
@ -1912,11 +1927,18 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
return;
}
uint32_t updateTS = 0;
ServerMsgMap::const_iterator cit = mServerMsgUpdateMap.find(grpId);
if(cit != mServerMsgUpdateMap.end())
updateTS = cit->second->msgUpdateTS;
RsNxsTransac* ntr = new RsNxsTransac(mServType);
ntr->transactionNumber = transN;
ntr->transactFlag = RsNxsTransac::FLAG_BEGIN_P1 |
RsNxsTransac::FLAG_TYPE_MSGS;
ntr->updateTS = time(NULL);
ntr->updateTS = updateTS;
ntr->nItems = msgSize;
ntr->PeerId(peerId);
@ -2003,7 +2025,9 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
if(mGrpServerUpdateItem)
{
if(item->updateTS >= mGrpServerUpdateItem->grpUpdateTS && item->updateTS != 0)
{
return;
}
}
std::map<std::string, RsGxsGrpMetaData*> grp;