This commit is contained in:
hinto.janai 2024-11-25 19:43:14 -05:00
parent 4f3b943b12
commit d85e9c814c
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
4 changed files with 39 additions and 26 deletions

View file

@ -14,13 +14,14 @@ use cuprate_rpc_types::json::{
GetCoinbaseTxSumRequest, GetCoinbaseTxSumResponse, GetConnectionsRequest, GetCoinbaseTxSumRequest, GetCoinbaseTxSumResponse, GetConnectionsRequest,
GetConnectionsResponse, GetFeeEstimateRequest, GetFeeEstimateResponse, GetInfoRequest, GetConnectionsResponse, GetFeeEstimateRequest, GetFeeEstimateResponse, GetInfoRequest,
GetInfoResponse, GetLastBlockHeaderRequest, GetLastBlockHeaderResponse, GetMinerDataRequest, GetInfoResponse, GetLastBlockHeaderRequest, GetLastBlockHeaderResponse, GetMinerDataRequest,
GetMinerDataResponse, GetOutputHistogramV2Request, GetOutputHistogramV2Response, GetMinerDataResponse, GetOutputDistributionV2Request, GetOutputDistributionV2Response,
GetTransactionPoolBacklogV2Request, GetTransactionPoolBacklogV2Response, GetTxIdsLooseRequest, GetOutputHistogramRequest, GetOutputHistogramResponse, GetTransactionPoolBacklogV2Request,
GetTxIdsLooseResponse, GetVersionRequest, GetVersionResponse, HardForkInfoRequest, GetTransactionPoolBacklogV2Response, GetTxIdsLooseRequest, GetTxIdsLooseResponse,
HardForkInfoResponse, JsonRpcRequest, JsonRpcResponse, OnGetBlockHashRequest, GetVersionRequest, GetVersionResponse, HardForkInfoRequest, HardForkInfoResponse,
OnGetBlockHashResponse, PruneBlockchainRequest, PruneBlockchainResponse, RelayTxRequest, JsonRpcRequest, JsonRpcResponse, OnGetBlockHashRequest, OnGetBlockHashResponse,
RelayTxResponse, SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, PruneBlockchainRequest, PruneBlockchainResponse, RelayTxRequest, RelayTxResponse,
SyncInfoRequest, SyncInfoResponse, SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest,
SyncInfoResponse,
}; };
use crate::rpc::CupratedRpcHandler; use crate::rpc::CupratedRpcHandler;
@ -60,8 +61,8 @@ pub(super) async fn map_request(
Req::FlushTransactionPool(r) => { Req::FlushTransactionPool(r) => {
Resp::FlushTransactionPool(flush_transaction_pool(state, r).await?) Resp::FlushTransactionPool(flush_transaction_pool(state, r).await?)
} }
Req::GetOutputHistogramV2(r) => { Req::GetOutputHistogram(r) => {
Resp::GetOutputHistogramV2(get_output_histogram_v2(state, r).await?) Resp::GetOutputHistogram(get_output_histogram(state, r).await?)
} }
Req::GetCoinbaseTxSum(r) => Resp::GetCoinbaseTxSum(get_coinbase_tx_sum(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?), Req::GetVersion(r) => Resp::GetVersion(get_version(state, r).await?),
@ -74,6 +75,9 @@ pub(super) async fn map_request(
Req::GetTransactionPoolBacklogV2(r) => { Req::GetTransactionPoolBacklogV2(r) => {
Resp::GetTransactionPoolBacklogV2(get_transaction_pool_backlog_v2(state, r).await?) 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::GetMinerData(r) => Resp::GetMinerData(get_miner_data(state, r).await?),
Req::PruneBlockchain(r) => Resp::PruneBlockchain(prune_blockchain(state, r).await?), Req::PruneBlockchain(r) => Resp::PruneBlockchain(prune_blockchain(state, r).await?),
Req::CalcPow(r) => Resp::CalcPow(calc_pow(state, r).await?), Req::CalcPow(r) => Resp::CalcPow(calc_pow(state, r).await?),
@ -195,10 +199,10 @@ async fn flush_transaction_pool(
todo!() todo!()
} }
async fn get_output_histogram_v2( async fn get_output_histogram(
state: CupratedRpcHandler, state: CupratedRpcHandler,
request: GetOutputHistogramV2Request, request: GetOutputHistogramRequest,
) -> Result<GetOutputHistogramV2Response, Error> { ) -> Result<GetOutputHistogramResponse, Error> {
todo!() todo!()
} }
@ -251,6 +255,13 @@ async fn get_transaction_pool_backlog_v2(
todo!() todo!()
} }
async fn get_output_distribution_v2(
state: CupratedRpcHandler,
request: GetOutputDistributionV2Request,
) -> Result<GetOutputDistributionV2Response, Error> {
todo!()
}
async fn get_miner_data( async fn get_miner_data(
state: CupratedRpcHandler, state: CupratedRpcHandler,
request: GetMinerDataRequest, request: GetMinerDataRequest,

View file

@ -75,7 +75,7 @@ impl Service<JsonRpcRequest> for RpcHandlerDummy {
Req::GetBans(_) => Resp::GetBans(Default::default()), Req::GetBans(_) => Resp::GetBans(Default::default()),
Req::Banned(_) => Resp::Banned(Default::default()), Req::Banned(_) => Resp::Banned(Default::default()),
Req::FlushTransactionPool(_) => Resp::FlushTransactionPool(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::GetCoinbaseTxSum(_) => Resp::GetCoinbaseTxSum(Default::default()),
Req::GetVersion(_) => Resp::GetVersion(Default::default()), Req::GetVersion(_) => Resp::GetVersion(Default::default()),
Req::GetFeeEstimate(_) => Resp::GetFeeEstimate(Default::default()), Req::GetFeeEstimate(_) => Resp::GetFeeEstimate(Default::default()),
@ -85,6 +85,7 @@ impl Service<JsonRpcRequest> for RpcHandlerDummy {
Req::GetTransactionPoolBacklogV2(_) => { Req::GetTransactionPoolBacklogV2(_) => {
Resp::GetTransactionPoolBacklogV2(Default::default()) Resp::GetTransactionPoolBacklogV2(Default::default())
} }
Req::GetOutputDistributionV2(_) => Resp::GetOutputDistributionV2(Default::default()),
Req::GetMinerData(_) => Resp::GetMinerData(Default::default()), Req::GetMinerData(_) => Resp::GetMinerData(Default::default()),
Req::PruneBlockchain(_) => Resp::PruneBlockchain(Default::default()), Req::PruneBlockchain(_) => Resp::PruneBlockchain(Default::default()),
Req::CalcPow(_) => Resp::CalcPow(Default::default()), Req::CalcPow(_) => Resp::CalcPow(Default::default()),

View file

@ -971,15 +971,14 @@ define_request_and_response! {
} }
} }
// TODO: update after finalizing <https://github.com/monero-project/monero/issues/9422>.
define_request_and_response! { define_request_and_response! {
get_output_histogram_v2, get_output_histogram,
cc73fe71162d564ffda8e549b79a350bca53c454 => cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2118..=2168, core_rpc_server_commands_defs.h => 2118..=2168,
GetOutputHistogramV2, GetOutputHistogram,
#[doc = serde_doc_test!( #[doc = serde_doc_test!(
GET_OUTPUT_HISTOGRAM_V2_REQUEST => GetOutputHistogramV2Request { GET_OUTPUT_HISTOGRAM_REQUEST => GetOutputHistogramRequest {
amounts: vec![20000000000], amounts: vec![20000000000],
min_count: 0, min_count: 0,
max_count: 0, max_count: 0,
@ -996,7 +995,7 @@ define_request_and_response! {
}, },
#[doc = serde_doc_test!( #[doc = serde_doc_test!(
GET_OUTPUT_HISTOGRAM_V2_RESPONSE => GetOutputHistogramV2Response { GET_OUTPUT_HISTOGRAM_RESPONSE => GetOutputHistogramResponse {
base: AccessResponseBase::OK, base: AccessResponseBase::OK,
histogram: vec![HistogramEntry { histogram: vec![HistogramEntry {
amount: 20000000000, amount: 20000000000,
@ -1385,7 +1384,6 @@ define_request_and_response! {
base: 0, base: 0,
distribution: vec![0, 1, 2], distribution: vec![0, 1, 2],
amount: 2628780000, amount: 2628780000,
binary: true,
})], })],
} }
)] )]
@ -1618,7 +1616,7 @@ pub enum JsonRpcRequest {
GetBans(GetBansRequest), GetBans(GetBansRequest),
Banned(BannedRequest), Banned(BannedRequest),
FlushTransactionPool(FlushTransactionPoolRequest), FlushTransactionPool(FlushTransactionPoolRequest),
GetOutputHistogramV2(GetOutputHistogramV2Request), GetOutputHistogram(GetOutputHistogramRequest),
GetCoinbaseTxSum(GetCoinbaseTxSumRequest), GetCoinbaseTxSum(GetCoinbaseTxSumRequest),
GetVersion(GetVersionRequest), GetVersion(GetVersionRequest),
GetFeeEstimate(GetFeeEstimateRequest), GetFeeEstimate(GetFeeEstimateRequest),
@ -1626,6 +1624,7 @@ pub enum JsonRpcRequest {
RelayTx(RelayTxRequest), RelayTx(RelayTxRequest),
SyncInfo(SyncInfoRequest), SyncInfo(SyncInfoRequest),
GetTransactionPoolBacklogV2(GetTransactionPoolBacklogV2Request), GetTransactionPoolBacklogV2(GetTransactionPoolBacklogV2Request),
GetOutputDistributionV2(GetOutputDistributionV2Request),
GetMinerData(GetMinerDataRequest), GetMinerData(GetMinerDataRequest),
PruneBlockchain(PruneBlockchainRequest), PruneBlockchain(PruneBlockchainRequest),
CalcPow(CalcPowRequest), CalcPow(CalcPowRequest),
@ -1647,10 +1646,11 @@ impl RpcCallValue for JsonRpcRequest {
Self::GetBlock(x) => x.is_restricted(), Self::GetBlock(x) => x.is_restricted(),
Self::GetInfo(x) => x.is_restricted(), Self::GetInfo(x) => x.is_restricted(),
Self::HardForkInfo(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::GetVersion(x) => x.is_restricted(),
Self::GetFeeEstimate(x) => x.is_restricted(), Self::GetFeeEstimate(x) => x.is_restricted(),
Self::GetTransactionPoolBacklogV2(x) => x.is_restricted(), Self::GetTransactionPoolBacklogV2(x) => x.is_restricted(),
Self::GetOutputDistributionV2(x) => x.is_restricted(),
Self::GetMinerData(x) => x.is_restricted(), Self::GetMinerData(x) => x.is_restricted(),
Self::AddAuxPow(x) => x.is_restricted(), Self::AddAuxPow(x) => x.is_restricted(),
Self::GetTxIdsLoose(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::GetBlock(x) => x.is_empty(),
Self::GetInfo(x) => x.is_empty(), Self::GetInfo(x) => x.is_empty(),
Self::HardForkInfo(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::GetVersion(x) => x.is_empty(),
Self::GetFeeEstimate(x) => x.is_empty(), Self::GetFeeEstimate(x) => x.is_empty(),
Self::GetTransactionPoolBacklogV2(x) => x.is_empty(), Self::GetTransactionPoolBacklogV2(x) => x.is_empty(),
Self::GetOutputDistributionV2(x) => x.is_empty(),
Self::GetMinerData(x) => x.is_empty(), Self::GetMinerData(x) => x.is_empty(),
Self::AddAuxPow(x) => x.is_empty(), Self::AddAuxPow(x) => x.is_empty(),
Self::GetTxIdsLoose(x) => x.is_empty(), Self::GetTxIdsLoose(x) => x.is_empty(),
@ -1750,7 +1751,7 @@ pub enum JsonRpcResponse {
GetBans(GetBansResponse), GetBans(GetBansResponse),
Banned(BannedResponse), Banned(BannedResponse),
FlushTransactionPool(FlushTransactionPoolResponse), FlushTransactionPool(FlushTransactionPoolResponse),
GetOutputHistogramV2(GetOutputHistogramV2Response), GetOutputHistogram(GetOutputHistogramResponse),
GetCoinbaseTxSum(GetCoinbaseTxSumResponse), GetCoinbaseTxSum(GetCoinbaseTxSumResponse),
GetVersion(GetVersionResponse), GetVersion(GetVersionResponse),
GetFeeEstimate(GetFeeEstimateResponse), GetFeeEstimate(GetFeeEstimateResponse),
@ -1758,6 +1759,7 @@ pub enum JsonRpcResponse {
RelayTx(RelayTxResponse), RelayTx(RelayTxResponse),
SyncInfo(SyncInfoResponse), SyncInfo(SyncInfoResponse),
GetTransactionPoolBacklogV2(GetTransactionPoolBacklogV2Response), GetTransactionPoolBacklogV2(GetTransactionPoolBacklogV2Response),
GetOutputDistributionV2(GetOutputDistributionV2Response),
GetMinerData(GetMinerDataResponse), GetMinerData(GetMinerDataResponse),
PruneBlockchain(PruneBlockchainResponse), PruneBlockchain(PruneBlockchainResponse),
CalcPow(CalcPowResponse), CalcPow(CalcPowResponse),

View file

@ -1118,9 +1118,8 @@ r#"{
"distributions": [{ "distributions": [{
"amount": 2628780000, "amount": 2628780000,
"base": 0, "base": 0,
"distribution": "", "distribution": [0, 1, 2],
"start_height": 1462078, "start_height": 1462078
"binary": false
}], }],
"status": "OK", "status": "OK",
"top_hash": "", "top_hash": "",