use crate::client::Client;
use crate::command::request::request;
use crate::command::CallableCommand;
use crate::Blockhash;
use crate::BlockhashHexEncoded;
use serde::Deserialize;
use serde::Serialize;
use serde_json::value::{to_raw_value, RawValue};
pub struct GetChainTipsCommand {}
impl GetChainTipsCommand {
pub fn new() -> Self {
GetChainTipsCommand {}
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Tip {
height: u64, hash: String, branchlen: u64, status: String, }
#[derive(Serialize, Deserialize, Debug)]
pub struct GetChainTipsCommandResponse(Vec<Tip>);
impl CallableCommand for GetChainTipsCommand {
type Response = GetChainTipsCommandResponse;
fn call(&self, client: &Client) -> Result<Self::Response, jsonrpc::Error> {
let command = "getchaintips";
let params: Vec<Box<RawValue>> = vec![];
let r = request(client, command, params);
let response: GetChainTipsCommandResponse = r.result()?;
Ok(response)
}
}