From d85e9c814cb5d02eaff624682bb1a42146847b14 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Mon, 25 Nov 2024 19:43:14 -0500 Subject: [PATCH] fixes --- binaries/cuprated/src/rpc/json.rs | 35 +++++++++++++++++--------- rpc/interface/src/rpc_handler_dummy.rs | 3 ++- rpc/types/src/json.rs | 22 ++++++++-------- test-utils/src/rpc/data/json.rs | 5 ++-- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs index e377d45d..d7f43a70 100644 --- a/binaries/cuprated/src/rpc/json.rs +++ b/binaries/cuprated/src/rpc/json.rs @@ -14,13 +14,14 @@ use cuprate_rpc_types::json::{ GetCoinbaseTxSumRequest, GetCoinbaseTxSumResponse, GetConnectionsRequest, GetConnectionsResponse, GetFeeEstimateRequest, GetFeeEstimateResponse, GetInfoRequest, GetInfoResponse, GetLastBlockHeaderRequest, GetLastBlockHeaderResponse, GetMinerDataRequest, - GetMinerDataResponse, GetOutputHistogramV2Request, GetOutputHistogramV2Response, - GetTransactionPoolBacklogV2Request, GetTransactionPoolBacklogV2Response, GetTxIdsLooseRequest, - GetTxIdsLooseResponse, GetVersionRequest, GetVersionResponse, HardForkInfoRequest, - HardForkInfoResponse, JsonRpcRequest, JsonRpcResponse, OnGetBlockHashRequest, - OnGetBlockHashResponse, PruneBlockchainRequest, PruneBlockchainResponse, RelayTxRequest, - RelayTxResponse, SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, - SyncInfoRequest, SyncInfoResponse, + GetMinerDataResponse, GetOutputDistributionV2Request, GetOutputDistributionV2Response, + GetOutputHistogramRequest, GetOutputHistogramResponse, GetTransactionPoolBacklogV2Request, + GetTransactionPoolBacklogV2Response, GetTxIdsLooseRequest, GetTxIdsLooseResponse, + GetVersionRequest, GetVersionResponse, HardForkInfoRequest, HardForkInfoResponse, + JsonRpcRequest, JsonRpcResponse, OnGetBlockHashRequest, OnGetBlockHashResponse, + PruneBlockchainRequest, PruneBlockchainResponse, RelayTxRequest, RelayTxResponse, + SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest, + SyncInfoResponse, }; use crate::rpc::CupratedRpcHandler; @@ -60,8 +61,8 @@ pub(super) async fn map_request( Req::FlushTransactionPool(r) => { Resp::FlushTransactionPool(flush_transaction_pool(state, r).await?) } - Req::GetOutputHistogramV2(r) => { - Resp::GetOutputHistogramV2(get_output_histogram_v2(state, r).await?) + Req::GetOutputHistogram(r) => { + Resp::GetOutputHistogram(get_output_histogram(state, r).await?) } Req::GetCoinbaseTxSum(r) => Resp::GetCoinbaseTxSum(get_coinbase_tx_sum(state, r).await?), Req::GetVersion(r) => Resp::GetVersion(get_version(state, r).await?), @@ -74,6 +75,9 @@ pub(super) async fn map_request( Req::GetTransactionPoolBacklogV2(r) => { Resp::GetTransactionPoolBacklogV2(get_transaction_pool_backlog_v2(state, r).await?) } + Req::GetOutputDistributionV2(r) => { + Resp::GetOutputDistributionV2(get_output_distribution_v2(state, r).await?) + } Req::GetMinerData(r) => Resp::GetMinerData(get_miner_data(state, r).await?), Req::PruneBlockchain(r) => Resp::PruneBlockchain(prune_blockchain(state, r).await?), Req::CalcPow(r) => Resp::CalcPow(calc_pow(state, r).await?), @@ -195,10 +199,10 @@ async fn flush_transaction_pool( todo!() } -async fn get_output_histogram_v2( +async fn get_output_histogram( state: CupratedRpcHandler, - request: GetOutputHistogramV2Request, -) -> Result { + request: GetOutputHistogramRequest, +) -> Result { todo!() } @@ -251,6 +255,13 @@ async fn get_transaction_pool_backlog_v2( todo!() } +async fn get_output_distribution_v2( + state: CupratedRpcHandler, + request: GetOutputDistributionV2Request, +) -> Result { + todo!() +} + async fn get_miner_data( state: CupratedRpcHandler, request: GetMinerDataRequest, diff --git a/rpc/interface/src/rpc_handler_dummy.rs b/rpc/interface/src/rpc_handler_dummy.rs index 1ab4a30e..9a4e27a8 100644 --- a/rpc/interface/src/rpc_handler_dummy.rs +++ b/rpc/interface/src/rpc_handler_dummy.rs @@ -75,7 +75,7 @@ impl Service for RpcHandlerDummy { Req::GetBans(_) => Resp::GetBans(Default::default()), Req::Banned(_) => Resp::Banned(Default::default()), Req::FlushTransactionPool(_) => Resp::FlushTransactionPool(Default::default()), - Req::GetOutputHistogramV2(_) => Resp::GetOutputHistogramV2(Default::default()), + Req::GetOutputHistogram(_) => Resp::GetOutputHistogram(Default::default()), Req::GetCoinbaseTxSum(_) => Resp::GetCoinbaseTxSum(Default::default()), Req::GetVersion(_) => Resp::GetVersion(Default::default()), Req::GetFeeEstimate(_) => Resp::GetFeeEstimate(Default::default()), @@ -85,6 +85,7 @@ impl Service for RpcHandlerDummy { Req::GetTransactionPoolBacklogV2(_) => { Resp::GetTransactionPoolBacklogV2(Default::default()) } + Req::GetOutputDistributionV2(_) => Resp::GetOutputDistributionV2(Default::default()), Req::GetMinerData(_) => Resp::GetMinerData(Default::default()), Req::PruneBlockchain(_) => Resp::PruneBlockchain(Default::default()), Req::CalcPow(_) => Resp::CalcPow(Default::default()), diff --git a/rpc/types/src/json.rs b/rpc/types/src/json.rs index a07a6f3e..b80066d4 100644 --- a/rpc/types/src/json.rs +++ b/rpc/types/src/json.rs @@ -971,15 +971,14 @@ define_request_and_response! { } } -// TODO: update after finalizing . define_request_and_response! { - get_output_histogram_v2, + get_output_histogram, cc73fe71162d564ffda8e549b79a350bca53c454 => core_rpc_server_commands_defs.h => 2118..=2168, - GetOutputHistogramV2, + GetOutputHistogram, #[doc = serde_doc_test!( - GET_OUTPUT_HISTOGRAM_V2_REQUEST => GetOutputHistogramV2Request { + GET_OUTPUT_HISTOGRAM_REQUEST => GetOutputHistogramRequest { amounts: vec![20000000000], min_count: 0, max_count: 0, @@ -996,7 +995,7 @@ define_request_and_response! { }, #[doc = serde_doc_test!( - GET_OUTPUT_HISTOGRAM_V2_RESPONSE => GetOutputHistogramV2Response { + GET_OUTPUT_HISTOGRAM_RESPONSE => GetOutputHistogramResponse { base: AccessResponseBase::OK, histogram: vec![HistogramEntry { amount: 20000000000, @@ -1385,7 +1384,6 @@ define_request_and_response! { base: 0, distribution: vec![0, 1, 2], amount: 2628780000, - binary: true, })], } )] @@ -1618,7 +1616,7 @@ pub enum JsonRpcRequest { GetBans(GetBansRequest), Banned(BannedRequest), FlushTransactionPool(FlushTransactionPoolRequest), - GetOutputHistogramV2(GetOutputHistogramV2Request), + GetOutputHistogram(GetOutputHistogramRequest), GetCoinbaseTxSum(GetCoinbaseTxSumRequest), GetVersion(GetVersionRequest), GetFeeEstimate(GetFeeEstimateRequest), @@ -1626,6 +1624,7 @@ pub enum JsonRpcRequest { RelayTx(RelayTxRequest), SyncInfo(SyncInfoRequest), GetTransactionPoolBacklogV2(GetTransactionPoolBacklogV2Request), + GetOutputDistributionV2(GetOutputDistributionV2Request), GetMinerData(GetMinerDataRequest), PruneBlockchain(PruneBlockchainRequest), CalcPow(CalcPowRequest), @@ -1647,10 +1646,11 @@ impl RpcCallValue for JsonRpcRequest { Self::GetBlock(x) => x.is_restricted(), Self::GetInfo(x) => x.is_restricted(), Self::HardForkInfo(x) => x.is_restricted(), - Self::GetOutputHistogramV2(x) => x.is_restricted(), + Self::GetOutputHistogram(x) => x.is_restricted(), Self::GetVersion(x) => x.is_restricted(), Self::GetFeeEstimate(x) => x.is_restricted(), Self::GetTransactionPoolBacklogV2(x) => x.is_restricted(), + Self::GetOutputDistributionV2(x) => x.is_restricted(), Self::GetMinerData(x) => x.is_restricted(), Self::AddAuxPow(x) => x.is_restricted(), Self::GetTxIdsLoose(x) => x.is_restricted(), @@ -1682,10 +1682,11 @@ impl RpcCallValue for JsonRpcRequest { Self::GetBlock(x) => x.is_empty(), Self::GetInfo(x) => x.is_empty(), Self::HardForkInfo(x) => x.is_empty(), - Self::GetOutputHistogramV2(x) => x.is_empty(), + Self::GetOutputHistogram(x) => x.is_empty(), Self::GetVersion(x) => x.is_empty(), Self::GetFeeEstimate(x) => x.is_empty(), Self::GetTransactionPoolBacklogV2(x) => x.is_empty(), + Self::GetOutputDistributionV2(x) => x.is_empty(), Self::GetMinerData(x) => x.is_empty(), Self::AddAuxPow(x) => x.is_empty(), Self::GetTxIdsLoose(x) => x.is_empty(), @@ -1750,7 +1751,7 @@ pub enum JsonRpcResponse { GetBans(GetBansResponse), Banned(BannedResponse), FlushTransactionPool(FlushTransactionPoolResponse), - GetOutputHistogramV2(GetOutputHistogramV2Response), + GetOutputHistogram(GetOutputHistogramResponse), GetCoinbaseTxSum(GetCoinbaseTxSumResponse), GetVersion(GetVersionResponse), GetFeeEstimate(GetFeeEstimateResponse), @@ -1758,6 +1759,7 @@ pub enum JsonRpcResponse { RelayTx(RelayTxResponse), SyncInfo(SyncInfoResponse), GetTransactionPoolBacklogV2(GetTransactionPoolBacklogV2Response), + GetOutputDistributionV2(GetOutputDistributionV2Response), GetMinerData(GetMinerDataResponse), PruneBlockchain(PruneBlockchainResponse), CalcPow(CalcPowResponse), diff --git a/test-utils/src/rpc/data/json.rs b/test-utils/src/rpc/data/json.rs index 36c10f5a..b37d644a 100644 --- a/test-utils/src/rpc/data/json.rs +++ b/test-utils/src/rpc/data/json.rs @@ -1118,9 +1118,8 @@ r#"{ "distributions": [{ "amount": 2628780000, "base": 0, - "distribution": "", - "start_height": 1462078, - "binary": false + "distribution": [0, 1, 2], + "start_height": 1462078 }], "status": "OK", "top_hash": "",