some fixes

- id pull now works (Peer A, Peer B test)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6889 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-11-04 14:09:32 +00:00
parent 67c55991d7
commit cf8a63888b
7 changed files with 42 additions and 13 deletions

View File

@ -176,7 +176,7 @@ class RsGixsReputation
public:
// get Reputation.
virtual bool haveReputation(const RsGxsId &id) = 0;
virtual bool loadReputation(const RsGxsId &id) = 0;
virtual bool loadReputation(const RsGxsId &id, const std::list<std::string>& peers) = 0;
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep) = 0;
};

View File

@ -1263,6 +1263,9 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
MsgAuthorV toVet;
std::list<std::string> peers;
peers.push_back(tr->mTransaction->PeerId());
for(; llit != msgItemL.end(); llit++)
{
RsNxsSyncMsgItem*& syncItem = *llit;
@ -1289,7 +1292,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
else
{
// preload for speed
mReputations->loadReputation(syncItem->authorId);
mReputations->loadReputation(syncItem->authorId, peers);
MsgAuthEntry entry;
entry.mAuthorId = syncItem->authorId;
entry.mGrpId = syncItem->grpId;
@ -1380,6 +1383,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
uint32_t transN = locked_getTransactionId();
GrpAuthorV toVet;
std::list<std::string> peers;
peers.push_back(tr->mTransaction->PeerId());
for(; llit != grpItemL.end(); llit++)
{
@ -1413,7 +1418,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
else
{
// preload reputation for later
mReputations->loadReputation(grpSyncItem->authorId);
mReputations->loadReputation(grpSyncItem->authorId, peers);
GrpAuthEntry entry;
entry.mAuthorId = grpSyncItem->authorId;
entry.mGrpId = grpSyncItem->grpId;

View File

@ -47,14 +47,16 @@ bool AuthorPending::expired() const
}
bool AuthorPending::getAuthorRep(GixsReputation& rep,
const std::string& authorId)
const std::string& authorId, const std::string& peerId)
{
if(mRep->haveReputation(authorId))
{
return mRep->getReputation(authorId, rep);
}
mRep->loadReputation(authorId);
std::list<std::string> peers;
peers.push_back(peerId);
mRep->loadReputation(authorId, peers);
return false;
}
@ -94,7 +96,7 @@ bool MsgRespPending::accepted()
if(!entry.mPassedVetting)
{
GixsReputation rep;
if(getAuthorRep(rep, entry.mAuthorId))
if(getAuthorRep(rep, entry.mAuthorId, mPeerId))
{
if(rep.score > mCutOff)
{
@ -129,7 +131,7 @@ bool GrpRespPending::accepted()
{
GixsReputation rep;
if(getAuthorRep(rep, entry.mAuthorId))
if(getAuthorRep(rep, entry.mAuthorId, mPeerId))
{
if(rep.score > mCutOff)
{

View File

@ -141,7 +141,7 @@ protected:
* @param authorId reputation to get
* @return true if successfully retrieve repution
*/
bool getAuthorRep(GixsReputation& rep, const std::string& authorId);
bool getAuthorRep(GixsReputation& rep, const std::string& authorId, const std::string& peerId);
private:

View File

@ -2271,6 +2271,7 @@ int RsServer::StartupRetroShare()
mGxsIdService, mGxsIdService, mGxsCircles,
false); // don't synchronise group automatic (need explicit group request)
mGxsIdService->setNes(gxsid_ns);
/**** GxsCircle service ****/

View File

@ -164,6 +164,11 @@ p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *ne
loadRecognKeys();
}
void p3IdService::setNes(RsNetworkExchangeService *nes)
{
RsStackMutex stack(mIdMtx);
mNes = nes;
}
uint32_t p3IdService::idAuthenPolicy()
{
@ -419,7 +424,7 @@ bool p3IdService::requestKey(const RsGxsId &id, const std::list<PeerId> &peers)
}
return cache_request_load(id);
return cache_request_load(id, peers);
}
bool p3IdService::isPendingNetworkRequest(const RsGxsId& gxsId) const
@ -473,11 +478,18 @@ bool p3IdService::haveReputation(const RsGxsId &id)
return haveKey(id);
}
bool p3IdService::loadReputation(const RsGxsId &id)
bool p3IdService::loadReputation(const RsGxsId &id, const std::list<std::string>& peers)
{
if (haveKey(id))
return true;
return cache_request_load(id);
else
{
if(isPendingNetworkRequest(id))
return true;
}
return cache_request_load(id, peers);
}
bool p3IdService::getReputation(const RsGxsId &id, GixsReputation &rep)
@ -1367,7 +1379,7 @@ bool p3IdService::cache_start_load()
groupIds.push_back(it->first); // might need conversion?
}
// mPendingCache.insert(mCacheLoad_ToCache.begin(), mCacheLoad_ToCache.end());
mPendingCache.insert(mCacheLoad_ToCache.begin(), mCacheLoad_ToCache.end());
mCacheLoad_ToCache.clear();
}
@ -1482,7 +1494,10 @@ void p3IdService::requestIdsFromNet()
std::map<std::string, std::list<RsGxsId> >::const_iterator cit2;
for(cit2 = requests.begin(); cit2 != requests.end(); cit2++)
{
if(mNes)
mNes->requestGrp(cit2->second, cit2->first);
}
mIdsNotPresent.clear();
}

View File

@ -196,6 +196,12 @@ static uint32_t idAuthenPolicy();
virtual void service_tick(); // needed for background processing.
/*!
* Design hack, id service must be constructed first as it
* is need for construction of subsequent net services
*/
void setNes(RsNetworkExchangeService* nes);
/* General Interface is provided by RsIdentity / RsGxsIfaceImpl. */
/* Data Specific Interface */
@ -258,7 +264,7 @@ virtual int getPrivateKey(const RsGxsId &id, RsTlvSecurityKey &key);
// get Reputation.
virtual bool haveReputation(const RsGxsId &id);
virtual bool loadReputation(const RsGxsId &id);
virtual bool loadReputation(const RsGxsId &id, const std::list<std::string>& peers);
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep);