| 689 | } |
| 690 | |
| 691 | std::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 |
nothing calls this directly
no test coverage detected