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:
parent
77a816e461
commit
9661676646
8 changed files with 127 additions and 35 deletions
17
dht/dht.cpp
17
dht/dht.cpp
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue