mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-27 23:57:38 -04:00
merging gxs_phase2 branch
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6401 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1150366913
commit
325fa4f222
116 changed files with 6050 additions and 3596 deletions
|
@ -124,7 +124,7 @@ RsIdentity *rsIdentity = NULL;
|
|||
/********************************************************************************/
|
||||
|
||||
p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
|
||||
: RsGxsIdExchange(gds, nes, new RsGxsIdSerialiser(), RS_SERVICE_GXSV1_TYPE_GXSID, idAuthenPolicy()),
|
||||
: 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")
|
||||
|
@ -205,7 +205,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
/* shouldn't need to worry about groups - as they need to be subscribed to */
|
||||
if (groupChange)
|
||||
{
|
||||
std::cerr << "p3IdService::notifyChanges() Found Message Change Notification";
|
||||
std::cerr << "p3IdService::notifyChanges() Found Group Change Notification";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
|
||||
|
@ -360,8 +360,33 @@ int p3IdService::getPrivateKey(const RsGxsId &id, RsTlvSecurityKey &key)
|
|||
/******************* RsGixsReputation ***************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
bool p3IdService::getReputation(const RsGxsId &id, const GixsReputation &rep)
|
||||
bool p3IdService::haveReputation(const RsGxsId &id)
|
||||
{
|
||||
return haveKey(id);
|
||||
}
|
||||
|
||||
bool p3IdService::loadReputation(const RsGxsId &id)
|
||||
{
|
||||
if (haveKey(id))
|
||||
return true;
|
||||
return cache_request_load(id);
|
||||
}
|
||||
|
||||
bool p3IdService::getReputation(const RsGxsId &id, GixsReputation &rep)
|
||||
{
|
||||
/* this is the key part for accepting messages */
|
||||
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
RsGxsIdCache data;
|
||||
if (mPublicKeyCache.fetch(id, data))
|
||||
{
|
||||
rep.id = id;
|
||||
// Score > 0 is okay.
|
||||
// Will extract score from Cache Info.
|
||||
// For the moment just return positive number.
|
||||
rep.score = 10;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2107,12 +2132,9 @@ std::string rsIdTypeToString(uint32_t idtype)
|
|||
* that we don't block at all. This should be in a background thread.
|
||||
* Perhaps a generic method to handle this will be advisable.... but we do that later.
|
||||
*
|
||||
* To start with we will work from the Posted service.
|
||||
*
|
||||
*
|
||||
*
|
||||
* So Reputation....
|
||||
* Three components:
|
||||
* 4 components:
|
||||
* 1) Your Opinion: Should override everything else.
|
||||
* 2) Implicit Factors: Know the associated GPG Key.
|
||||
* 3) Your Friends Opinions:
|
||||
|
@ -2157,6 +2179,56 @@ std::string rsIdTypeToString(uint32_t idtype)
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/************************************************************************************/
|
||||
/*
|
||||
* Scoring system.
|
||||
* -100 to 100 is expected range.
|
||||
*
|
||||
*
|
||||
* Each Lobby has a publish threshold.
|
||||
* - As part of Lobby definition. ???
|
||||
* - Locally Set.
|
||||
*
|
||||
* Threshold:
|
||||
* 50 VIP List.
|
||||
* 20 Dress Code
|
||||
* 10 Limit Riffraff.
|
||||
* 0 Accept All.
|
||||
*
|
||||
* Implicit Scores:
|
||||
* +50 for known PGP
|
||||
* +10 for unknown PGP (want to encourage usage).
|
||||
* +5 for Anon ID.
|
||||
*
|
||||
* Own Scores:
|
||||
* +1000 Accepted
|
||||
* +50 Friend
|
||||
* +10 Interesting
|
||||
* 0 Mostly Harmless
|
||||
* -10 Annoying.
|
||||
* -50 Troll
|
||||
* -1000 Total Banned
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
|
||||
Processing Algorithm:
|
||||
* - Grab all Groups which have received messages.
|
||||
* (opt 1)-> grab latest msgs for each of these and process => score.
|
||||
* (opt 2)-> try incremental system (people probably won't change opinions often -> just set them once)
|
||||
* --> if not possible, fallback to full calculation.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool p3IdService::reputation_start()
|
||||
{
|
||||
if (!CacheArbitration(BG_REPUTATION))
|
||||
|
@ -2891,3 +2963,65 @@ void p3IdService::handle_event(uint32_t event_type, const std::string &elabel)
|
|||
|
||||
|
||||
|
||||
|
||||
/***** Conversion fns for RsGxsIdOpinion ****************/
|
||||
|
||||
#define REP_OFFSET 10000
|
||||
#define REP_RANGE 1000
|
||||
|
||||
int limitRep(int ans)
|
||||
{
|
||||
if (ans < -REP_RANGE)
|
||||
{
|
||||
ans = -REP_RANGE;
|
||||
}
|
||||
if (ans > REP_RANGE)
|
||||
{
|
||||
ans = REP_RANGE;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
int convertRepToInt(uint32_t rep)
|
||||
{
|
||||
if (rep == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return limitRep(rep - REP_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
uint32_t convertRepToUint32(int rep)
|
||||
{
|
||||
return limitRep(rep) + REP_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
int RsGxsIdOpinion::getOpinion()
|
||||
{
|
||||
return convertRepToInt(mOpinion);
|
||||
}
|
||||
|
||||
|
||||
int RsGxsIdOpinion::setOpinion(int op)
|
||||
{
|
||||
mOpinion = convertRepToUint32(op);
|
||||
return op;
|
||||
}
|
||||
|
||||
int RsGxsIdOpinion::getReputation()
|
||||
{
|
||||
return convertRepToInt(mReputation);
|
||||
}
|
||||
|
||||
|
||||
int RsGxsIdOpinion::setReputation(int op)
|
||||
{
|
||||
mReputation = convertRepToUint32(op);
|
||||
return op;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue