Skip to content

Commit 61804f2

Browse files
committed
[DHT] Use put signed bytes instead of put immutable
1 parent b036649 commit 61804f2

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/dht/session.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,25 @@ namespace DHT {
9797
sig = sign.bytes;
9898
}
9999

100+
void put_signed_bytes
101+
(
102+
libtorrent::entry& e
103+
,std::array<char, 64>& sig
104+
,std::int64_t& seq
105+
,std::string const& salt
106+
,std::array<char, 32> const& pk
107+
,std::array<char, 64> const& signature
108+
,libtorrent::entry const& entry
109+
,std::int64_t const& iSeq
110+
)
111+
{
112+
using dht::sign_mutable_item;
113+
e = entry;
114+
seq = iSeq;
115+
sig = signature;
116+
LogPrintf("%s --\nSalt = %s\nSequence = %d, e = %s\n", __func__, salt, seq, e.to_string());
117+
}
118+
100119
void CleanUpPutBuffer()
101120
{
102121
uint32_t nCurrentTimeStamp = GetAdjustedTime();
@@ -249,7 +268,12 @@ void ReannounceEntries()
249268
if (randomMutableItem.vchSalt.size() > 0 && ConvertMutableEntry(randomMutableItem, mut_item)) {
250269
size_t thread = fMultiThreads ? nThreads -1 : 0;
251270
libtorrent::sha1_hash infohash(randomMutableItem.InfoHash().c_str());
252-
arraySessions[thread].second->Session->dht_put_item(mut_item);
271+
std::array<char, ED25519_PUBLIC_KEY_BYTE_LENGTH> pubkey;
272+
aux::from_hex(randomMutableItem.PublicKey(), pubkey.data());
273+
std::array<char, ED25519_SIGTATURE_BYTE_LENGTH> signature_bytes;
274+
aux::from_hex(randomMutableItem.Signature(), signature_bytes.data());
275+
arraySessions[thread].second->Session->dht_put_item(pubkey, std::bind(&DHT::put_signed_bytes, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4,
276+
pubkey, signature_bytes, mut_item, randomMutableItem.SequenceNumber), randomMutableItem.Salt());
253277
LogPrintf("%s -- Re-annoucing item infohash %s, entry \n%s\n", __func__, infohash.to_string(), mut_item.to_string());
254278
}
255279
}

0 commit comments

Comments
 (0)