Skip to content

Commit fdef9f2

Browse files
author
Gabriel Comte
committed
Implement serde_json::Value for BlockStatsFields
1 parent e0583c4 commit fdef9f2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

client/src/client.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,6 @@ pub trait RpcApi: Sized {
471471
height: u64,
472472
fields: &[json::BlockStatsFields],
473473
) -> Result<json::GetBlockStatsResultPartial> {
474-
let fields: Vec<String> = fields.iter().map(|field| field.to_string()).collect();
475-
476474
self.call("getblockstats", &[height.into(), fields.into()])
477475
}
478476

json/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ pub struct FeeRatePercentiles {
403403
pub fr_90th: Amount,
404404
}
405405

406+
#[derive(Clone)]
406407
pub enum BlockStatsFields {
407408
AverageFee,
408409
AverageFeeRate,
@@ -477,6 +478,12 @@ impl fmt::Display for BlockStatsFields {
477478
}
478479
}
479480

481+
impl From<BlockStatsFields> for serde_json::Value {
482+
fn from(bsf: BlockStatsFields) -> Self {
483+
Self::from(bsf.to_string())
484+
}
485+
}
486+
480487
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
481488
#[serde(rename_all = "camelCase")]
482489
pub struct GetMiningInfoResult {

0 commit comments

Comments
 (0)