MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / custom_initialize

Method custom_initialize

runners/client/ClientRunner.cpp:172–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void ClientRunner::custom_initialize(td::Promise<td::Unit> promise) {
173 params_version_ = runner_config()->root_contract_config->params_version();
174 cocoon_wallet_initialize_wait_for_balance_and_get_seqno(
175 wallet_private_key_->as_octet_string(), owner_address_, min_wallet_balance(),
176 [self_id = actor_id(this), promise = std::move(promise)](td::Result<td::Unit> R) mutable {
177 if (R.is_error()) {
178 promise.set_error(R.move_as_error());
179 return;
180 }
181 promise.set_value(td::Unit());
182 });
183
184 register_custom_http_handler("/stats", [&](http::HttpCallback::RequestType request_type,
185 std::vector<std::pair<std::string, std::string>> headers, std::string path,
186 std::vector<std::pair<std::string, std::string>> args, std::string body,
187 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
188 http_send_static_answer(http_generate_main(), std::move(answer_callback));
189 });
190 register_custom_http_handler(
191 "/jsonstats",
192 [&](http::HttpCallback::RequestType request_type, std::vector<std::pair<std::string, std::string>> headers,
193 std::string path, std::vector<std::pair<std::string, std::string>> args, std::string body,
194 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
195 http_send_static_answer(http_generate_json_stats(), std::move(answer_callback), "application/json");
196 });
197 register_custom_http_handler(
198 "/request/charge",
199 [&](http::HttpCallback::RequestType request_type, std::vector<std::pair<std::string, std::string>> headers,
200 std::string path, std::vector<std::pair<std::string, std::string>> args, std::string body,
201 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
202 http_send_static_answer(http_charge(get_from_sorted_list(args, "proxy")), std::move(answer_callback));
203 });
204 register_custom_http_handler(
205 "/request/close",
206 [&](http::HttpCallback::RequestType request_type, std::vector<std::pair<std::string, std::string>> headers,
207 std::string path, std::vector<std::pair<std::string, std::string>> args, std::string body,
208 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
209 http_send_static_answer(http_close(get_from_sorted_list(args, "proxy")), std::move(answer_callback));
210 });
211 register_custom_http_handler(
212 "/request/topup",
213 [&](http::HttpCallback::RequestType request_type, std::vector<std::pair<std::string, std::string>> headers,
214 std::string path, std::vector<std::pair<std::string, std::string>> args, std::string body,
215 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
216 http_send_static_answer(http_top_up(get_from_sorted_list(args, "proxy")), std::move(answer_callback));
217 });
218 register_custom_http_handler(
219 "/request/withdraw",
220 [&](http::HttpCallback::RequestType request_type, std::vector<std::pair<std::string, std::string>> headers,
221 std::string path, std::vector<std::pair<std::string, std::string>> args, std::string body,
222 std::unique_ptr<http::HttpRequestCallback> answer_callback) {
223 http_send_static_answer(http_withdraw(get_from_sorted_list(args, "proxy")), std::move(answer_callback));
224 });
225 register_custom_http_handler(
226 "/request/debuglogentry",
227 [&](http::HttpCallback::RequestType request_type, std::vector<std::pair<std::string, std::string>> headers,
228 std::string path, std::vector<std::pair<std::string, std::string>> args, std::string body,
229 std::unique_ptr<http::HttpRequestCallback> answer_callback) {

Callers

nothing calls this directly

Calls 2

params_versionMethod · 0.80
set_errorMethod · 0.80

Tested by

no test coverage detected