mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 09:26:18 -05:00
added feedback from rsgenexchange into Global router to add routing information
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7628 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b593a918a0
commit
c17de671bb
@ -35,10 +35,13 @@ class RsGRouterGenericDataItem ;
|
||||
|
||||
static const uint32_t GROUTER_CLIENT_ID_MESSAGES = 0x1001 ;
|
||||
|
||||
static const uint32_t RS_GROUTER_MATRIX_MAX_HIT_ENTRIES = 5;
|
||||
static const uint32_t RS_GROUTER_MATRIX_MAX_HIT_ENTRIES = 10; // max number of clues to store
|
||||
static const uint32_t RS_GROUTER_MATRIX_MIN_TIME_BETWEEN_HITS = 60; // can be set to up to half the publish time interval. Prevents flooding routes.
|
||||
static const uint32_t RS_GROUTER_MIN_CONFIG_SAVE_PERIOD = 5; // at most save config every 5 seconds
|
||||
|
||||
static const float RS_GROUTER_BASE_WEIGHT_ROUTED_MSG = 1.0f ; // base contribution of routed message clue to routing matrix
|
||||
static const float RS_GROUTER_BASE_WEIGHT_GXS_PACKET = 0.1f ; // base contribution of GXS message to routing matrix
|
||||
|
||||
static const time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything
|
||||
static const time_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation.
|
||||
static const time_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 1 *10 ; // Check for key advertising every 10 minutes
|
||||
|
@ -760,7 +760,7 @@ void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item)
|
||||
//
|
||||
// The time should also be set so that the routing clue has less importance.
|
||||
//
|
||||
float base = (item->state == RS_GROUTER_ACK_STATE_RCVD)?1.0f : 0.5 ;
|
||||
float base = ((item->state == RS_GROUTER_ACK_STATE_RCVD)?1.0f : 0.5) * RS_GROUTER_BASE_WEIGHT_ROUTED_MSG ;
|
||||
uint32_t time_shift = now - (*it2).time_stamp ;
|
||||
float probability = (*it2).probability;
|
||||
|
||||
@ -832,6 +832,15 @@ void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item)
|
||||
}
|
||||
}
|
||||
|
||||
void p3GRouter::addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id)
|
||||
{
|
||||
RsStackMutex mtx(grMtx) ;
|
||||
#ifdef GROUTER_DEBUG
|
||||
grouter_debug() << "Received new routing clue for key " << id << " from peer " << peer_id << std::endl;
|
||||
#endif
|
||||
_routing_matrix.addRoutingClue(id,peer_id,RS_GROUTER_BASE_WEIGHT_GXS_PACKET) ;
|
||||
}
|
||||
|
||||
void p3GRouter::handleRecvDataItem(RsGRouterGenericDataItem *item)
|
||||
{
|
||||
RsStackMutex mtx(grMtx) ;
|
||||
|
@ -57,12 +57,12 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
||||
// Router clients business //
|
||||
//===================================================//
|
||||
|
||||
// This method allows to associate client ids (that are saved to disk) to client objects deriving
|
||||
// This method allows to associate client ids (that are saved to disk) to client objects deriving
|
||||
// from GRouterClientService. The various services are responsible for regstering themselves to the
|
||||
// global router, with consistent ids. The services are stored in a map, and arriving objects are
|
||||
// passed on the correct service depending on the client id of the key they are reaching.
|
||||
//
|
||||
bool registerClientService(const GRouterServiceId& id,GRouterClientService *service) ;
|
||||
virtual bool registerClientService(const GRouterServiceId& id,GRouterClientService *service) ;
|
||||
|
||||
// Use this method to register/unregister a key that the global router will
|
||||
// forward in the network, so that is can be a possible destination for
|
||||
@ -77,10 +77,16 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
||||
// Unregistering a key might not have an instantaneous effect, so the client is responsible for
|
||||
// discarding traffic that might later come for this key.
|
||||
//
|
||||
bool registerKey(const GRouterKeyId& key, const GRouterServiceId& client_id,const std::string& description_string) ;
|
||||
bool unregisterKey(const GRouterKeyId& key) ;
|
||||
virtual bool registerKey(const GRouterKeyId& key, const GRouterServiceId& client_id,const std::string& description_string) ;
|
||||
virtual bool unregisterKey(const GRouterKeyId& key) ;
|
||||
|
||||
//===================================================//
|
||||
//===================================================//
|
||||
// Routing clue collection methods //
|
||||
//===================================================//
|
||||
|
||||
virtual void addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id) ;
|
||||
|
||||
//===================================================//
|
||||
// Client/server request services //
|
||||
//===================================================//
|
||||
|
||||
@ -89,12 +95,12 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
||||
// remembered by the client, so that he knows when the data has been received.
|
||||
// The client id is supplied so that the client can be notified when the data has been received.
|
||||
//
|
||||
void sendData(const GRouterKeyId& destination,const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) ;
|
||||
virtual void sendData(const GRouterKeyId& destination,const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) ;
|
||||
|
||||
// Sends an ACK to the origin of the msg. This is used to notify for
|
||||
// unfound route, or message correctly received, depending on the particular situation.
|
||||
//
|
||||
void sendACK(const RsPeerId& peer,GRouterMsgPropagationId mid, uint32_t flags) ;
|
||||
virtual void sendACK(const RsPeerId& peer,GRouterMsgPropagationId mid, uint32_t flags) ;
|
||||
|
||||
//===================================================//
|
||||
// Interface with RsGRouter //
|
||||
@ -131,7 +137,7 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
||||
SERVICE_INFO_MIN_MINOR_VERSION) ;
|
||||
}
|
||||
|
||||
void setDebugEnabled(bool b) { _debug_enabled = b ; }
|
||||
virtual void setDebugEnabled(bool b) { _debug_enabled = b ; }
|
||||
protected:
|
||||
//===================================================//
|
||||
// Routing method handling //
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "util/contentvalue.h"
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
#include "retroshare/rsgxscircles.h"
|
||||
#include "retroshare/rsgrouter.h"
|
||||
#include "rsgixs.h"
|
||||
#include "rsgxsutil.h"
|
||||
|
||||
@ -165,7 +166,7 @@ void RsGenExchange::tick()
|
||||
// Meta Changes should happen first.
|
||||
// This is important, as services want to change Meta, then get results.
|
||||
// Services shouldn't rely on this ordering - but some do.
|
||||
processGrpMetaChanges();
|
||||
processGrpMetaChanges();
|
||||
processMsgMetaChanges();
|
||||
|
||||
mDataAccess->processRequests();
|
||||
@ -178,7 +179,9 @@ void RsGenExchange::tick()
|
||||
|
||||
processGroupDelete();
|
||||
|
||||
processRecvdData();
|
||||
processRecvdData();
|
||||
|
||||
processRoutingClues() ;
|
||||
|
||||
if(!mNotifications.empty())
|
||||
{
|
||||
@ -2040,6 +2043,16 @@ void RsGenExchange::processGroupUpdatePublish()
|
||||
}
|
||||
|
||||
|
||||
void RsGenExchange::processRoutingClues()
|
||||
{
|
||||
RsStackMutex stack(mGenMtx);
|
||||
|
||||
for(std::map<RsGxsId,std::set<RsPeerId> >::const_iterator it = mRoutingClues.begin();it!=mRoutingClues.end();++it)
|
||||
for(std::set<RsPeerId>::const_iterator it2(it->second.begin());it2!=it->second.end();++it2)
|
||||
rsGRouter->addRoutingClue(GRouterKeyId(it->first),(*it2)) ;
|
||||
|
||||
mRoutingClues.clear() ;
|
||||
}
|
||||
void RsGenExchange::processGroupDelete()
|
||||
{
|
||||
RsStackMutex stack(mGenMtx);
|
||||
@ -2478,7 +2491,7 @@ void RsGenExchange::processRecvdMessages()
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(msg->grpId);
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " msg info : grp id=" << msg->grpId << ", msg id=" << msg->msgId << std::endl;
|
||||
std::cerr << " msg info : grp id=" << msg->grpId << ", msg id=" << msg->msgId << std::endl;
|
||||
#endif
|
||||
|
||||
// validate msg
|
||||
@ -2492,23 +2505,27 @@ void RsGenExchange::processRecvdMessages()
|
||||
}
|
||||
|
||||
if(validateReturn == VALIDATE_SUCCESS)
|
||||
{
|
||||
meta->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
|
||||
msgs.insert(std::make_pair(msg, meta));
|
||||
msgIds[msg->grpId].push_back(msg->msgId);
|
||||
{
|
||||
meta->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
|
||||
msgs.insert(std::make_pair(msg, meta));
|
||||
msgIds[msg->grpId].push_back(msg->msgId);
|
||||
|
||||
NxsMsgPendingVect::iterator validated_entry = std::find(mMsgPendingValidate.begin(), mMsgPendingValidate.end(),
|
||||
getMsgIdPair(*msg));
|
||||
NxsMsgPendingVect::iterator validated_entry = std::find(mMsgPendingValidate.begin(), mMsgPendingValidate.end(),
|
||||
getMsgIdPair(*msg));
|
||||
|
||||
if(validated_entry != mMsgPendingValidate.end()) mMsgPendingValidate.erase(validated_entry);
|
||||
if(validated_entry != mMsgPendingValidate.end()) mMsgPendingValidate.erase(validated_entry);
|
||||
|
||||
computeHash(msg->msg, meta->mHash);
|
||||
meta->recvTS = time(NULL);
|
||||
computeHash(msg->msg, meta->mHash);
|
||||
meta->recvTS = time(NULL);
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " new status flags: " << meta->mMsgStatus << std::endl;
|
||||
std::cerr << " computed hash: " << meta->mHash << std::endl;
|
||||
std::cerr << " new status flags: " << meta->mMsgStatus << std::endl;
|
||||
std::cerr << " computed hash: " << meta->mHash << std::endl;
|
||||
std::cerr << "Message received. Identity=" << msg->metaData->mAuthorId << ", from peer " << msg->PeerId() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(!msg->metaData->mAuthorId.isNull())
|
||||
mRoutingClues[msg->metaData->mAuthorId].insert(msg->PeerId()) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2626,6 +2643,15 @@ void RsGenExchange::processRecvdGroups()
|
||||
|
||||
computeHash(grp->grp, meta->mHash);
|
||||
|
||||
// group has been validated. Let's notify the global router for the clue
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "Group routage info: Identity=" << meta->mAuthorId << " from " << grp->PeerId() << std::endl;
|
||||
#endif
|
||||
|
||||
if(!meta->mAuthorId.isNull())
|
||||
mRoutingClues[meta->mAuthorId].insert(grp->PeerId()) ;
|
||||
|
||||
// now check if group already existss
|
||||
if(std::find(existingGrpIds.begin(), existingGrpIds.end(), grp->grpId) == existingGrpIds.end())
|
||||
{
|
||||
|
@ -671,7 +671,8 @@ private:
|
||||
|
||||
void processGroupUpdatePublish();
|
||||
|
||||
void processGroupDelete();
|
||||
void processGroupDelete();
|
||||
void processRoutingClues();
|
||||
|
||||
void publishMsgs();
|
||||
|
||||
@ -884,8 +885,9 @@ private:
|
||||
std::vector<GroupUpdate> mGroupUpdates, mPeersGroupUpdate;
|
||||
|
||||
std::vector<GroupUpdatePublish> mGroupUpdatePublish;
|
||||
std::vector<GroupDeletePublish> mGroupDeletePublish;
|
||||
|
||||
std::vector<GroupDeletePublish> mGroupDeletePublish;
|
||||
std::map<RsGxsId,std::set<RsPeerId> > mRoutingClues ;
|
||||
|
||||
};
|
||||
|
||||
|
@ -87,6 +87,12 @@ class RsGRouter
|
||||
|
||||
virtual void sendData(const GRouterKeyId& destination, const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) =0;
|
||||
virtual bool registerKey(const GRouterKeyId& key,const GRouterServiceId& client_id,const std::string& description_string) =0;
|
||||
|
||||
//===================================================//
|
||||
// Routage feedback from other services //
|
||||
//===================================================//
|
||||
|
||||
virtual void addRoutingClue(const GRouterKeyId& destination, const RsPeerId& source) =0;
|
||||
};
|
||||
|
||||
// To access the GRouter from anywhere
|
||||
|
Loading…
Reference in New Issue
Block a user