Skip to content

Commit

Permalink
Implement serde_json::Value for BlockStatsFields
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Comte committed Nov 3, 2021
1 parent 7d570c9 commit 9fc141e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,6 @@ pub trait RpcApi: Sized {
height: u64,
fields: &[json::BlockStatsFields],
) -> Result<json::GetBlockStatsResultPartial> {
let fields: Vec<String> = fields.iter().map(|field| field.to_string()).collect();

self.call("getblockstats", &[height.into(), fields.into()])
}

Expand Down
7 changes: 7 additions & 0 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ pub struct FeeRatePercentiles {
pub fr_90th: Amount,
}

#[derive(Clone)]
pub enum BlockStatsFields {
AverageFee,
AverageFeeRate,
Expand Down Expand Up @@ -477,6 +478,12 @@ impl fmt::Display for BlockStatsFields {
}
}

impl From<BlockStatsFields> for serde_json::Value {
fn from(bsf: BlockStatsFields) -> Self {
Self::from(bsf.to_string())
}
}

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetMiningInfoResult {
Expand Down

0 comments on commit 9fc141e

Please sign in to comment.