Tweaks to bitdht library for standalone single search option.

- Added flag to disable local Network search.
 - Fixed DHT Msg Rate bug (ported from trunk).



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5731 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-10-28 14:10:56 +00:00
parent 301e85c2fa
commit 72d3c868e3
3 changed files with 32 additions and 23 deletions

View file

@ -87,6 +87,8 @@ bdNodeManager::bdNodeManager(bdNodeId *id, std::string dhtVersion, std::string b
mFns->bdPrintNodeId(std::cerr, id); mFns->bdPrintNodeId(std::cerr, id);
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
mLocalNetEnhancements = true;
} }
int bdNodeManager::stopDht() int bdNodeManager::stopDht()
@ -400,31 +402,36 @@ void bdNodeManager::iteration()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* run a random search for ourselves, from own App DHT peer */
QueryRandomLocalNet(); /* This stuff is only important for "LocalNet based Features */
if (mLocalNetEnhancements)
{
/* run a random search for ourselves, from own App DHT peer */
QueryRandomLocalNet();
#define SEARCH_MAX_SIZE 10 #define SEARCH_MAX_SIZE 10
if (mBdNetworkSize < SEARCH_MAX_SIZE) if (mBdNetworkSize < SEARCH_MAX_SIZE)
{
#ifdef DEBUG_MGR
std::cerr << "Local Netsize: " << mBdNetworkSize << " to small...searching";
std::cerr << std::endl;
#endif
/* if the network size is very small */
SearchForLocalNet();
mSearchingDone = false;
}
else
{
if (!mSearchingDone)
{ {
mSearchingDone = true;
mSearchTS = now;
#ifdef DEBUG_MGR #ifdef DEBUG_MGR
std::cerr << "Completed LocalNet Search in : " << mSearchTS-mStartTS; std::cerr << "Local Netsize: " << mBdNetworkSize << " to small...searching";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* if the network size is very small */
SearchForLocalNet();
mSearchingDone = false;
}
else
{
if (!mSearchingDone)
{
mSearchingDone = true;
mSearchTS = now;
#ifdef DEBUG_MGR
std::cerr << "Completed LocalNet Search in : " << mSearchTS-mStartTS;
std::cerr << std::endl;
#endif
}
} }
} }

View file

@ -187,6 +187,8 @@ void SearchForLocalNet();
bdBloom mBloomFilter; bdBloom mBloomFilter;
bool mLocalNetEnhancements;
/* future node functions */ /* future node functions */
//addPeerPing(foundId); //addPeerPing(foundId);
//clearPing(it->first); //clearPing(it->first);

View file

@ -134,14 +134,14 @@ uint32_t bdNode::setNodeDhtMode(uint32_t dhtFlags)
{ {
default: default:
case BITDHT_MODE_TRAFFIC_LOW: case BITDHT_MODE_TRAFFIC_LOW:
mMaxAllowedMsgs = BDNODE_HIGH_MSG_RATE;
break;
case BITDHT_MODE_TRAFFIC_HIGH:
mMaxAllowedMsgs = BDNODE_LOW_MSG_RATE; mMaxAllowedMsgs = BDNODE_LOW_MSG_RATE;
break; break;
case BITDHT_MODE_TRAFFIC_MED: case BITDHT_MODE_TRAFFIC_MED:
mMaxAllowedMsgs = BDNODE_MED_MSG_RATE; mMaxAllowedMsgs = BDNODE_MED_MSG_RATE;
break; break;
case BITDHT_MODE_TRAFFIC_HIGH:
mMaxAllowedMsgs = BDNODE_HIGH_MSG_RATE;
break;
case BITDHT_MODE_TRAFFIC_TRICKLE: case BITDHT_MODE_TRAFFIC_TRICKLE:
mMaxAllowedMsgs = BDNODE_TRICKLE_MSG_RATE; mMaxAllowedMsgs = BDNODE_TRICKLE_MSG_RATE;
break; break;