mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 16:45:11 -04:00
added non selective tracking for GXS messages
This commit is contained in:
parent
7db3bb1c9b
commit
47dd70fbe8
13 changed files with 160 additions and 83 deletions
|
@ -27,13 +27,56 @@
|
|||
#include "groutermatrix.h"
|
||||
#include "grouteritems.h"
|
||||
|
||||
//#define ROUTING_MATRIX_DEBUG
|
||||
#define ROUTING_MATRIX_DEBUG
|
||||
|
||||
GRouterMatrix::GRouterMatrix()
|
||||
{
|
||||
_proba_need_updating = true ;
|
||||
}
|
||||
|
||||
bool GRouterMatrix::addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& source_friend)
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
uint32_t fid = getFriendId(source_friend) ;
|
||||
|
||||
RoutingTrackEntry rte ;
|
||||
|
||||
rte.friend_id = fid ;
|
||||
rte.time_stamp = now ;
|
||||
|
||||
_tracking_clues[mid] = rte ;
|
||||
#ifdef ROUTING_MATRIX_DEBUG
|
||||
std::cerr << "GRouterMatrix::addTrackingInfo(): Added clue mid=" << mid << ", from " << source_friend << " ID=" << fid << std::endl;
|
||||
#endif
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool GRouterMatrix::cleanUp()
|
||||
{
|
||||
// remove all tracking entries that have become too old.
|
||||
|
||||
#ifdef ROUTING_MATRIX_DEBUG
|
||||
std::cerr << "GRouterMatrix::cleanup()" << std::endl;
|
||||
#endif
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
for(std::map<RsGxsMessageId,RoutingTrackEntry>::iterator it(_tracking_clues.begin());it!=_tracking_clues.end();)
|
||||
if(it->second.time_stamp + RS_GROUTER_MAX_KEEP_TRACKING_CLUES < now)
|
||||
{
|
||||
#ifdef ROUTING_MATRIX_DEBUG
|
||||
std::cerr << " removing old entry msgId=" << it->first << ", from id " << it->second.friend_id << ", obtained " << (now - it->second.time_stamp) << " secs ago." << std::endl;
|
||||
#endif
|
||||
std::map<RsGxsMessageId,RoutingTrackEntry>::iterator tmp(it) ;
|
||||
++tmp ;
|
||||
_tracking_clues.erase(it) ;
|
||||
it=tmp ;
|
||||
}
|
||||
else
|
||||
++it ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool GRouterMatrix::addRoutingClue(const GRouterKeyId& key_id,const RsPeerId& source_friend,float weight)
|
||||
{
|
||||
// 1 - get the friend index.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue