| 379 | } |
| 380 | |
| 381 | async fn datastore( |
| 382 | &self, |
| 383 | request: tonic::Request<pb::DatastoreRequest>, |
| 384 | ) -> Result<tonic::Response<pb::DatastoreResponse>, tonic::Status> { |
| 385 | let req = request.into_inner(); |
| 386 | let req: requests::DatastoreRequest = req.into(); |
| 387 | debug!("Client asked for datastore"); |
| 388 | trace!("datastore request: {:?}", req); |
| 389 | let mut rpc = ClnRpc::new(&self.rpc_path) |
| 390 | .await |
| 391 | .map_err(|e| Status::new(Code::Internal, e.to_string()))?; |
| 392 | let result = rpc.call(Request::Datastore(req)) |
| 393 | .await |
| 394 | .map_err(|e| Status::new( |
| 395 | Code::Unknown, |
| 396 | format!("Error calling method Datastore: {:?}", e)))?; |
| 397 | match result { |
| 398 | Response::Datastore(r) => { |
| 399 | trace!("datastore response: {:?}", r); |
| 400 | Ok(tonic::Response::new(r.into())) |
| 401 | }, |
| 402 | r => Err(Status::new( |
| 403 | Code::Internal, |
| 404 | format!( |
| 405 | "Unexpected result {:?} to method call Datastore", |
| 406 | r |
| 407 | ) |
| 408 | )), |
| 409 | } |
| 410 | |
| 411 | } |
| 412 | |
| 413 | async fn create_onion( |
| 414 | &self, |