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

Method check

runners/proxy/ProxyClientInfo.cpp:71–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71ClientCheckResult ProxyClientInfo::check() {
72 if (charging_now()) {
73 return ClientCheckResult::Ok;
74 }
75
76 if (is_closed()) {
77 if (running_queries() > 0) {
78 return ClientCheckResult::Ok;
79 }
80
81 return ClientCheckResult::Ok;
82 }
83
84 if (is_closing() && tokens_max() == tokens_committed_to_blockchain() && running_queries() == 0) {
85 runner_->client_charge(*this, true);
86 return ClientCheckResult::Ok;
87 } else {
88 auto delta = tokens_ready_to_charge();
89 if (delta == 0) {
90 return ClientCheckResult::Ok;
91 }
92 if (delta * runner_->price_per_token() >= runner_->min_client_charge_sum()) {
93 runner_->client_charge(*this, false);
94 return ClientCheckResult::Ok;
95 }
96 }
97
98 return ClientCheckResult::Ok;
99}
100
101ton::tl_object_ptr<cocoon_api::client_paymentStatus> ProxyClientInfo::serialize_payment_status() {
102 runner_->sign_client_payment(*this);

Callers

nothing calls this directly

Calls 3

client_chargeMethod · 0.80
min_client_charge_sumMethod · 0.80
price_per_tokenMethod · 0.45

Tested by

no test coverage detected