rpc_misc.rs 864 B

12345678910111213141516171819202122232425262728
  1. use serde_json::{json, Value};
  2. use darkfi::{
  3. rpc::jsonrpc::{JsonResponse, JsonResult},
  4. util::time::Timestamp,
  5. };
  6. use super::Darkfid;
  7. impl Darkfid {
  8. // RPCAPI:
  9. // Returns a `pong` to the `ping` request.
  10. //
  11. // --> {"jsonrpc": "2.0", "method": "ping", "params": [], "id": 1}
  12. // <-- {"jsonrpc": "2.0", "result": "pong", "id": 1}
  13. pub async fn misc_pong(&self, id: Value, _params: &[Value]) -> JsonResult {
  14. JsonResponse::new(json!("pong"), id).into()
  15. }
  16. // RPCAPI:
  17. // Returns current system clock in `Timestamp` format.
  18. //
  19. // --> {"jsonrpc": "2.0", "method": "clock", "params": [], "id": 1}
  20. // <-- {"jsonrpc": "2.0", "result": {...}, "id": 1}
  21. pub async fn misc_clock(&self, id: Value, _params: &[Value]) -> JsonResult {
  22. JsonResponse::new(json!(Timestamp::current_time()), id).into()
  23. }
  24. }