1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Improve dht lookup in overlays (#1104)

Continue dht lookup even if value was found
This commit is contained in:
SpyCheese 2024-08-15 15:26:35 +03:00 committed by GitHub
parent 77a816e461
commit 9661676646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 127 additions and 35 deletions

View file

@ -470,7 +470,7 @@ void DhtMemberImpl::get_value_in(DhtKeyId key, td::Promise<DhtValue> result) {
network_id = network_id_, id = id_,
client_only = client_only_](td::Result<DhtNode> R) mutable {
R.ensure();
td::actor::create_actor<DhtQueryFindValue>("FindValueQuery", key, print_id, id, std::move(list), k, a, network_id,
td::actor::create_actor<DhtQueryFindValueSingle>("FindValueQuery", key, print_id, id, std::move(list), k, a, network_id,
R.move_as_ok(), client_only, SelfId, adnl, std::move(promise))
.release();
});
@ -478,6 +478,21 @@ void DhtMemberImpl::get_value_in(DhtKeyId key, td::Promise<DhtValue> result) {
get_self_node(std::move(P));
}
void DhtMemberImpl::get_value_many(DhtKey key, std::function<void(DhtValue)> callback, td::Promise<td::Unit> promise) {
DhtKeyId key_id = key.compute_key_id();
auto P = td::PromiseCreator::lambda(
[key = key_id, callback = std::move(callback), promise = std::move(promise), SelfId = actor_id(this),
print_id = print_id(), adnl = adnl_, list = get_nearest_nodes(key_id, k_ * 2), k = k_, a = a_,
network_id = network_id_, id = id_, client_only = client_only_](td::Result<DhtNode> R) mutable {
R.ensure();
td::actor::create_actor<DhtQueryFindValueMany>("FindValueManyQuery", key, print_id, id, std::move(list), k, a,
network_id, R.move_as_ok(), client_only, SelfId, adnl,
std::move(callback), std::move(promise))
.release();
});
get_self_node(std::move(P));
}
void DhtMemberImpl::register_reverse_connection(adnl::AdnlNodeIdFull client, td::Promise<td::Unit> promise) {
auto client_short = client.compute_short_id();
td::uint32 ttl = (td::uint32)td::Clocks::system() + 300;