diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs index a370156f..883a8334 100644 --- a/binaries/cuprated/src/rpc/json.rs +++ b/binaries/cuprated/src/rpc/json.rs @@ -38,7 +38,7 @@ use cuprate_rpc_types::{ SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest, SyncInfoResponse, }, - misc::{BlockHeader, GetBan, Status}, + misc::{BlockHeader, GetBan, HistogramEntry, Status}, CORE_RPC_VERSION, }; @@ -512,12 +512,31 @@ async fn flush_transaction_pool( /// async fn get_output_histogram( - state: CupratedRpcHandler, + mut state: CupratedRpcHandler, request: GetOutputHistogramRequest, ) -> Result { + let input = cuprate_types::OutputHistogramInput { + amounts: request.amounts, + min_count: request.min_count, + max_count: request.max_count, + unlocked: request.unlocked, + recent_cutoff: request.recent_cutoff, + }; + + let histogram = blockchain::output_histogram(&mut state.blockchain_read, input) + .await? + .into_iter() + .map(|entry| HistogramEntry { + amount: entry.amount, + total_instances: entry.total_instances, + unlocked_instances: entry.unlocked_instances, + recent_instances: entry.recent_instances, + }) + .collect(); + Ok(GetOutputHistogramResponse { base: AccessResponseBase::ok(), - histogram: todo!(), + histogram, }) }