diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/Torrents.cpp /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/Torrents.cpp --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/Torrents.cpp 2026-09-22 01:06:18.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/Torrents.cpp 2026-09-22 00:23:01.000000000 +0000 @@ -1186,7 +1186,6 @@ m_IsInterested (false), m_IsRemoteInterested (false), m_LastReceiveTime (0), m_LastSendTime (0), m_NumRequests (0), m_NumPieces (0), m_LastRequestedPieceIndex (-1), - m_RemoteMsgIDUtMetadata (0), m_RemoteMsgIDI2PPEX (0), m_RemoteMsgIDI2PDHT (0), - m_RemoteMetadataSize (0), m_IsFast (false), m_SuggestedPieceIndex (-1), - m_Downloaded (0), m_Uploaded (0) + m_RemoteMsgIDUtMetadata (0), m_RemoteMsgIDI2PPEX (0), m_RemoteMetadataSize (0), + m_IsFast (false), m_SuggestedPieceIndex (-1), m_Downloaded (0), m_Uploaded (0) { ResetStats (); @@ -2159,9 +2158,4 @@ m_RemoteMsgIDI2PPEX = msgID; } - else if (extensionName == EXTENSION_NAME_I2P_DHT) - { - m_ExtendedMessageHandlers.emplace (EXTENSION_MSGID_I2P_DHT, &PeerConnection::HandleI2PDHTExtension); - m_RemoteMsgIDI2PDHT = msgID; - } } @@ -2312,28 +2306,4 @@ } - void PeerConnection::HandleI2PDHTExtension (const uint8_t * buf, size_t len) - { - uint16_t port = 0, rport = 0; - ParseDictionary (std::string_view ((const char *)buf, len), - [&port, &rport](std::string_view key, std::string_view buf)->size_t - { - if (key == "port") - { - auto [value, l] = ExtractInteger (buf); - if (l && value > 0 && value <= 65535) - port = value; - return l; - } - else if (key == "rport") - { - auto [value, l] = ExtractInteger (buf); - if (l && value > 0 && value <= 65535) - rport = value; - return l; - } - return 0; - }); - } - void PeerConnection::NotifyPEXPeers () { diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/Torrents.h /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/Torrents.h --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/Torrents.h 2026-09-22 01:06:18.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/Torrents.h 2026-09-22 00:23:01.000000000 +0000 @@ -77,6 +77,4 @@ constexpr std::string_view EXTENSION_NAME_I2P_PEX { "i2p_pex" }; constexpr uint8_t EXTENSION_MSGID_I2P_PEX = 2; - constexpr std::string_view EXTENSION_NAME_I2P_DHT { "i2p_dht" }; - constexpr uint8_t EXTENSION_MSGID_I2P_DHT = 3; enum MessageType @@ -428,5 +426,4 @@ void HandleI2PPEXExtension (const uint8_t * buf, size_t len); // BEP11 void NotifyPEXPeers (); // BEP11 - void HandleI2PDHTExtension (const uint8_t * buf, size_t len); // BEP5 std::optional GetNextBlockToRequest (); @@ -454,5 +451,5 @@ // BEP10 std::unordered_map m_ExtendedMessageHandlers; - uint8_t m_RemoteMsgIDUtMetadata, m_RemoteMsgIDI2PPEX, m_RemoteMsgIDI2PDHT; + uint8_t m_RemoteMsgIDUtMetadata, m_RemoteMsgIDI2PPEX; // BEP9 size_t m_RemoteMetadataSize; diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsDHT.cpp /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsDHT.cpp --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsDHT.cpp 2026-09-22 01:06:18.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsDHT.cpp 2026-09-22 00:23:01.000000000 +0000 @@ -18,18 +18,16 @@ namespace torrents { - std::optional Bucket::GetMiddleID () const + NodeID Bucket::GetMiddleID () const { - uint8_t bit = std::max (start.FindLowestBit (), next ? next->start.FindLowestBit () : -1) + 1; - if (bit >= NodeID::len * 8) return {}; NodeID middleID = start; + int bit = std::max (start.FindLowestBit (), next ? next->start.FindLowestBit () : -1) + 1; middleID[bit >> 3] |= (0x80 >> (bit & 0x07)); - return { middleID }; + return middleID; } - bool Bucket::Split () + void Bucket::Split () { auto middleID = GetMiddleID (); - if (!middleID) return false; - auto newBucket = new Bucket (*middleID); + auto newBucket = new Bucket (middleID); newBucket->next = next; next = newBucket; @@ -38,5 +36,5 @@ while (it != nodes.end ()) { - if ((*it)->id < *middleID) + if ((*it)->id < middleID) it++; // stay in old bucket else @@ -48,5 +46,4 @@ } } - return true; } @@ -108,16 +105,14 @@ auto bucket = FindBucket (id); if (!bucket) return nullptr; - if (bucket->IsFull ()) + if (bucket->IsFull () && !bucket->IsInBucket (m_OurNode)) return nullptr; + + std::shared_ptr node; + do { - if (!bucket->IsInBucket (m_OurNode)) return nullptr; - do - { - if (!bucket->Split ()) return nullptr; - bucket = FindBucket (id); - } - while (bucket->IsFull ()); + bucket->Split (); + bucket = FindBucket (id); } + while (bucket->IsFull ()); - std::shared_ptr node; if (bucket) { diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsDHT.h /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsDHT.h --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsDHT.h 2026-09-22 01:06:18.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsDHT.h 2026-09-22 00:23:01.000000000 +0000 @@ -19,5 +19,4 @@ #include #include -#include #include "Identity.h" #include "I2PService.h" @@ -77,6 +76,6 @@ bool IsFull () const { return nodes.size () >= MAX_BUCKET_CAPACITY; } bool IsInBucket (const NodeID& id) const { return id >= start && (!next || id < next->start); } - std::optional GetMiddleID () const; - bool Split (); + NodeID GetMiddleID () const; + void Split (); };