mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
added auto-cleaning of reputation info for outdated/removed identities
This commit is contained in:
parent
bf28ea7ac7
commit
c98416dc28
4 changed files with 174 additions and 153 deletions
|
@ -254,6 +254,7 @@ virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
|||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||
virtual bool isBanned(const RsGxsId& id) =0;
|
||||
virtual time_t getLastUsageTS(const RsGxsId &id) =0;
|
||||
|
||||
// Specific RsIdentity Functions....
|
||||
/* Specific Service Data */
|
||||
|
|
|
@ -117,13 +117,13 @@
|
|||
* 10 | 1.0 | 0 | 0.25 | 1.0
|
||||
*
|
||||
* To check:
|
||||
* [ ] Opinions are saved/loaded accross restart
|
||||
* [ ] Opinions are transmitted to friends
|
||||
* [ ] Opinions are transmitted to friends when updated
|
||||
* [X] Opinions are saved/loaded accross restart
|
||||
* [X] Opinions are transmitted to friends
|
||||
* [X] Opinions are transmitted to friends when updated
|
||||
*
|
||||
* To do:
|
||||
* [ ] Add debug info
|
||||
* [ ] Test the whole thing
|
||||
* [X] Add debug info
|
||||
* [X] Test the whole thing
|
||||
* [X] Implement a system to allow not storing info when we don't have it
|
||||
*/
|
||||
|
||||
|
@ -139,6 +139,7 @@ static const float REPUTATION_ASSESSMENT_THRESHOLD_X1 = 0.5f ; // reputat
|
|||
static const uint32_t PGP_AUTO_BAN_THRESHOLD_DEFAULT = 2 ; // above this, auto ban any GXS id signed by this node
|
||||
static const uint32_t IDENTITY_FLAGS_UPDATE_DELAY = 100 ; //
|
||||
static const uint32_t BANNED_NODES_UPDATE_DELAY = 313 ; // update approx every 5 mins. Chosen to not be a multiple of IDENTITY_FLAGS_UPDATE_DELAY
|
||||
static const uint32_t REPUTATION_INFO_KEEP_DELAY = 86400*35; // remove old reputation info 5 days after last usage limit, in case the ID would come back..
|
||||
|
||||
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
||||
:p3Service(), p3Config(),
|
||||
|
@ -343,6 +344,7 @@ void p3GxsReputation::cleanup()
|
|||
// identities, which would cause an excess of hits to the database.
|
||||
|
||||
bool updated = false ;
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
|
@ -358,6 +360,17 @@ void p3GxsReputation::cleanup()
|
|||
#endif
|
||||
updated = true ;
|
||||
}
|
||||
else if(rsIdentity->getLastUsageTS(it->first) + REPUTATION_INFO_KEEP_DELAY < now)
|
||||
{
|
||||
#ifdef DEBUG_REPUTATION
|
||||
std::cerr << " Identity " << it->first << " has a last usage TS of " << now - rsIdentity->getLastUsageTS(it->first) << " secs ago: deleting it." << std::endl;
|
||||
#endif
|
||||
std::map<RsGxsId,Reputation>::iterator tmp(it) ;
|
||||
++tmp ;
|
||||
mReputations.erase(it) ;
|
||||
it = tmp ;
|
||||
updated = true ;
|
||||
}
|
||||
else
|
||||
++it ;
|
||||
|
||||
|
|
|
@ -503,6 +503,12 @@ bool p3IdService:: getNickname(const RsGxsId &id, std::string &nickname)
|
|||
}
|
||||
#endif
|
||||
|
||||
time_t p3IdService::getLastUsageTS(const RsGxsId &id)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
return locked_getLastUsageTS(id) ;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
|
|
|
@ -275,6 +275,7 @@ virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
|||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) ;
|
||||
virtual bool isBanned(const RsGxsId& id) ;
|
||||
virtual time_t getLastUsageTS(const RsGxsId &id) ;
|
||||
|
||||
/**************** RsGixs Implementation ***************/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue