added correct timestamp in msg list response items for GXS. To be tested.

This commit is contained in:
csoler 2016-01-05 19:23:59 -05:00
parent 141f0927e3
commit 7b3fd53bb9
2 changed files with 27 additions and 17 deletions

View File

@ -207,8 +207,8 @@
NXS_NET_DEBUG_4 vetting NXS_NET_DEBUG_4 vetting
NXS_NET_DEBUG_5 summary of transactions (useful to just know what comes in/out) NXS_NET_DEBUG_5 summary of transactions (useful to just know what comes in/out)
***/ ***/
//#define NXS_NET_DEBUG_0 1 #define NXS_NET_DEBUG_0 1
//#define NXS_NET_DEBUG_1 1 #define NXS_NET_DEBUG_1 1
//#define NXS_NET_DEBUG_2 1 //#define NXS_NET_DEBUG_2 1
//#define NXS_NET_DEBUG_3 1 //#define NXS_NET_DEBUG_3 1
//#define NXS_NET_DEBUG_4 1 //#define NXS_NET_DEBUG_4 1
@ -1127,8 +1127,7 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVett
#ifdef NXS_NET_DEBUG_1 #ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(grpPend->mPeerId,entry.mGroupId) << " Group Id: " << entry.mGroupId << " PASSED" << std::endl; GXSNETDEBUG_PG(grpPend->mPeerId,entry.mGroupId) << " Group Id: " << entry.mGroupId << " PASSED" << std::endl;
#endif #endif
RsNxsSyncGrpItem* gItem = new RsNxsSyncGrpItem* gItem = new RsNxsSyncGrpItem(mServType);
RsNxsSyncGrpItem(mServType);
gItem->flag = RsNxsSyncGrpItem::FLAG_RESPONSE; gItem->flag = RsNxsSyncGrpItem::FLAG_RESPONSE;
gItem->grpId = entry.mGroupId; gItem->grpId = entry.mGroupId;
gItem->publishTs = 0; gItem->publishTs = 0;
@ -1154,6 +1153,7 @@ void RsGxsNetService::locked_createTransactionFromPending(MsgCircleIdsRequestVet
std::list<RsNxsItem*> itemL; std::list<RsNxsItem*> itemL;
uint32_t transN = locked_getTransactionId(); uint32_t transN = locked_getTransactionId();
RsGxsGroupId grp_id ;
for(; vit != msgPend->mMsgs.end(); ++vit) for(; vit != msgPend->mMsgs.end(); ++vit)
{ {
@ -1167,10 +1167,12 @@ void RsGxsNetService::locked_createTransactionFromPending(MsgCircleIdsRequestVet
mItem->PeerId(msgPend->mPeerId); mItem->PeerId(msgPend->mPeerId);
mItem->transactionNumber = transN; mItem->transactionNumber = transN;
itemL.push_back(mItem); itemL.push_back(mItem);
grp_id = msgPend->mGrpId ;
} }
if(!itemL.empty()) if(!itemL.empty())
locked_pushMsgRespFromList(itemL, msgPend->mPeerId, transN); locked_pushMsgRespFromList(itemL, msgPend->mPeerId,grp_id, transN);
} }
/*bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta /*bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta
@ -3692,8 +3694,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
{ {
RsGxsMsgMetaData* m = *vit; RsGxsMsgMetaData* m = *vit;
RsNxsSyncMsgItem* mItem = new RsNxsSyncMsgItem* mItem = new RsNxsSyncMsgItem(mServType);
RsNxsSyncMsgItem(mServType);
mItem->flag = RsNxsSyncGrpItem::FLAG_RESPONSE; mItem->flag = RsNxsSyncGrpItem::FLAG_RESPONSE;
mItem->grpId = m->mGroupId; mItem->grpId = m->mGroupId;
mItem->msgId = m->mMsgId; mItem->msgId = m->mMsgId;
@ -3711,7 +3712,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " sending final msg info list of " << itemL.size() << " items." << std::endl; GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " sending final msg info list of " << itemL.size() << " items." << std::endl;
#endif #endif
locked_pushMsgRespFromList(itemL, peer, transN); locked_pushMsgRespFromList(itemL, peer, item->grpId,transN);
} }
} }
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
@ -3725,24 +3726,33 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
delete *vit; delete *vit;
} }
void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const uint32_t& transN) void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const RsGxsGroupId& grp_id,const uint32_t& transN)
{ {
#ifdef NXS_NET_DEBUG_1 #ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_P_(sslId) << "locked_pushMsgResponseFromList()" << std::endl; GXSNETDEBUG_PG(sslId,grp_id) << "locked_pushMsgResponseFromList()" << std::endl;
GXSNETDEBUG_P_(sslId) << " nelems = " << itemL.size() << std::endl; GXSNETDEBUG_PG(sslId,grp_id) << " nelems = " << itemL.size() << std::endl;
GXSNETDEBUG_P_(sslId) << " peerId = " << sslId << std::endl; GXSNETDEBUG_PG(sslId,grp_id) << " peerId = " << sslId << std::endl;
GXSNETDEBUG_P_(sslId) << " transN = " << transN << std::endl; GXSNETDEBUG_PG(sslId,grp_id) << " transN = " << transN << std::endl;
#endif #endif
NxsTransaction* tr = new NxsTransaction(); NxsTransaction* tr = new NxsTransaction();
tr->mItems = itemL; tr->mItems = itemL;
tr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM; tr->mFlag = NxsTransaction::FLAG_STATE_WAITING_CONFIRM;
RsNxsTransac* trItem = new RsNxsTransac(mServType); RsNxsTransac* trItem = new RsNxsTransac(mServType);
trItem->transactFlag = RsNxsTransac::FLAG_BEGIN_P1 | RsNxsTransac::FLAG_TYPE_MSG_LIST_RESP; trItem->transactFlag = RsNxsTransac::FLAG_BEGIN_P1 | RsNxsTransac::FLAG_TYPE_MSG_LIST_RESP;
trItem->nItems = itemL.size(); trItem->nItems = itemL.size();
trItem->timestamp = 0;
trItem->PeerId(sslId); trItem->PeerId(sslId);
trItem->transactionNumber = transN; trItem->transactionNumber = transN;
ServerMsgMap::const_iterator cit = mServerMsgUpdateMap.find(grp_id);
if(cit != mServerMsgUpdateMap.end())
trItem->timestamp = cit->second->msgUpdateTS;
else
{
std::cerr << "(EE) cannot find a server TS for message of group " << grp_id << " in locked_pushMsgRespFromList. This is weird." << std::endl;
trItem->timestamp = 0 ;
}
// also make a copy for the resident transaction // also make a copy for the resident transaction
tr->mTransaction = new RsNxsTransac(*trItem); tr->mTransaction = new RsNxsTransac(*trItem);
tr->mTransaction->PeerId(mOwnId); tr->mTransaction->PeerId(mOwnId);

View File

@ -364,7 +364,7 @@ private:
void locked_pushMsgTransactionFromList(std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN); void locked_pushMsgTransactionFromList(std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN);
void locked_pushGrpTransactionFromList(std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN); void locked_pushGrpTransactionFromList(std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN);
void locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList, const RsPeerId& peer, const uint32_t& transN); void locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList, const RsPeerId& peer, const uint32_t& transN);
void locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const uint32_t& transN); void locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const RsGxsGroupId &grp_id, const uint32_t& transN);
void syncWithPeers(); void syncWithPeers();
void syncGrpStatistics(); void syncGrpStatistics();
void addGroupItemToList(NxsTransaction*& tr, void addGroupItemToList(NxsTransaction*& tr,