mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
updates to libbitdht to make it work with retroshare.
* decreased nodes per bucket to 10 - to try reduce traffic. * changed operator< to non const. * fixed up debuging. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3322 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1069ed0c58
commit
c1b624832f
@ -54,7 +54,7 @@
|
||||
* #define DEBUG_MGR_PKT 1
|
||||
***/
|
||||
|
||||
//#define DEBUG_MGR 1
|
||||
#define DEBUG_MGR 1
|
||||
|
||||
bdNodeManager::bdNodeManager(bdNodeId *id, std::string dhtVersion, std::string bootfile, bdDhtFunctions *fns)
|
||||
:bdNode(id, dhtVersion, bootfile, fns)
|
||||
@ -141,7 +141,7 @@ void bdNodeManager::iteration()
|
||||
if (modeAge > MAX_STARTUP_TIME)
|
||||
{
|
||||
#ifdef DEBUG_MGR
|
||||
std::cerr << "bdNodeManager::iteration(): STARTUP ";
|
||||
std::cerr << "bdNodeManager::iteration(): STARTUP -> REFRESH";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
bdNodeId id;
|
||||
@ -157,6 +157,10 @@ void bdNodeManager::iteration()
|
||||
case BITDHT_MGR_STATE_ACTIVE:
|
||||
if (modeAge > MAX_REFRESH_TIME)
|
||||
{
|
||||
#ifdef DEBUG_MGR
|
||||
std::cerr << "bdNodeManager::iteration(): ACTIVE -> REFRESH";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mMode = BITDHT_MGR_STATE_REFRESH;
|
||||
mModeTS = now;
|
||||
}
|
||||
@ -165,6 +169,10 @@ void bdNodeManager::iteration()
|
||||
|
||||
case BITDHT_MGR_STATE_REFRESH:
|
||||
{
|
||||
#ifdef DEBUG_MGR
|
||||
std::cerr << "bdNodeManager::iteration(): REFRESH -> ACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* select random ids, and perform searchs to refresh space */
|
||||
mMode = BITDHT_MGR_STATE_ACTIVE;
|
||||
mModeTS = now;
|
||||
|
@ -215,8 +215,8 @@ void bdNode::iteration()
|
||||
genNewTransId(&transId);
|
||||
registerOutgoingMsg(&id, &transId, BITDHT_MSG_TYPE_FIND_NODE);
|
||||
|
||||
msgout_find_node(&id, &transId, &targetNodeId);
|
||||
#ifdef DEBUG_NODE_MSGS
|
||||
msgout_find_node(&id, &transId, &targetNodeId);
|
||||
std::cerr << "bdNode::iteration() Find Node Req for : ";
|
||||
mFns->bdPrintId(std::cerr, &id);
|
||||
std::cerr << " searching for : ";
|
||||
@ -371,7 +371,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
|
||||
|
||||
#ifdef DEBUG_NODE_ACTIONS
|
||||
fprintf(stderr, "bdNode::addPeer(");
|
||||
bdPrintId(std::cerr, id);
|
||||
mFns->bdPrintId(std::cerr, id);
|
||||
fprintf(stderr, ")\n");
|
||||
#endif
|
||||
|
||||
@ -484,8 +484,8 @@ void bdNode::processRemoteQuery()
|
||||
std::cerr << "bdNode::processRemoteQuery() Reply to Find Node: ";
|
||||
mFns->bdPrintId(std::cerr, &(query.mId));
|
||||
std::cerr << " searching for : ";
|
||||
bdPrintNodeId(std::cerr, &(query.mQuery));
|
||||
mFns->std::cerr << ", found " << nearest.size() << " nodes ";
|
||||
mFns->bdPrintNodeId(std::cerr, &(query.mQuery));
|
||||
std::cerr << ", found " << nearest.size() << " nodes ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "bitdht/bdiface.h"
|
||||
|
||||
#define BITDHT_STANDARD_BUCKET_SIZE 20
|
||||
#define BITDHT_STANDARD_BUCKET_SIZE 10 // 20 - too many per query.
|
||||
#define BITDHT_STANDARD_BUCKET_SIZE_BITS 5
|
||||
|
||||
#define BITDHT_STANDARD_N_BUCKETS BITDHT_KEY_BITLEN
|
||||
|
@ -42,6 +42,7 @@
|
||||
/*
|
||||
* #define DEBUG_UDP_BITDHT 1
|
||||
*/
|
||||
|
||||
//#define DEBUG_UDP_BITDHT 1
|
||||
|
||||
/*************************************/
|
||||
|
@ -37,6 +37,8 @@
|
||||
* #define DEBUG_UDP_LAYER 1
|
||||
***/
|
||||
|
||||
//#define DEBUG_UDP_LAYER 1
|
||||
|
||||
static const int UDP_DEF_TTL = 64;
|
||||
|
||||
/* NB: This #define makes the listener open 0.0.0.0:X port instead
|
||||
@ -77,7 +79,8 @@ class udpPacket
|
||||
int len;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const struct sockaddr_in &addr)
|
||||
//std::ostream &operator<<(std::ostream &out, const struct sockaddr_in &addr)
|
||||
std::ostream &operator<<(std::ostream &out, struct sockaddr_in &addr)
|
||||
{
|
||||
out << "[" << inet_ntoa(addr.sin_addr) << ":";
|
||||
out << htons(addr.sin_port) << "]";
|
||||
|
@ -33,7 +33,10 @@
|
||||
#include <list>
|
||||
#include <deque>
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const struct sockaddr_in &addr);
|
||||
/* careful - duplicate definitions */
|
||||
//std::ostream &operator<<(std::ostream &out, const struct sockaddr_in &addr);
|
||||
std::ostream &operator<<(std::ostream &out, struct sockaddr_in &addr);
|
||||
|
||||
bool operator==(const struct sockaddr_in &addr, const struct sockaddr_in &addr2);
|
||||
bool operator<(const struct sockaddr_in &addr, const struct sockaddr_in &addr2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user