diff --git a/include/opendht/dht.h b/include/opendht/dht.h index 71d6865717c6f45e02e1f7d90f34341cc0632028..65bceec0866a451a3f9fea2a98a45e08169497fa 100644 --- a/include/opendht/dht.h +++ b/include/opendht/dht.h @@ -113,12 +113,12 @@ public: * The node is not pinged, so this should be * used to bootstrap efficiently from previously known nodes. */ - bool insertNode(const InfoHash& id, const sockaddr*, socklen_t); - bool insertNode(const NodeExport& n) { - return insertNode(n.id, reinterpret_cast<const sockaddr*>(&n.ss), n.sslen); + void insertNode(const InfoHash& id, const sockaddr*, socklen_t); + void insertNode(const NodeExport& n) { + insertNode(n.id, reinterpret_cast<const sockaddr*>(&n.ss), n.sslen); } - int pingNode(const sockaddr*, socklen_t); + void pingNode(const sockaddr*, socklen_t); time_point periodic(const uint8_t *buf, size_t buflen, const sockaddr *from, socklen_t fromlen); diff --git a/src/dht.cpp b/src/dht.cpp index 655240a20e9377f2e6eb9882d8c11d3d1da5793f..8ba46df6b4aa5cad65a562fd3e4a43c2a71401c5 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -2844,30 +2844,28 @@ Dht::exportNodes() return nodes; } -bool +void Dht::insertNode(const InfoHash& id, const sockaddr* sa, socklen_t salen) { if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) - return false; + return; scheduler.syncTime(); - auto n = network_engine.insertNode(id, sa, salen); - return !!n; + network_engine.insertNode(id, sa, salen); } -int +void Dht::pingNode(const sockaddr* sa, socklen_t salen) { scheduler.syncTime(); DHT_LOG.DEBUG("Sending ping to %s", print_addr(sa, salen).c_str()); auto& count = sa->sa_family == AF_INET ? pending_pings4 : pending_pings6; count++; - network_engine.sendPing(sa, salen, [&](const Request&, NetworkEngine::RequestAnswer&&){ + network_engine.sendPing(sa, salen, [&](const Request&, NetworkEngine::RequestAnswer&&) { count--; }, [&](const Request&, bool last){ if (last) count--; }); - return -1; } void