added author pull code

-- problem, still need to figure out how to get peer auth req should go to

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6881 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-10-29 21:29:20 +00:00
parent a6f62caef4
commit f2884d580f
5 changed files with 87 additions and 20 deletions

View File

@ -766,6 +766,8 @@ void RsGxsNetService::run(){
// vetting of id and circle info
runVetting();
processExplicitGroupRequests();
}
}
@ -2063,3 +2065,40 @@ void RsGxsNetService::setSyncAge(uint32_t age)
}
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const std::string& peerId)
{
RsStackMutex stack(mNxsMutex);
mExplicitRequest[peerId].assign(grpId.begin(), grpId.end());
return 1;
}
void RsGxsNetService::processExplicitGroupRequests()
{
RsStackMutex stack(mNxsMutex);
std::map<std::string, std::list<RsGxsGroupId> >::const_iterator cit = mExplicitRequest.begin();
for(; cit != mExplicitRequest.end(); cit++)
{
const std::string& peerId = cit->first;
const std::list<RsGxsGroupId>& groupIdList = cit->second;
std::list<RsNxsItem*> grpSyncItems;
std::list<RsGxsGroupId>::const_iterator git = groupIdList.begin();
uint32_t transN = locked_getTransactionId();
for(; git != groupIdList.end(); git++)
{
RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(mServType);
item->grpId = *git;
item->PeerId(peerId);
item->flag = RsNxsSyncGrpItem::FLAG_REQUEST;
item->transactionNumber = transN;
grpSyncItems.push_back(item);
}
if(!grpSyncItems.empty())
locked_pushGrpTransactionFromList(grpSyncItems, peerId, transN);
}
mExplicitRequest.clear();
}

View File

@ -115,7 +115,7 @@ public:
* @param msgId the messages to retrieve
* @return request token to be redeemed
*/
int requestMsg(const std::string& msgId, uint8_t hops){ return 0;}
int requestMsg(const RsGxsGrpMsgIdPair& msgId){ return 0;}
/*!
* Request for this group is sent through to peers on your network
@ -123,7 +123,7 @@ public:
* @param enabled set to false to disable pause, and true otherwise
* @return request token to be redeemed
*/
int requestGrp(const std::list<std::string>& grpId, uint8_t hops){ return 0;}
int requestGrp(const std::list<RsGxsGroupId>& grpId, const std::string& peerId);
/* p3Config methods */
@ -322,6 +322,8 @@ private:
bool locked_canReceive(const RsGxsGrpMetaData * const grpMeta, const std::string& peerId);
void processExplicitGroupRequests();
private:
typedef std::vector<RsNxsGrp*> GrpFragments;
@ -422,6 +424,8 @@ private:
// need to be verfied
std::vector<AuthorPending*> mPendingResp;
std::vector<GrpCircleVetting*> mPendingCircleVets;
std::map<std::string, std::list<RsGxsGroupId> > mExplicitRequest;
};
#endif // RSGXSNETSERVICE_H

View File

@ -68,21 +68,6 @@ public:
*/
virtual void setSyncAge(uint32_t age) = 0;
/*!
* Explicitly requests all the groups contained by a peer
* Circumvents polling of peers for message
* @param peerId id of peer
*/
virtual void requestGroupsOfPeer(const std::string& peerId) = 0;
/*!
* get messages of a peer for a given group id, this circumvents the normal
* polling of peers for messages of given group id
* @param peerId Id of peer
* @param grpId id of group to request messages for
*/
virtual void requestMessagesOfPeer(const std::string& peerId, const std::string& grpId) = 0;
/*!
* Initiates a search through the network
* This returns messages which contains the search terms set in RsGxsSearch
@ -116,7 +101,7 @@ public:
* @param msgId the messages to retrieve
* @return request token to be redeemed
*/
virtual int requestMsg(const std::string& msgId, uint8_t hops) = 0;
virtual int requestMsg(const RsGxsGrpMsgIdPair& msgId) = 0;
/*!
* Request for this group is sent through to peers on your network
@ -124,7 +109,7 @@ public:
* @param enabled set to false to disable pause, and true otherwise
* @return request token to be redeemed
*/
virtual int requestGrp(const std::list<std::string>& grpId, uint8_t hops) = 0;
virtual int requestGrp(const std::list<RsGxsGroupId>& grpId, const std::string& peerId) = 0;
};

View File

@ -140,7 +140,7 @@ p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *ne
: RsGxsIdExchange(gds, nes, new RsGxsIdSerialiser(), RS_SERVICE_GXSV2_TYPE_GXSID, idAuthenPolicy()),
RsIdentity(this), GxsTokenQueue(this), RsTickEvent(), mIdMtx("p3IdService"),
mPublicKeyCache(DEFAULT_MEM_CACHE_SIZE, "GxsIdPublicKeyCache"),
mPrivateKeyCache(DEFAULT_MEM_CACHE_SIZE, "GxsIdPrivateKeyCache")
mPrivateKeyCache(DEFAULT_MEM_CACHE_SIZE, "GxsIdPrivateKeyCache"), mNes(nes)
{
mBgSchedule_Mode = 0;
mBgSchedule_Active = false;
@ -1366,6 +1366,9 @@ bool p3IdService::cache_start_load()
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts, groupIds);
GxsTokenQueue::queueRequest(token, GXSIDREQ_CACHELOAD);
std::set<RsGxsGroupId> groupIdSet;
groupIdSet.insert(groupIds.begin(), groupIds.end());
mGroupsToCache.insert(std::make_pair(token, groupIdSet));
}
return 1;
}
@ -1401,10 +1404,29 @@ bool p3IdService::cache_load_for_token(uint32_t token)
std::cerr << std::endl;
#endif // DEBUG_IDS
{
// remove identities that are present
RsStackMutex stack(mIdMtx);
mGroupsToCache[token].erase(item->meta.mGroupId);
}
/* cache the data */
cache_store(item);
delete item;
}
{
// now store identities that aren't present
RsStackMutex stack(mIdMtx);
const std::set<RsGxsGroupId>& groupIdSet = mGroupsToCache[token];
if(!groupIdSet.empty())
mGroupNotPresent[token].assign(groupIdSet.begin(), groupIdSet.end());
mGroupsToCache.erase(token);
}
}
else
{
@ -3601,7 +3623,13 @@ std::ostream &operator<<(std::ostream &out, const RsGxsIdOpinion &opinion)
void p3IdService::checkPeerForIdentities()
{
RsStackMutex stack(mIdMtx);
// crud, i needed peers instead!
mGroupNotPresent.clear();
}
// Overloaded from GxsTokenQueue for Request callbacks.

View File

@ -358,6 +358,12 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
void loadRecognKeys();
/************************************************************************
* for getting identities that are not present
*
*/
void checkPeerForIdentities();
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
bool checkRecognSignature_locked(std::string encoded, RSA &key, std::string signature);
@ -413,6 +419,11 @@ std::string genRandomId(int len = 20);
std::vector<RsGxsGroupChange*> mGroupChange;
std::vector<RsGxsMsgChange*> mMsgChange;
private:
std::map<uint32_t, std::set<RsGxsGroupId> > mGroupsToCache;
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
RsNetworkExchangeService* mNes;
};
#endif // P3_IDENTITY_SERVICE_HEADER