My Project 3.2.0
C++ Distributed Hash Table
Loading...
Searching...
No Matches
dht::Node Struct Reference
Collaboration diagram for dht::Node:

Public Member Functions

 Node (const InfoHash &id, const SockAddr &addr, std::mt19937_64 &rd, bool client=false)
 
 Node (const InfoHash &id, SockAddr &&addr, std::mt19937_64 &rd, bool client=false)
 
 Node (const InfoHash &id, const sockaddr *sa, socklen_t salen, std::mt19937_64 &rd)
 
const InfoHashgetId () const
 
const SockAddrgetAddr () const
 
std::string getAddrStr () const
 
bool isClient () const
 
bool isIncoming ()
 
const time_point & getTime () const
 
const time_point & getReplyTime () const
 
void setTime (const time_point &t)
 
void authError ()
 
void authSuccess ()
 
bool isExpired () const
 
bool isGood (time_point now) const
 
bool isPendingMessage () const
 
size_t getPendingMessageCount () const
 
bool isOld (const time_point &now) const
 
bool isRemovable (const time_point &now) const
 
NodeExport exportNode () const
 
sa_family_t getFamily () const
 
void update (const SockAddr &)
 
void requested (const Sp< net::Request > &req)
 
void received (time_point now, const Sp< net::Request > &req)
 
Sp< net::Request > getRequest (Tid tid)
 
void cancelRequest (const Sp< net::Request > &req)
 
void setExpired ()
 
Tid openSocket (SocketCb &&cb)
 
Sp< SocketgetSocket (Tid id)
 
void closeSocket (Tid id)
 
void reset ()
 
Tid getNewTid ()
 
std::string toString () const
 

Public Attributes

const InfoHash id
 

Static Public Attributes

static constexpr const std::chrono::minutes NODE_GOOD_TIME {120}
 
static constexpr const std::chrono::minutes NODE_EXPIRE_TIME {10}
 
static constexpr const std::chrono::seconds MAX_RESPONSE_TIME {1}
 

Friends

OPENDHT_PUBLIC friend std::ostream & operator<< (std::ostream &s, const Node &h)
 

Detailed Description

Definition at line 48 of file node.h.

Constructor & Destructor Documentation

◆ Node()

dht::Node::Node ( const InfoHash & id,
const sockaddr * sa,
socklen_t salen,
std::mt19937_64 & rd )
inline

Definition at line 53 of file node.h.

Member Function Documentation

◆ authError()

void dht::Node::authError ( )
inline

Makes notice about an additionnal authentication error with this node. Up to MAX_AUTH_ERRORS errors are accepted in order to let the node recover. Upon this limit, the node expires.

Definition at line 75 of file node.h.

◆ authSuccess()

void dht::Node::authSuccess ( )
inline

Definition at line 79 of file node.h.

◆ closeSocket()

void dht::Node::closeSocket ( Tid id)

Closes a socket so that no further data will be red on that socket.

Parameters
socketThe socket to close.

◆ exportNode()

NodeExport dht::Node::exportNode ( ) const
inline

Definition at line 93 of file node.h.

◆ getAddr()

const SockAddr & dht::Node::getAddr ( ) const
inline

Definition at line 59 of file node.h.

◆ getAddrStr()

std::string dht::Node::getAddrStr ( ) const
inline

Definition at line 60 of file node.h.

◆ getFamily()

sa_family_t dht::Node::getFamily ( ) const
inline

Definition at line 99 of file node.h.

◆ getId()

const InfoHash & dht::Node::getId ( ) const
inline

Definition at line 56 of file node.h.

◆ getNewTid()

Tid dht::Node::getNewTid ( )
inline

Generates a new request id, skipping the invalid id.

Returns
the new id.

Definition at line 140 of file node.h.

◆ getReplyTime()

const time_point & dht::Node::getReplyTime ( ) const
inline

Definition at line 67 of file node.h.

◆ getTime()

const time_point & dht::Node::getTime ( ) const
inline

Definition at line 66 of file node.h.

◆ isClient()

bool dht::Node::isClient ( ) const
inline

Definition at line 63 of file node.h.

◆ isExpired()

bool dht::Node::isExpired ( ) const
inline

Definition at line 81 of file node.h.

◆ isIncoming()

bool dht::Node::isIncoming ( )
inline

Definition at line 64 of file node.h.

◆ isOld()

bool dht::Node::isOld ( const time_point & now) const
inline

Definition at line 86 of file node.h.

◆ isRemovable()

bool dht::Node::isRemovable ( const time_point & now) const
inline

Definition at line 89 of file node.h.

◆ openSocket()

Tid dht::Node::openSocket ( SocketCb && cb)

Opens a socket on which a node will be able allowed to write for further additionnal updates following the response to a previous request.

Parameters
nodeThe node which will be allowed to write on this socket.
cbThe callback to execute once updates arrive on the socket.
Returns
the socket.

◆ reset()

void dht::Node::reset ( )
inline

Resets the state of the node so it's not expired anymore.

Definition at line 133 of file node.h.

◆ setTime()

void dht::Node::setTime ( const time_point & t)
inline

Definition at line 68 of file node.h.

Member Data Documentation

◆ id

const InfoHash dht::Node::id

Definition at line 49 of file node.h.

◆ MAX_RESPONSE_TIME

const std::chrono::seconds dht::Node::MAX_RESPONSE_TIME {1}
staticconstexpr

Definition at line 155 of file node.h.

◆ NODE_EXPIRE_TIME

const std::chrono::minutes dht::Node::NODE_EXPIRE_TIME {10}
staticconstexpr

Definition at line 152 of file node.h.

◆ NODE_GOOD_TIME

const std::chrono::minutes dht::Node::NODE_GOOD_TIME {120}
staticconstexpr

Definition at line 149 of file node.h.


The documentation for this struct was generated from the following file: