| 132 | } |
| 133 | |
| 134 | void ClientProxyConnection::process_auth_answer(td::Result<td::BufferSlice> R) { |
| 135 | if (R.is_error()) { |
| 136 | fail_connection(R.move_as_error_prefix("auth unsuccessful: ")); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | auto R2 = fetch_tl_object<cocoon_api::client_AuthorizationWithProxy>(R.move_as_ok(), true); |
| 141 | if (R2.is_error()) { |
| 142 | fail_connection(R2.move_as_error_prefix("received incorrect auth answer from proxy: ")); |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | auto obj = R2.move_as_ok(); |
| 147 | |
| 148 | cocoon_api::downcast_call( |
| 149 | *obj, |
| 150 | td::overloaded( |
| 151 | [&](cocoon_api::client_authorizationWithProxySuccess &r) { |
| 152 | proxy_->process_signed_payment_data(*r.signed_payment_); |
| 153 | proxy_->update_tokens_committed_to_db(r.tokens_committed_to_db_); |
| 154 | proxy_->update_tokens_used(r.max_tokens_); |
| 155 | handshake_completed(); |
| 156 | LOG(DEBUG) << "connection " << connection_id() << ": handshake completed successfully"; |
| 157 | }, |
| 158 | [&](cocoon_api::client_authorizationWithProxyFailed &r) { |
| 159 | fail_connection(td::Status::Error(PSTRING() << "auth unsuccessfull: " << r.error_code_ << " " << r.error_)); |
| 160 | })); |
| 161 | } |
| 162 | |
| 163 | } // namespace cocoon |
no test coverage detected