adapter.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Adapter class goes here
  2. //use crate::rpc::jsonserver::JsonRpcInterface;
  3. use std::sync::Arc;
  4. // Dummy adapter for now
  5. pub struct RpcAdapter {}
  6. impl RpcAdapter {
  7. pub fn new() -> Arc<Self> {
  8. Arc::new(Self {})
  9. }
  10. pub async fn get_info() {}
  11. pub async fn key_gen() {}
  12. pub async fn say_hello() {}
  13. pub async fn stop() {}
  14. }
  15. //let stop_send = self.stop_send.clone();
  16. //io.add_method("stop", move |_| {
  17. // let stop_send = stop_send.clone();
  18. // async move {
  19. // RpcAdapter::stop().await;
  20. // let _ = stop_send.send(()).await;
  21. // Ok(jsonrpc_core::Value::Null)
  22. // }
  23. //});
  24. //let stop_send = self.stop_send.clone();
  25. //pub async fn wait_for_quit(self: Arc<Self>) -> Result<()> {
  26. // Ok(self.stop_recv.recv().await?)
  27. //}
  28. //let self2 = self2.clone();
  29. //async move {
  30. // Ok(json!({
  31. // "started": *self2.started.lock().await,
  32. // "connections": self2.p2p.connections_count().await
  33. // }))
  34. //pub async fn serve(self: Arc<Self>, mut req: Request) ->
  35. // http_types::Result<Response> { info!("RPC serving {}", req.url());
  36. // let request = req.body_string().await?;
  37. // let mut res = Response::new(StatusCode::Ok);
  38. // res.insert_header("Content-Type", "text/plain");
  39. // res.set_body(response);
  40. // Ok(res)
  41. //}
  42. //pub async fn wait_for_quit(self: Arc<Self>) -> Result<()> {
  43. // Ok(self.stop_recv.recv().await?)
  44. //}