mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
enabled load/save of grouter configuration. Checked that keys and info is properly restored at startup
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6975 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
146465a53f
commit
be3a593ee2
5 changed files with 28 additions and 1 deletions
|
@ -122,7 +122,7 @@ void GRouterMatrix::debugDump() const
|
|||
|
||||
for(std::map<GRouterKeyId, std::vector<float> >::const_iterator it(_time_combined_hits.begin());it!=_time_combined_hits.end();++it)
|
||||
{
|
||||
std::cerr << it->first.toStdString() << " : " ;
|
||||
std::cerr << " " << it->first.toStdString() << " : " ;
|
||||
|
||||
for(uint32_t i=0;i<it->second.size();++i)
|
||||
std::cerr << it->second[i] << " " ;
|
||||
|
|
|
@ -38,6 +38,7 @@ typedef uint32_t GRouterMsgPropagationId ;
|
|||
|
||||
static const uint32_t RS_GROUTER_MATRIX_MAX_HIT_ENTRIES = 5;
|
||||
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 time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 20 ; // Output everything
|
||||
static const time_t RS_GROUTER_AUTOWASH_PERIOD = 60 ; // Autowash every minute. Not a costly operation.
|
||||
|
|
|
@ -37,6 +37,8 @@ p3GRouter::p3GRouter(p3LinkMgr *lm)
|
|||
{
|
||||
addSerialType(new RsGRouterSerialiser()) ;
|
||||
|
||||
_changed = false ;
|
||||
|
||||
// Debug stuff. Create a random key and register it.
|
||||
uint8_t random_hash_buff[20] ;
|
||||
RSRandom::random_bytes(random_hash_buff,20) ;
|
||||
|
@ -52,6 +54,7 @@ int p3GRouter::tick()
|
|||
static time_t last_autowash_time = 0 ;
|
||||
static time_t last_publish_campaign_time = 0 ;
|
||||
static time_t last_debug_output_time = 0 ;
|
||||
static time_t last_config_changed = 0 ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
|
@ -85,6 +88,19 @@ int p3GRouter::tick()
|
|||
last_debug_output_time = now ;
|
||||
debugDump() ;
|
||||
}
|
||||
|
||||
// If content has changed, save config, at most every RS_GROUTER_MIN_CONFIG_SAVE_PERIOD seconds appart
|
||||
// Otherwise, always save at least every RS_GROUTER_MAX_CONFIG_SAVE_PERIOD seconds
|
||||
//
|
||||
if(_changed && now > last_config_changed + RS_GROUTER_MIN_CONFIG_SAVE_PERIOD)
|
||||
{
|
||||
std::cerr << "p3GRouter::tick(): triggering config save." << std::endl;
|
||||
|
||||
_changed = false ;
|
||||
last_config_changed = now ;
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
@ -422,6 +438,8 @@ void p3GRouter::handleRecvPublishKeyItem(RsGRouterPublishKeyItem *item)
|
|||
// Doing this we can control the amount of key propagation and avoid flooding.
|
||||
|
||||
locked_forwardKey(*item) ;
|
||||
|
||||
_changed = true ;
|
||||
}
|
||||
|
||||
void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item)
|
||||
|
@ -536,6 +554,8 @@ void p3GRouter::handleRecvDataItem(RsGRouterGenericDataItem *item)
|
|||
std::cerr << " (WW) key is outdated. Dropping this item." << std::endl;
|
||||
else
|
||||
std::cerr << " Item is not for us. Leaving in pending msgs to be routed later." << std::endl;
|
||||
|
||||
_changed = true ;
|
||||
}
|
||||
|
||||
bool p3GRouter::registerClientService(const GRouterServiceId& id,GRouterClientService *service)
|
||||
|
|
|
@ -199,6 +199,9 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||
// Multi-thread protection mutex.
|
||||
//
|
||||
RsMutex grMtx ;
|
||||
|
||||
// config update/save variables
|
||||
bool _changed ;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue