@@ -126,16 +126,11 @@ class DhtQueryFindNodes : public DhtQuery {
126
126
};
127
127
128
128
class DhtQueryFindValue : public DhtQuery {
129
- private:
130
- td::Promise<DhtValue> promise_;
131
-
132
129
public:
133
130
DhtQueryFindValue (DhtKeyId key, DhtMember::PrintId print_id, adnl::AdnlNodeIdShort src, DhtNodesList list,
134
131
td::uint32 k, td::uint32 a, td::int32 our_network_id, DhtNode self, bool client_only,
135
- td::actor::ActorId<DhtMember> node, td::actor::ActorId<adnl::Adnl> adnl,
136
- td::Promise<DhtValue> promise)
137
- : DhtQuery(key, print_id, src, k, a, our_network_id, std::move(self), client_only, node, adnl)
138
- , promise_(std::move(promise)) {
132
+ td::actor::ActorId<DhtMember> node, td::actor::ActorId<adnl::Adnl> adnl)
133
+ : DhtQuery(key, print_id, src, k, a, our_network_id, std::move(self), client_only, node, adnl) {
139
134
add_nodes (std::move (list));
140
135
}
141
136
void send_one_query (adnl::AdnlNodeIdShort id) override ;
@@ -146,6 +141,48 @@ class DhtQueryFindValue : public DhtQuery {
146
141
std::string get_name () const override {
147
142
return " find value" ;
148
143
}
144
+
145
+ virtual bool on_value_found (DhtValue value) = 0;
146
+ };
147
+
148
+ class DhtQueryFindValueSingle : public DhtQueryFindValue {
149
+ public:
150
+ DhtQueryFindValueSingle (DhtKeyId key, DhtMember::PrintId print_id, adnl::AdnlNodeIdShort src, DhtNodesList list,
151
+ td::uint32 k, td::uint32 a, td::int32 our_network_id, DhtNode self, bool client_only,
152
+ td::actor::ActorId<DhtMember> node, td::actor::ActorId<adnl::Adnl> adnl,
153
+ td::Promise<DhtValue> promise)
154
+ : DhtQueryFindValue(key, print_id, src, std::move(list), k, a, our_network_id, std::move(self), client_only, node,
155
+ adnl)
156
+ , promise_(std::move(promise)) {
157
+ add_nodes (std::move (list));
158
+ }
159
+ bool on_value_found (DhtValue value) override ;
160
+ void tear_down () override ;
161
+
162
+ private:
163
+ td::Promise<DhtValue> promise_;
164
+ bool found_ = false ;
165
+ };
166
+
167
+ class DhtQueryFindValueMany : public DhtQueryFindValue {
168
+ public:
169
+ DhtQueryFindValueMany (DhtKeyId key, DhtMember::PrintId print_id, adnl::AdnlNodeIdShort src, DhtNodesList list,
170
+ td::uint32 k, td::uint32 a, td::int32 our_network_id, DhtNode self, bool client_only,
171
+ td::actor::ActorId<DhtMember> node, td::actor::ActorId<adnl::Adnl> adnl,
172
+ std::function<void (DhtValue)> callback, td::Promise<td::Unit> promise)
173
+ : DhtQueryFindValue(key, print_id, src, std::move(list), k, a, our_network_id, std::move(self), client_only, node,
174
+ adnl)
175
+ , callback_(std::move(callback))
176
+ , promise_(std::move(promise)) {
177
+ add_nodes (std::move (list));
178
+ }
179
+ bool on_value_found (DhtValue value) override ;
180
+ void tear_down () override ;
181
+
182
+ private:
183
+ std::function<void (DhtValue)> callback_;
184
+ td::Promise<td::Unit> promise_;
185
+ bool found_ = false ;
149
186
};
150
187
151
188
class DhtQueryStore : public td ::actor::Actor {
0 commit comments