-fixed msg sync test, now passing

-enabled msg circle checking


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7305 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-04-26 23:48:33 +00:00
parent 75188fb6f0
commit 4fe6161d58
5 changed files with 50 additions and 30 deletions

View File

@ -457,7 +457,7 @@ bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta,
if(mCircles->isLoaded(grpMeta->mCircleId))
{
const RsPgpId& pgpId = rsPeers->getGPGId(peerId);
const RsPgpId& pgpId = mNetMgr->getGPGId(peerId);
return mCircles->canSend(grpMeta->mCircleId, pgpId);
}
@ -1912,6 +1912,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
return;
}
// hacky assumes a transaction only consist of a single grpId
RsGxsGroupId grpId;
for(;lit != tr->mItems.end(); lit++)
@ -2144,7 +2145,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
if(!toVet.empty())
{
mPendingCircleVets.push_back(new GrpCircleIdRequestVetting(mCircles, toVet, peer));
mPendingCircleVets.push_back(new GrpCircleIdRequestVetting(mCircles, mNetMgr, toVet, peer));
}
locked_pushGrpRespFromList(itemL, peer, transN);
@ -2171,7 +2172,7 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
{
if(mCircles->isLoaded(circleId))
{
const RsPgpId& pgpId = rsPeers->getGPGId(sslId);
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
return mCircles->canSend(circleId, pgpId);
}
@ -2188,7 +2189,7 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
if(mCircles->isLoaded(internalCircleId))
{
const RsPgpId& pgpId = rsPeers->getGPGId(sslId);
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
return mCircles->canSend(internalCircleId, pgpId);
}
@ -2261,7 +2262,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
uint32_t transN = locked_getTransactionId();
if(/*canSendMsgIds(msgMetas, *grpMeta, peer)*/ true)
if(canSendMsgIds(msgMetas, *grpMeta, peer))
{
std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin();
@ -2337,7 +2338,7 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
{
if(mCircles->isLoaded(circleId))
{
const RsPgpId& pgpId = rsPeers->getGPGId(sslId);
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
return mCircles->canSend(circleId, pgpId);
}
@ -2353,7 +2354,7 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
}
if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, toVet, grpMeta.mGroupId,
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mNetMgr, toVet, grpMeta.mGroupId,
sslId, grpMeta.mCircleId));
return false;
@ -2365,10 +2366,10 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mCircleId;
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
if(mCircles->isLoaded(internalCircleId))
{
const RsPgpId& pgpId = rsPeers->getGPGId(sslId);
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
return mCircles->canSend(internalCircleId, pgpId);
}
@ -2384,7 +2385,7 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
}
if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, toVet, grpMeta.mGroupId,
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mNetMgr, toVet, grpMeta.mGroupId,
sslId, grpMeta.mCircleId));
return false;

View File

@ -231,11 +231,19 @@ private:
void locked_genReqGrpTransaction(NxsTransaction* tr);
/*!
* Generates new transaction to send msg data based on list
* of grpids received from peer stored in passed transaction
* This first checks if one can send a grpId based circles
* If it can send, then it call locked_genSendMsgsTransaction
* @param tr transaction responsible for generating grp request
* @see locked_genSendMsgsTransaction
*/
void locked_genSendMsgsTransaction(NxsTransaction* tr);
void locked_checkSendMsgsTransaction(NxsTransaction* tr);
/*!
* Generates new transaction to send msg data based on list
* of grpids received from peer stored in passed transaction
* @param tr transaction responsible for generating grp request
*/
void locked_genSendMsgsTransaction(NxsTransaction* tr);
/*!
* Generates new transaction to send grp data based on list

View File

@ -213,8 +213,8 @@ const int GrpCircleVetting::MSG_ID_RECV_PEND = 3;
GrpIdCircleVet::GrpIdCircleVet(const RsGxsGroupId& grpId, const RsGxsCircleId& circleId)
: mGroupId(grpId), mCircleId(circleId), mCleared(false) {}
GrpCircleVetting::GrpCircleVetting(RsGcxs* const circles)
: mCircles(circles) {}
GrpCircleVetting::GrpCircleVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr)
: mCircles(circles), mNetMgr(netMgr) {}
GrpCircleVetting::~GrpCircleVetting() {}
@ -226,7 +226,7 @@ bool GrpCircleVetting::canSend(const SSLIdType& peerId, const RsGxsCircleId& cir
{
if(mCircles->isLoaded(circleId))
{
const RsPgpId& pgpId = rsPeers->getGPGId(peerId);
const RsPgpId& pgpId = mNetMgr->getGPGId(peerId);
return mCircles->canSend(circleId, pgpId);
}
@ -236,8 +236,8 @@ bool GrpCircleVetting::canSend(const SSLIdType& peerId, const RsGxsCircleId& cir
}
GrpCircleIdRequestVetting::GrpCircleIdRequestVetting(
RsGcxs* const circles, std::vector<GrpIdCircleVet> grpCircleV, const RsPeerId& peerId)
: GrpCircleVetting(circles), mGrpCircleV(grpCircleV), mPeerId(peerId) {}
RsGcxs* const circles, RsNxsNetMgr* const netMgr, std::vector<GrpIdCircleVet> grpCircleV, const RsPeerId& peerId)
: GrpCircleVetting(circles, netMgr), mGrpCircleV(grpCircleV), mPeerId(peerId) {}
bool GrpCircleIdRequestVetting::cleared()
{
@ -274,10 +274,10 @@ MsgIdCircleVet::MsgIdCircleVet(const RsGxsMessageId& msgId,
: mMsgId(msgId), mAuthorId(authorId) {
}
MsgCircleIdsRequestVetting::MsgCircleIdsRequestVetting(RsGcxs* const circles,
MsgCircleIdsRequestVetting::MsgCircleIdsRequestVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr,
std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
const RsPeerId& peerId, const RsGxsCircleId& circleId)
: GrpCircleVetting(circles), mMsgs(msgs), mGrpId(grpId), mPeerId(peerId), mCircleId(circleId) {}
: GrpCircleVetting(circles, netMgr), mMsgs(msgs), mGrpId(grpId), mPeerId(peerId), mCircleId(circleId) {}
bool MsgCircleIdsRequestVetting::cleared()
{
@ -291,3 +291,8 @@ int MsgCircleIdsRequestVetting::getType() const
return MSG_ID_SEND_PEND;
}
RsPgpId RsNxsNetMgrImpl::getGPGId(const RsPeerId& peerId) {
rsPeers->getGPGId(peerId);
}

View File

@ -83,6 +83,7 @@ public:
virtual ~RsNxsNetMgr(){};
virtual const RsPeerId& getOwnId() = 0;
virtual void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers) = 0;
virtual RsPgpId getGPGId(const RsPeerId& peerId) = 0;
};
@ -94,8 +95,9 @@ public:
RsNxsNetMgrImpl(p3ServiceControl* sc);
virtual ~RsNxsNetMgrImpl(){};
virtual const RsPeerId& getOwnId();
virtual void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers);
const RsPeerId& getOwnId();
void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers);
RsPgpId getGPGId(const RsPeerId& peerId);
private:
@ -243,7 +245,7 @@ public:
static const int MSG_ID_RECV_PEND;
GrpCircleVetting(RsGcxs* const circles);
GrpCircleVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr);
virtual ~GrpCircleVetting();
bool expired();
virtual int getType() const = 0;
@ -255,13 +257,14 @@ protected:
private:
RsGcxs* const mCircles;
RsNxsNetMgr* const mNetMgr;
time_t mTimeStamp;
};
class GrpCircleIdRequestVetting : public GrpCircleVetting
{
public:
GrpCircleIdRequestVetting(RsGcxs* const circles, std::vector<GrpIdCircleVet> mGrpCircleV, const RsPeerId& peerId);
GrpCircleIdRequestVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr, std::vector<GrpIdCircleVet> mGrpCircleV, const RsPeerId& peerId);
bool cleared();
int getType() const;
std::vector<GrpIdCircleVet> mGrpCircleV;
@ -271,7 +274,7 @@ public:
class MsgCircleIdsRequestVetting : public GrpCircleVetting
{
public:
MsgCircleIdsRequestVetting(RsGcxs* const circles, std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
MsgCircleIdsRequestVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr, std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
const RsPeerId& peerId, const RsGxsCircleId& circleId);
bool cleared();
int getType() const;

View File

@ -20,6 +20,7 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
{
int numPeers = 2;
// create 2 peers
for(int i =0; i < numPeers; i++)
{
RsPeerId id = RsPeerId::random();
@ -31,7 +32,7 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
for(; it != mPeerIds.end(); it++)
{
// data stores
RsGeneralDataService* ds = new RsDataService("./", "grp_store_" +
RsGeneralDataService* ds = new RsDataService("./", "data_store_" +
it->toStdString(), mServType, NULL, "key");
mDataServices.insert(std::make_pair(*it, ds));
@ -57,16 +58,17 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
std::auto_ptr<RsNxsGrp> grp = std::auto_ptr<RsNxsGrp>(new RsNxsGrp(mServType));
init_item(*grp);
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
init_item(meta);
meta->mReputationCutOff = 0;
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
init_item(meta);
meta->mReputationCutOff = 0;
meta->mGroupId = grp->grpId;
grp->metaData = meta;
meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
meta->mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
RsGxsGroupId grpId = grp->grpId;
// the expected result is that each peer has the group of the others
// the expected result is that each peer has all messages
it = mPeerIds.begin();
DataMap::iterator mit = mDataServices.begin();
@ -95,6 +97,7 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
RsGxsMsgMetaData* msgMeta = new RsGxsMsgMetaData();
init_item(msgMeta);
msgMeta->mGroupId = grp->grpId;
msgMeta->mMsgId = msg->msgId;
RsGeneralDataService::MsgStoreMap msm;
msm.insert(std::make_pair(msg , msgMeta));
RsGxsMessageId msgId = msg->msgId;