use crate::command::CallableCommand;
use crate::Blockhash;
use crate::{client::Client, command::request::request};
use serde::{Deserialize, Serialize};
use serde_json::value::{to_raw_value, RawValue};
const GET_DIFFICULTY_COMMAND: &str = "getmininginfo";
pub struct GetMiningInfoCommand {}
#[derive(Serialize, Deserialize, Debug)]
pub struct GetMiningInfoCommandResponse {
pub blocks: u64, pub currentblockweight: Option<u64>, pub currentblocktx: Option<u64>, pub difficulty: f64, pub networkhashps: f64, pub pooledtx: u64, pub chain: String, pub warnings: String, }
impl GetMiningInfoCommand {
pub fn new() -> Self {
GetMiningInfoCommand {}
}
}
impl CallableCommand for GetMiningInfoCommand {
type Response = GetMiningInfoCommandResponse;
fn call(&self, client: &Client) -> Self::Response {
let params = vec![];
let r = request(client, GET_DIFFICULTY_COMMAND, params);
let response: GetMiningInfoCommandResponse = r.result().unwrap();
response
}
}