mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -04:00
added display of usage statistics for GXS identities
This commit is contained in:
parent
ef0850e65b
commit
d3051eff1a
9 changed files with 85 additions and 17 deletions
|
@ -656,6 +656,8 @@ public:
|
|||
virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) ;
|
||||
|
||||
uint16_t serviceType() const { return mServType ; }
|
||||
uint16_t serviceFullType() const { return ((uint32_t)mServType << 8) + (((uint32_t) RS_PKT_VERSION_SERVICE) << 24); }
|
||||
|
||||
protected:
|
||||
|
||||
/** Notifications **/
|
||||
|
|
|
@ -139,7 +139,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
GxsMsgReq msgIds;
|
||||
GxsMsgReq grps;
|
||||
|
||||
std::set<RsGxsId> used_gxs_ids ;
|
||||
std::map<RsGxsId,RsGxsGroupId> used_gxs_ids ;
|
||||
std::set<RsGxsGroupId> subscribed_groups ;
|
||||
|
||||
// compute hash and compare to stored value, if it fails then simply add it
|
||||
|
@ -172,7 +172,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
#endif
|
||||
|
||||
if(rsIdentity!=NULL && !rsIdentity->isBanned(grp->metaData->mAuthorId))
|
||||
used_gxs_ids.insert(grp->metaData->mAuthorId) ;
|
||||
used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId,grp->grpId)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
GXSUTIL_DEBUG() << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
|
||||
#endif
|
||||
if(rsIdentity!=NULL && !rsIdentity->isBanned(msg->metaData->mAuthorId))
|
||||
used_gxs_ids.insert(msg->metaData->mAuthorId) ;
|
||||
used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,msg->metaData->mGroupId)) ;
|
||||
}
|
||||
|
||||
delete msg;
|
||||
|
@ -297,9 +297,9 @@ bool RsGxsIntegrityCheck::check()
|
|||
std::list<RsPeerId> connected_friends ;
|
||||
rsPeers->getOnlineList(connected_friends) ;
|
||||
|
||||
std::vector<RsGxsId> gxs_ids ;
|
||||
std::vector<std::pair<RsGxsId,RsGxsGroupId> > gxs_ids ;
|
||||
|
||||
for(std::set<RsGxsId>::const_iterator it(used_gxs_ids.begin());it!=used_gxs_ids.end();++it)
|
||||
for(std::map<RsGxsId,RsGxsGroupId>::const_iterator it(used_gxs_ids.begin());it!=used_gxs_ids.end();++it)
|
||||
{
|
||||
gxs_ids.push_back(*it) ;
|
||||
#ifdef DEBUG_GXSUTIL
|
||||
|
@ -321,9 +321,9 @@ bool RsGxsIntegrityCheck::check()
|
|||
GXSUTIL_DEBUG() << " requesting ID " << gxs_ids[n] ;
|
||||
#endif
|
||||
|
||||
if(!mGixs->haveKey(gxs_ids[n])) // checks if we have it already in the cache (conservative way to ensure that we atually have it)
|
||||
if(!mGixs->haveKey(gxs_ids[n].first)) // checks if we have it already in the cache (conservative way to ensure that we atually have it)
|
||||
{
|
||||
mGixs->requestKey(gxs_ids[n],connected_friends);
|
||||
mGixs->requestKey(gxs_ids[n].first,connected_friends);
|
||||
|
||||
++nb_requested_not_in_cache ;
|
||||
#ifdef DEBUG_GXSUTIL
|
||||
|
@ -335,12 +335,8 @@ bool RsGxsIntegrityCheck::check()
|
|||
#ifdef DEBUG_GXSUTIL
|
||||
GXSUTIL_DEBUG() << " ... already in cache" << std::endl;
|
||||
#endif
|
||||
|
||||
// Note: we could time_stamp even in the case where the id is not cached. Anyway, it's not really a problem here, since IDs have a high chance of
|
||||
// behing eventually stamped.
|
||||
|
||||
mGixs->timeStampKey(gxs_ids[n],"Used in service (Integrity check)") ;
|
||||
}
|
||||
mGixs->timeStampKey(gxs_ids[n].first,"Author in group " + gxs_ids[n].second.toStdString() + " of service \"" + rsServiceControl->getServiceName(mGenExchangeClient->serviceFullType())) ;
|
||||
|
||||
gxs_ids[n] = gxs_ids[gxs_ids.size()-1] ;
|
||||
gxs_ids.pop_back() ;
|
||||
|
|
|
@ -362,6 +362,20 @@ void p3ServiceControl::getServiceChanges(std::set<RsPeerId> &updateSet)
|
|||
mUpdatedSet.clear();
|
||||
}
|
||||
|
||||
std::string p3ServiceControl::getServiceName(uint32_t service_id)
|
||||
{
|
||||
RsStackMutex stack(mCtrlMtx); /***** LOCK STACK MUTEX ****/
|
||||
|
||||
std::map<uint32_t, RsServiceInfo>::const_iterator it = mOwnServices.find(service_id) ;
|
||||
|
||||
if(it == mOwnServices.end())
|
||||
{
|
||||
std::cerr << "(EE) Cannot find own service for ID = " << std::hex << service_id << std::dec << std::endl;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return it->second.mServiceName;
|
||||
}
|
||||
|
||||
bool p3ServiceControl::getOwnServices(RsPeerServiceInfo &info)
|
||||
{
|
||||
|
|
|
@ -85,6 +85,7 @@ virtual const RsPeerId& getOwnId();
|
|||
*/
|
||||
|
||||
virtual bool getOwnServices(RsPeerServiceInfo &info);
|
||||
virtual std::string getServiceName(uint32_t service_id) ;
|
||||
|
||||
// This is what is passed to peers, can be displayed by GUI too.
|
||||
virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info);
|
||||
|
|
|
@ -184,7 +184,7 @@ public:
|
|||
// Cyril: Reputation details. At some point we might want to merge information
|
||||
// between the two into a single global score. Since the old reputation system
|
||||
// is not finished yet, I leave this in place. We should decide what to do with it.
|
||||
|
||||
#warning (cyril) possibly remove this old reputation field.
|
||||
GxsReputation mReputation_oldSystem; // this is the old "mReputation" field, which apparently is not used.
|
||||
RsReputations::ReputationInfo mReputation;
|
||||
|
||||
|
@ -193,6 +193,7 @@ public:
|
|||
|
||||
// last usage
|
||||
time_t mLastUsageTS ;
|
||||
std::map<std::string,time_t> mUseCases ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ class RsServiceControl
|
|||
virtual ~RsServiceControl() { return; }
|
||||
|
||||
virtual bool getOwnServices(RsPeerServiceInfo &info) = 0;
|
||||
virtual std::string getServiceName(uint32_t service_id) = 0;
|
||||
|
||||
virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
||||
virtual bool getServicesProvided(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
||||
|
|
|
@ -279,10 +279,24 @@ void p3IdService::timeStampKey(const RsGxsId& gxs_id, const std::string& reason)
|
|||
keyTSInfo& info(mKeysTS[gxs_id]) ;
|
||||
|
||||
info.TS = now ;
|
||||
info.usage_map[now] = reason ;
|
||||
info.usage_map[reason] = now;
|
||||
|
||||
while(info.usage_map.size() > GXS_MAX_KEY_TS_USAGE_MAP_SIZE)
|
||||
info.usage_map.erase(info.usage_map.begin());
|
||||
{
|
||||
// This is very costly, but normally the outerloop should never be rolled more than once.
|
||||
|
||||
std::map<std::string,time_t>::iterator best_it ;
|
||||
time_t best_time = now+1;
|
||||
|
||||
for(std::map<std::string,time_t>::iterator it(info.usage_map.begin());it!=info.usage_map.end();++it)
|
||||
if(it->second < best_time)
|
||||
{
|
||||
best_time = it->second ;
|
||||
best_it = it;
|
||||
}
|
||||
|
||||
info.usage_map.erase(best_it) ;
|
||||
}
|
||||
|
||||
slowIndicateConfigChanged() ;
|
||||
}
|
||||
|
@ -566,7 +580,16 @@ bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
|||
rsReputations->setOwnOpinion(id,RsReputations::OPINION_POSITIVE) ;
|
||||
|
||||
details = data.details;
|
||||
details.mLastUsageTS = locked_getLastUsageTS(id) ;
|
||||
|
||||
std::map<RsGxsId,keyTSInfo>::const_iterator it = mKeysTS.find(id) ;
|
||||
|
||||
if(it == mKeysTS.end())
|
||||
details.mLastUsageTS = 0 ;
|
||||
else
|
||||
{
|
||||
details.mLastUsageTS = it->second.TS ;
|
||||
details.mUseCases = it->second.usage_map ;
|
||||
}
|
||||
|
||||
// one utf8 symbol can be at most 4 bytes long - would be better to measure real unicode length !!!
|
||||
if(details.mNickname.length() > RSID_MAXIMUM_NICKNAME_SIZE*4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue