| 1237 | } |
| 1238 | |
| 1239 | void ProxyRunner::receive_query(TcpClient::ConnectionId connection_id, td::BufferSlice query, |
| 1240 | td::Promise<td::BufferSlice> promise) { |
| 1241 | auto magic = get_tl_magic(query); |
| 1242 | switch (magic) { |
| 1243 | case cocoon_api::client_connectToProxy::ID: |
| 1244 | case cocoon_api::client_authorizeWithProxyShort::ID: |
| 1245 | case cocoon_api::client_authorizeWithProxyLong::ID: { |
| 1246 | auto conn = static_cast<ProxyInboundConnection *>(get_connection(connection_id)); |
| 1247 | if (!conn || conn->connection_type() != ProxyInboundConnection::ConnectionType::Client) { |
| 1248 | return promise.set_error(td::Status::Error(ton::ErrorCode::protoviolation, "client connect() from non client")); |
| 1249 | } |
| 1250 | auto client_conn = static_cast<ProxyInboundClientConnection *>(conn); |
| 1251 | client_conn->receive_handshake_query(std::move(query), std::move(promise)); |
| 1252 | } break; |
| 1253 | case cocoon_api::client_updatePaymentStatus::ID: { |
| 1254 | auto conn = static_cast<ProxyInboundConnection *>(get_connection(connection_id)); |
| 1255 | if (!conn || conn->connection_type() != ProxyInboundConnection::ConnectionType::Client) { |
| 1256 | return promise.set_error(td::Status::Error(ton::ErrorCode::protoviolation, "client request from non client")); |
| 1257 | } |
| 1258 | if (!conn->handshake_is_completed()) { |
| 1259 | return promise.set_error( |
| 1260 | td::Status::Error(ton::ErrorCode::protoviolation, "client request from non-ready connection")); |
| 1261 | } |
| 1262 | promise.set_value(cocoon::serialize_tl_object( |
| 1263 | static_cast<ProxyInboundClientConnection *>(conn)->client_info()->serialize_payment_status(), true)); |
| 1264 | } break; |
| 1265 | case cocoon_api::worker_connectToProxy::ID: |
| 1266 | case cocoon_api::worker_compareBalanceWithProxy::ID: |
| 1267 | case cocoon_api::worker_extendedCompareBalanceWithProxy::ID: |
| 1268 | case cocoon_api::worker_proxyHandshakeComplete::ID: { |
| 1269 | auto conn = static_cast<ProxyInboundConnection *>(get_connection(connection_id)); |
| 1270 | if (!conn || conn->connection_type() != ProxyInboundConnection::ConnectionType::Worker) { |
| 1271 | return promise.set_error(td::Status::Error(ton::ErrorCode::protoviolation, "worker connect() from non worker")); |
| 1272 | } |
| 1273 | auto worker_conn = static_cast<ProxyInboundWorkerConnection *>(conn); |
| 1274 | worker_conn->receive_handshake_query(std::move(query), std::move(promise)); |
| 1275 | } break; |
| 1276 | case cocoon_api::worker_updatePaymentStatus::ID: { |
| 1277 | auto conn = static_cast<ProxyInboundConnection *>(get_connection(connection_id)); |
| 1278 | if (!conn || conn->connection_type() != ProxyInboundConnection::ConnectionType::Worker) { |
| 1279 | return promise.set_error(td::Status::Error(ton::ErrorCode::protoviolation, "worker request from non worker")); |
| 1280 | } |
| 1281 | if (!conn->handshake_is_completed()) { |
| 1282 | return promise.set_error( |
| 1283 | td::Status::Error(ton::ErrorCode::protoviolation, "worker request from non-ready connection")); |
| 1284 | } |
| 1285 | promise.set_value(cocoon::serialize_tl_object( |
| 1286 | static_cast<ProxyInboundWorkerConnection *>(conn)->worker_info()->serialize_payment_status(), true)); |
| 1287 | } break; |
| 1288 | case cocoon_api::client_getWorkerTypes::ID: { |
| 1289 | auto conn = static_cast<ProxyInboundConnection *>(get_connection(connection_id)); |
| 1290 | if (!conn || conn->connection_type() != ProxyInboundConnection::ConnectionType::Client || |
| 1291 | !conn->handshake_is_completed()) { |
| 1292 | return promise.set_error(td::Status::Error(ton::ErrorCode::protoviolation, "expected client connection")); |
| 1293 | } |
| 1294 | TRY_RESULT_PROMISE(promise, obj, fetch_tl_object<cocoon_api::client_getWorkerTypes>(std::move(query), true)); |
| 1295 | |
| 1296 | std::vector<ton::tl_object_ptr<cocoon_api::client_workerType>> r; |
nothing calls this directly
no test coverage detected