diff --git a/binaries/cuprated/src/rpc/bin.rs b/binaries/cuprated/src/rpc/bin.rs index 60d92c12..5cf7a11f 100644 --- a/binaries/cuprated/src/rpc/bin.rs +++ b/binaries/cuprated/src/rpc/bin.rs @@ -35,6 +35,7 @@ pub(super) async fn map_request( }) } +/// async fn get_blocks( state: CupratedRpcHandlerState, request: GetBlocksRequest, @@ -42,6 +43,7 @@ async fn get_blocks( todo!() } +/// async fn get_blocks_by_height( state: CupratedRpcHandlerState, request: GetBlocksByHeightRequest, @@ -49,6 +51,7 @@ async fn get_blocks_by_height( todo!() } +/// async fn get_hashes( state: CupratedRpcHandlerState, request: GetHashesRequest, @@ -56,6 +59,7 @@ async fn get_hashes( todo!() } +/// async fn get_output_indexes( state: CupratedRpcHandlerState, request: GetOutputIndexesRequest, @@ -63,6 +67,7 @@ async fn get_output_indexes( todo!() } +/// async fn get_outs( state: CupratedRpcHandlerState, request: GetOutsRequest, @@ -70,6 +75,7 @@ async fn get_outs( todo!() } +/// async fn get_transaction_pool_hashes( state: CupratedRpcHandlerState, request: GetTransactionPoolHashesRequest, @@ -77,6 +83,7 @@ async fn get_transaction_pool_hashes( todo!() } +/// async fn get_output_distribution( state: CupratedRpcHandlerState, request: GetOutputDistributionRequest, diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs index 2f4786f7..6bc0f7de 100644 --- a/binaries/cuprated/src/rpc/json.rs +++ b/binaries/cuprated/src/rpc/json.rs @@ -98,6 +98,7 @@ pub(super) async fn map_request( }) } +/// async fn get_block_count( mut state: CupratedRpcHandlerState, request: GetBlockCountRequest, @@ -108,6 +109,7 @@ async fn get_block_count( }) } +/// async fn on_get_block_hash( mut state: CupratedRpcHandlerState, request: OnGetBlockHashRequest, @@ -119,6 +121,7 @@ async fn on_get_block_hash( Ok(OnGetBlockHashResponse { block_hash }) } +/// async fn submit_block( state: CupratedRpcHandlerState, request: SubmitBlockRequest, @@ -129,6 +132,7 @@ async fn submit_block( }) } +/// async fn generate_blocks( state: CupratedRpcHandlerState, request: GenerateBlocksRequest, @@ -140,6 +144,7 @@ async fn generate_blocks( }) } +/// async fn get_last_block_header( mut state: CupratedRpcHandlerState, request: GetLastBlockHeaderRequest, @@ -153,6 +158,7 @@ async fn get_last_block_header( }) } +/// async fn get_block_header_by_hash( mut state: CupratedRpcHandlerState, request: GetBlockHeaderByHashRequest, @@ -169,14 +175,13 @@ async fn get_block_header_by_hash( fill_pow_hash: bool, ) -> Result { let hash = helper::hex_to_hash(hex)?; - let block = blockchain::block_by_hash(state, hash).await?; - let block_header = BlockHeader::from(&block); - + let (_, block_header) = helper::block_header_by_hash(state, hash, fill_pow_hash).await?; Ok(block_header) } let block_header = get(&mut state, request.hash, request.fill_pow_hash).await?; + // FIXME PERF: could make a `Vec` on await on all tasks at the same time. let mut block_headers = Vec::with_capacity(request.hashes.len()); for hash in request.hashes { let hash = get(&mut state, hash, request.fill_pow_hash).await?; @@ -190,19 +195,22 @@ async fn get_block_header_by_hash( }) } +/// async fn get_block_header_by_height( mut state: CupratedRpcHandlerState, request: GetBlockHeaderByHeightRequest, ) -> Result { helper::check_height(&mut state, request.height).await?; - let block = blockchain::block(&mut state, request.height).await?; + let (_, block_header) = + helper::block_header(&mut state, request.height, request.fill_pow_hash).await?; Ok(GetBlockHeaderByHeightResponse { base: AccessResponseBase::ok(), - block_header: BlockHeader::from(&block), + block_header, }) } +/// async fn get_block_headers_range( mut state: CupratedRpcHandlerState, request: GetBlockHeadersRangeRequest, @@ -249,6 +257,7 @@ async fn get_block_headers_range( }) } +/// async fn get_block( mut state: CupratedRpcHandlerState, request: GetBlockRequest, @@ -280,6 +289,7 @@ async fn get_block( }) } +/// async fn get_connections( state: CupratedRpcHandlerState, request: GetConnectionsRequest, @@ -290,6 +300,7 @@ async fn get_connections( }) } +/// async fn get_info( state: CupratedRpcHandlerState, request: GetInfoRequest, @@ -338,6 +349,7 @@ async fn get_info( }) } +/// async fn hard_fork_info( state: CupratedRpcHandlerState, request: HardForkInfoRequest, @@ -355,6 +367,7 @@ async fn hard_fork_info( }) } +/// async fn set_bans( state: CupratedRpcHandlerState, request: SetBansRequest, @@ -366,6 +379,7 @@ async fn set_bans( }) } +/// async fn get_bans( state: CupratedRpcHandlerState, request: GetBansRequest, @@ -376,6 +390,7 @@ async fn get_bans( }) } +/// async fn banned( state: CupratedRpcHandlerState, request: BannedRequest, @@ -387,6 +402,7 @@ async fn banned( }) } +/// async fn flush_transaction_pool( state: CupratedRpcHandlerState, request: FlushTransactionPoolRequest, @@ -395,6 +411,7 @@ async fn flush_transaction_pool( Ok(FlushTransactionPoolResponse { status: Status::Ok }) } +/// async fn get_output_histogram( state: CupratedRpcHandlerState, request: GetOutputHistogramRequest, @@ -405,6 +422,7 @@ async fn get_output_histogram( }) } +/// async fn get_coinbase_tx_sum( state: CupratedRpcHandlerState, request: GetCoinbaseTxSumRequest, @@ -420,6 +438,7 @@ async fn get_coinbase_tx_sum( }) } +/// async fn get_version( state: CupratedRpcHandlerState, request: GetVersionRequest, @@ -434,6 +453,7 @@ async fn get_version( }) } +/// async fn get_fee_estimate( state: CupratedRpcHandlerState, request: GetFeeEstimateRequest, @@ -446,6 +466,7 @@ async fn get_fee_estimate( }) } +/// async fn get_alternate_chains( state: CupratedRpcHandlerState, request: GetAlternateChainsRequest, @@ -456,6 +477,7 @@ async fn get_alternate_chains( }) } +/// async fn relay_tx( state: CupratedRpcHandlerState, request: RelayTxRequest, @@ -463,6 +485,7 @@ async fn relay_tx( Ok(RelayTxResponse { status: todo!() }) } +/// async fn sync_info( state: CupratedRpcHandlerState, request: SyncInfoRequest, @@ -478,6 +501,7 @@ async fn sync_info( }) } +/// async fn get_transaction_pool_backlog( state: CupratedRpcHandlerState, request: GetTransactionPoolBacklogRequest, @@ -488,6 +512,7 @@ async fn get_transaction_pool_backlog( }) } +/// async fn get_miner_data( state: CupratedRpcHandlerState, request: GetMinerDataRequest, @@ -505,6 +530,7 @@ async fn get_miner_data( }) } +/// async fn prune_blockchain( state: CupratedRpcHandlerState, request: PruneBlockchainRequest, @@ -516,6 +542,7 @@ async fn prune_blockchain( }) } +/// async fn calc_pow( state: CupratedRpcHandlerState, request: CalcPowRequest, @@ -523,6 +550,7 @@ async fn calc_pow( Ok(CalcPowResponse { pow_hash: todo!() }) } +/// async fn flush_cache( state: CupratedRpcHandlerState, request: FlushCacheRequest, @@ -534,6 +562,7 @@ async fn flush_cache( }) } +/// async fn add_aux_pow( state: CupratedRpcHandlerState, request: AddAuxPowRequest, @@ -548,6 +577,7 @@ async fn add_aux_pow( }) } +/// async fn get_tx_ids_loose( state: CupratedRpcHandlerState, request: GetTxIdsLooseRequest, diff --git a/binaries/cuprated/src/rpc/other.rs b/binaries/cuprated/src/rpc/other.rs index c0df3993..1e228822 100644 --- a/binaries/cuprated/src/rpc/other.rs +++ b/binaries/cuprated/src/rpc/other.rs @@ -70,6 +70,7 @@ pub(super) async fn map_request( }) } +/// async fn get_height( state: CupratedRpcHandlerState, request: GetHeightRequest, @@ -77,6 +78,7 @@ async fn get_height( todo!() } +/// async fn get_transactions( state: CupratedRpcHandlerState, request: GetTransactionsRequest, @@ -84,6 +86,7 @@ async fn get_transactions( todo!() } +/// async fn get_alt_blocks_hashes( state: CupratedRpcHandlerState, request: GetAltBlocksHashesRequest, @@ -91,6 +94,7 @@ async fn get_alt_blocks_hashes( todo!() } +/// async fn is_key_image_spent( state: CupratedRpcHandlerState, request: IsKeyImageSpentRequest, @@ -98,6 +102,7 @@ async fn is_key_image_spent( todo!() } +/// async fn send_raw_transaction( state: CupratedRpcHandlerState, request: SendRawTransactionRequest, @@ -105,6 +110,7 @@ async fn send_raw_transaction( todo!() } +/// async fn start_mining( state: CupratedRpcHandlerState, request: StartMiningRequest, @@ -112,6 +118,7 @@ async fn start_mining( todo!() } +/// async fn stop_mining( state: CupratedRpcHandlerState, request: StopMiningRequest, @@ -119,6 +126,7 @@ async fn stop_mining( todo!() } +/// async fn mining_status( state: CupratedRpcHandlerState, request: MiningStatusRequest, @@ -126,6 +134,7 @@ async fn mining_status( todo!() } +/// async fn save_bc( state: CupratedRpcHandlerState, request: SaveBcRequest, @@ -133,6 +142,7 @@ async fn save_bc( todo!() } +/// async fn get_peer_list( state: CupratedRpcHandlerState, request: GetPeerListRequest, @@ -140,6 +150,7 @@ async fn get_peer_list( todo!() } +/// async fn set_log_hash_rate( state: CupratedRpcHandlerState, request: SetLogHashRateRequest, @@ -147,6 +158,7 @@ async fn set_log_hash_rate( todo!() } +/// async fn set_log_level( state: CupratedRpcHandlerState, request: SetLogLevelRequest, @@ -154,6 +166,7 @@ async fn set_log_level( todo!() } +/// async fn set_log_categories( state: CupratedRpcHandlerState, request: SetLogCategoriesRequest, @@ -161,6 +174,7 @@ async fn set_log_categories( todo!() } +/// async fn set_bootstrap_daemon( state: CupratedRpcHandlerState, request: SetBootstrapDaemonRequest, @@ -168,6 +182,7 @@ async fn set_bootstrap_daemon( todo!() } +/// async fn get_transaction_pool( state: CupratedRpcHandlerState, request: GetTransactionPoolRequest, @@ -175,6 +190,7 @@ async fn get_transaction_pool( todo!() } +/// async fn get_transaction_pool_stats( state: CupratedRpcHandlerState, request: GetTransactionPoolStatsRequest, @@ -182,6 +198,7 @@ async fn get_transaction_pool_stats( todo!() } +/// async fn stop_daemon( state: CupratedRpcHandlerState, request: StopDaemonRequest, @@ -189,6 +206,7 @@ async fn stop_daemon( todo!() } +/// async fn get_limit( state: CupratedRpcHandlerState, request: GetLimitRequest, @@ -196,6 +214,7 @@ async fn get_limit( todo!() } +/// async fn set_limit( state: CupratedRpcHandlerState, request: SetLimitRequest, @@ -203,6 +222,7 @@ async fn set_limit( todo!() } +/// async fn out_peers( state: CupratedRpcHandlerState, request: OutPeersRequest, @@ -210,6 +230,7 @@ async fn out_peers( todo!() } +/// async fn in_peers( state: CupratedRpcHandlerState, request: InPeersRequest, @@ -217,6 +238,7 @@ async fn in_peers( todo!() } +/// async fn get_net_stats( state: CupratedRpcHandlerState, request: GetNetStatsRequest, @@ -224,6 +246,7 @@ async fn get_net_stats( todo!() } +/// async fn get_outs( state: CupratedRpcHandlerState, request: GetOutsRequest, @@ -231,6 +254,7 @@ async fn get_outs( todo!() } +/// async fn update( state: CupratedRpcHandlerState, request: UpdateRequest, @@ -238,6 +262,7 @@ async fn update( todo!() } +/// async fn pop_blocks( state: CupratedRpcHandlerState, request: PopBlocksRequest, @@ -245,6 +270,7 @@ async fn pop_blocks( todo!() } +/// async fn get_transaction_pool_hashes( state: CupratedRpcHandlerState, request: GetTransactionPoolHashesRequest, @@ -252,6 +278,7 @@ async fn get_transaction_pool_hashes( todo!() } +/// async fn get_public_nodes( state: CupratedRpcHandlerState, request: GetPublicNodesRequest,