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

Method http_charge

runners/client/ClientRunner.cpp:691–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

689}
690
691std::string ClientRunner::http_charge(const std::string &proxy_sc_address) {
692 auto it2 = proxies_.find(proxy_sc_address);
693 if (it2 == proxies_.end()) {
694 return wrap_short_answer_to_http("proxy not found");
695 }
696
697 auto &proxy = *it2->second;
698
699 if (proxy.sc_request_running()) {
700 return wrap_short_answer_to_http("request is already running");
701 }
702
703 if (!proxy.exp_sc_is_inited()) {
704 return wrap_short_answer_to_http("proxy is not inited");
705 }
706
707 if (proxy.exp_sc_is_closed()) {
708 return wrap_short_answer_to_http("proxy is closed");
709 }
710
711 if (!proxy.can_charge()) {
712 return wrap_short_answer_to_http("nothing to charge");
713 }
714
715 auto msg = proxy.run_charge();
716 cocoon_wallet()->send_transaction(proxy.client_sc_address(), to_nano(0.7), {}, std::move(msg),
717 create_proxy_sc_request_promise(it2->second));
718
719 return wrap_short_answer_to_http("request sent");
720}
721
722} // namespace cocoon

Callers

nothing calls this directly

Calls 8

to_nanoFunction · 0.85
sc_request_runningMethod · 0.80
exp_sc_is_initedMethod · 0.80
exp_sc_is_closedMethod · 0.80
can_chargeMethod · 0.80
run_chargeMethod · 0.80
client_sc_addressMethod · 0.80
send_transactionMethod · 0.45

Tested by

no test coverage detected