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

@ -253,7 +253,7 @@ void RsDataService::initialise(){
" UPDATE OF " + KEY_RECV_TS + " ON " + MSG_TABLE_NAME + " UPDATE OF " + KEY_RECV_TS + " ON " + MSG_TABLE_NAME +
std::string(" BEGIN ") + std::string(" BEGIN ") +
" UPDATE " + GRP_TABLE_NAME + " SET " + KEY_GRP_LAST_POST + "= new." " UPDATE " + GRP_TABLE_NAME + " SET " + KEY_GRP_LAST_POST + "= new."
+ KEY_RECV_TS + ";" + KEY_RECV_TS + " WHERE " + KEY_GRP_ID + "=old." + KEY_GRP_ID + ";"
+ std::string("END;")); + std::string("END;"));
} }

View File

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