bitcoind_request/command/
get_difficulty.rs1use crate::command::CallableCommand;
14use crate::{client::Client, command::request::request};
15use serde::{Deserialize, Serialize};
16
17const GET_DIFFICULTY_COMMAND: &str = "getdifficulty";
18
19pub struct GetDifficultyCommand {}
20impl GetDifficultyCommand {
21 pub fn new() -> Self {
22 GetDifficultyCommand {}
23 }
24}
25#[derive(Serialize, Deserialize, Debug)]
27pub struct GetDifficultyCommandResponse(pub f64);
28
29impl CallableCommand for GetDifficultyCommand {
30 type Response = GetDifficultyCommandResponse;
31 fn call(&self, client: &Client) -> Result<Self::Response, jsonrpc::Error> {
32 let params = vec![];
33 let r = request(client, GET_DIFFICULTY_COMMAND, params);
34 let response: GetDifficultyCommandResponse = r.result()?;
35 Ok(response)
36 }
37}