mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 11:39:30 +00:00
/send_raw_transaction
, /save_bc
, response_base
This commit is contained in:
parent
d4b30333bb
commit
b3314d4981
6 changed files with 172 additions and 136 deletions
|
@ -110,7 +110,7 @@ async fn get_blocks(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GetBlocksResponse {
|
Ok(GetBlocksResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
blocks: todo!(),
|
blocks: todo!(),
|
||||||
start_height: todo!(),
|
start_height: todo!(),
|
||||||
current_height: todo!(),
|
current_height: todo!(),
|
||||||
|
@ -136,7 +136,7 @@ async fn get_blocks_by_height(
|
||||||
.collect::<Result<Vec<BlockCompleteEntry>, Error>>()?;
|
.collect::<Result<Vec<BlockCompleteEntry>, Error>>()?;
|
||||||
|
|
||||||
Ok(GetBlocksByHeightResponse {
|
Ok(GetBlocksByHeightResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
blocks,
|
blocks,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ async fn get_hashes(
|
||||||
let m_blocks_ids = bytes.split_off(index);
|
let m_blocks_ids = bytes.split_off(index);
|
||||||
|
|
||||||
Ok(GetHashesResponse {
|
Ok(GetHashesResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
m_blocks_ids,
|
m_blocks_ids,
|
||||||
start_height,
|
start_height,
|
||||||
current_height,
|
current_height,
|
||||||
|
@ -191,7 +191,7 @@ async fn get_output_indexes(
|
||||||
request: GetOutputIndexesRequest,
|
request: GetOutputIndexesRequest,
|
||||||
) -> Result<GetOutputIndexesResponse, Error> {
|
) -> Result<GetOutputIndexesResponse, Error> {
|
||||||
Ok(GetOutputIndexesResponse {
|
Ok(GetOutputIndexesResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ async fn get_outs(
|
||||||
request: GetOutsRequest,
|
request: GetOutsRequest,
|
||||||
) -> Result<GetOutsResponse, Error> {
|
) -> Result<GetOutsResponse, Error> {
|
||||||
Ok(GetOutsResponse {
|
Ok(GetOutsResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ async fn get_transaction_pool_hashes(
|
||||||
request: GetTransactionPoolHashesRequest,
|
request: GetTransactionPoolHashesRequest,
|
||||||
) -> Result<GetTransactionPoolHashesResponse, Error> {
|
) -> Result<GetTransactionPoolHashesResponse, Error> {
|
||||||
Ok(GetTransactionPoolHashesResponse {
|
Ok(GetTransactionPoolHashesResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ async fn get_output_distribution(
|
||||||
request: GetOutputDistributionRequest,
|
request: GetOutputDistributionRequest,
|
||||||
) -> Result<GetOutputDistributionResponse, Error> {
|
) -> Result<GetOutputDistributionResponse, Error> {
|
||||||
Ok(GetOutputDistributionResponse {
|
Ok(GetOutputDistributionResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ pub enum BlockchainManagerRequest {
|
||||||
Box<Block>,
|
Box<Block>,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
Sync,
|
||||||
|
|
||||||
/// Is the blockchain in the middle of syncing?
|
/// Is the blockchain in the middle of syncing?
|
||||||
///
|
///
|
||||||
/// This returning `false` does not necessarily
|
/// This returning `false` does not necessarily
|
||||||
|
@ -102,6 +105,7 @@ pub enum BlockchainManagerResponse {
|
||||||
/// Response to:
|
/// Response to:
|
||||||
/// - [`BlockchainManagerRequest::Prune`]
|
/// - [`BlockchainManagerRequest::Prune`]
|
||||||
/// - [`BlockchainManagerRequest::RelayBlock`]
|
/// - [`BlockchainManagerRequest::RelayBlock`]
|
||||||
|
/// - [`BlockchainManagerRequest::Sync`]
|
||||||
Ok,
|
Ok,
|
||||||
|
|
||||||
/// Response to [`BlockchainManagerRequest::PopBlocks`]
|
/// Response to [`BlockchainManagerRequest::PopBlocks`]
|
||||||
|
|
|
@ -11,7 +11,10 @@ use cuprate_helper::{
|
||||||
cast::{u64_to_usize, usize_to_u64},
|
cast::{u64_to_usize, usize_to_u64},
|
||||||
map::split_u128_into_low_high_bits,
|
map::split_u128_into_low_high_bits,
|
||||||
};
|
};
|
||||||
use cuprate_rpc_types::misc::BlockHeader;
|
use cuprate_rpc_types::{
|
||||||
|
base::{AccessResponseBase, ResponseBase},
|
||||||
|
misc::BlockHeader,
|
||||||
|
};
|
||||||
use cuprate_types::HardFork;
|
use cuprate_types::HardFork;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -166,3 +169,21 @@ pub(super) async fn top_height(state: &mut CupratedRpcHandler) -> Result<(u64, [
|
||||||
let height = chain_height.saturating_sub(1);
|
let height = chain_height.saturating_sub(1);
|
||||||
Ok((height, hash))
|
Ok((height, hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
pub const fn response_base(is_bootstrap: bool) -> ResponseBase {
|
||||||
|
if is_bootstrap {
|
||||||
|
ResponseBase::OK_UNTRUSTED
|
||||||
|
} else {
|
||||||
|
ResponseBase::OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
pub const fn access_response_base(is_bootstrap: bool) -> AccessResponseBase {
|
||||||
|
if is_bootstrap {
|
||||||
|
AccessResponseBase::OK_UNTRUSTED
|
||||||
|
} else {
|
||||||
|
AccessResponseBase::OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ async fn get_block_template(
|
||||||
let wide_difficulty = (difficulty, difficulty_top64).hex_prefix();
|
let wide_difficulty = (difficulty, difficulty_top64).hex_prefix();
|
||||||
|
|
||||||
Ok(GetBlockTemplateResponse {
|
Ok(GetBlockTemplateResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
blockhashing_blob,
|
blockhashing_blob,
|
||||||
blocktemplate_blob,
|
blocktemplate_blob,
|
||||||
difficulty_top64,
|
difficulty_top64,
|
||||||
|
@ -215,7 +215,7 @@ async fn get_block_count(
|
||||||
_: GetBlockCountRequest,
|
_: GetBlockCountRequest,
|
||||||
) -> Result<GetBlockCountResponse, Error> {
|
) -> Result<GetBlockCountResponse, Error> {
|
||||||
Ok(GetBlockCountResponse {
|
Ok(GetBlockCountResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
count: helper::top_height(&mut state).await?.0,
|
count: helper::top_height(&mut state).await?.0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ async fn submit_block(
|
||||||
blockchain_manager::relay_block(&mut state.blockchain_manager, Box::new(block)).await?;
|
blockchain_manager::relay_block(&mut state.blockchain_manager, Box::new(block)).await?;
|
||||||
|
|
||||||
Ok(SubmitBlockResponse {
|
Ok(SubmitBlockResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
block_id,
|
block_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ async fn generate_blocks(
|
||||||
let blocks = blocks.into_iter().map(Hex).collect();
|
let blocks = blocks.into_iter().map(Hex).collect();
|
||||||
|
|
||||||
Ok(GenerateBlocksResponse {
|
Ok(GenerateBlocksResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
blocks,
|
blocks,
|
||||||
height,
|
height,
|
||||||
})
|
})
|
||||||
|
@ -303,7 +303,7 @@ async fn get_last_block_header(
|
||||||
let block_header = helper::block_header(&mut state, height, request.fill_pow_hash).await?;
|
let block_header = helper::block_header(&mut state, height, request.fill_pow_hash).await?;
|
||||||
|
|
||||||
Ok(GetLastBlockHeaderResponse {
|
Ok(GetLastBlockHeaderResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
block_header,
|
block_header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ async fn get_block_header_by_hash(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GetBlockHeaderByHashResponse {
|
Ok(GetBlockHeaderByHashResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
block_header,
|
block_header,
|
||||||
block_headers,
|
block_headers,
|
||||||
})
|
})
|
||||||
|
@ -354,7 +354,7 @@ async fn get_block_header_by_height(
|
||||||
helper::block_header(&mut state, request.height, request.fill_pow_hash).await?;
|
helper::block_header(&mut state, request.height, request.fill_pow_hash).await?;
|
||||||
|
|
||||||
Ok(GetBlockHeaderByHeightResponse {
|
Ok(GetBlockHeaderByHeightResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
block_header,
|
block_header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ async fn get_block_headers_range(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GetBlockHeadersRangeResponse {
|
Ok(GetBlockHeadersRangeResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ async fn get_block(
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(GetBlockResponse {
|
Ok(GetBlockResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
blob,
|
blob,
|
||||||
json,
|
json,
|
||||||
miner_tx_hash,
|
miner_tx_hash,
|
||||||
|
@ -459,7 +459,7 @@ async fn get_connections(
|
||||||
let connections = address_book::connection_info::<ClearNet>(&mut DummyAddressBook).await?;
|
let connections = address_book::connection_info::<ClearNet>(&mut DummyAddressBook).await?;
|
||||||
|
|
||||||
Ok(GetConnectionsResponse {
|
Ok(GetConnectionsResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
connections,
|
connections,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ async fn get_info(
|
||||||
let wide_difficulty = format!("{:#x}", c.next_difficulty);
|
let wide_difficulty = format!("{:#x}", c.next_difficulty);
|
||||||
|
|
||||||
Ok(GetInfoResponse {
|
Ok(GetInfoResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
adjusted_time,
|
adjusted_time,
|
||||||
alt_blocks_count,
|
alt_blocks_count,
|
||||||
block_size_limit,
|
block_size_limit,
|
||||||
|
@ -617,7 +617,7 @@ async fn hard_fork_info(
|
||||||
let info = blockchain_context::hard_fork_info(&mut state.blockchain_context, hard_fork).await?;
|
let info = blockchain_context::hard_fork_info(&mut state.blockchain_context, hard_fork).await?;
|
||||||
|
|
||||||
Ok(HardForkInfoResponse {
|
Ok(HardForkInfoResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
earliest_height: info.earliest_height,
|
earliest_height: info.earliest_height,
|
||||||
enabled: info.enabled,
|
enabled: info.enabled,
|
||||||
state: info.state,
|
state: info.state,
|
||||||
|
@ -654,7 +654,7 @@ async fn set_bans(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(SetBansResponse {
|
Ok(SetBansResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ async fn get_bans(state: CupratedRpcHandler, _: GetBansRequest) -> Result<GetBan
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetBansResponse {
|
Ok(GetBansResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
bans,
|
bans,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -777,7 +777,7 @@ async fn get_output_histogram(
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetOutputHistogramResponse {
|
Ok(GetOutputHistogramResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
histogram,
|
histogram,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -800,7 +800,7 @@ async fn get_coinbase_tx_sum(
|
||||||
let wide_fee_amount = format!("{emission_amount:#x}");
|
let wide_fee_amount = format!("{emission_amount:#x}");
|
||||||
|
|
||||||
Ok(GetCoinbaseTxSumResponse {
|
Ok(GetCoinbaseTxSumResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
emission_amount,
|
emission_amount,
|
||||||
emission_amount_top64,
|
emission_amount_top64,
|
||||||
fee_amount,
|
fee_amount,
|
||||||
|
@ -835,7 +835,7 @@ async fn get_version(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GetVersionResponse {
|
Ok(GetVersionResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
version: CORE_RPC_VERSION,
|
version: CORE_RPC_VERSION,
|
||||||
release: RELEASE,
|
release: RELEASE,
|
||||||
current_height,
|
current_height,
|
||||||
|
@ -854,7 +854,7 @@ async fn get_fee_estimate(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(GetFeeEstimateResponse {
|
Ok(GetFeeEstimateResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
fee: estimate.fee,
|
fee: estimate.fee,
|
||||||
fees: estimate.fees,
|
fees: estimate.fees,
|
||||||
quantization_mask: estimate.quantization_mask,
|
quantization_mask: estimate.quantization_mask,
|
||||||
|
@ -873,7 +873,7 @@ async fn get_alternate_chains(
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetAlternateChainsResponse {
|
Ok(GetAlternateChainsResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
chains,
|
chains,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -925,7 +925,7 @@ async fn sync_info(
|
||||||
let overview = String::from(FIELD_NOT_SUPPORTED);
|
let overview = String::from(FIELD_NOT_SUPPORTED);
|
||||||
|
|
||||||
Ok(SyncInfoResponse {
|
Ok(SyncInfoResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
height,
|
height,
|
||||||
next_needed_pruning_seed,
|
next_needed_pruning_seed,
|
||||||
overview,
|
overview,
|
||||||
|
@ -951,7 +951,7 @@ async fn get_transaction_pool_backlog(
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetTransactionPoolBacklogResponse {
|
Ok(GetTransactionPoolBacklogResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
backlog,
|
backlog,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -984,7 +984,7 @@ async fn get_output_distribution(
|
||||||
}).collect::<Result<Vec<Distribution>, _>>()?;
|
}).collect::<Result<Vec<Distribution>, _>>()?;
|
||||||
|
|
||||||
Ok(GetOutputDistributionResponse {
|
Ok(GetOutputDistributionResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
distributions,
|
distributions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1015,7 +1015,7 @@ async fn get_miner_data(
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetMinerDataResponse {
|
Ok(GetMinerDataResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
major_version,
|
major_version,
|
||||||
height,
|
height,
|
||||||
prev_id,
|
prev_id,
|
||||||
|
@ -1038,7 +1038,7 @@ async fn prune_blockchain(
|
||||||
.compress();
|
.compress();
|
||||||
|
|
||||||
Ok(PruneBlockchainResponse {
|
Ok(PruneBlockchainResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
pruned,
|
pruned,
|
||||||
pruning_seed,
|
pruning_seed,
|
||||||
})
|
})
|
||||||
|
@ -1090,7 +1090,7 @@ async fn flush_cache(
|
||||||
// TODO: cuprated doesn't need this call; decide behavior.
|
// TODO: cuprated doesn't need this call; decide behavior.
|
||||||
|
|
||||||
Ok(FlushCacheResponse {
|
Ok(FlushCacheResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1288,7 +1288,7 @@ fn add_aux_pow_inner(
|
||||||
let aux_pow = aux_pow.into_vec();
|
let aux_pow = aux_pow.into_vec();
|
||||||
|
|
||||||
Ok(AddAuxPowResponse {
|
Ok(AddAuxPowResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
blocktemplate_blob,
|
blocktemplate_blob,
|
||||||
blockhashing_blob,
|
blockhashing_blob,
|
||||||
merkle_root,
|
merkle_root,
|
||||||
|
@ -1306,7 +1306,7 @@ async fn get_tx_ids_loose(
|
||||||
return Err(anyhow!("Not implemented"));
|
return Err(anyhow!("Not implemented"));
|
||||||
|
|
||||||
Ok(GetTxIdsLooseResponse {
|
Ok(GetTxIdsLooseResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
txids: todo!(),
|
txids: todo!(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
//! RPC request handler functions (other JSON endpoints).
|
//! RPC request handler functions (other JSON endpoints).
|
||||||
|
|
||||||
use std::collections::{BTreeSet, HashMap, HashSet};
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
|
collections::{BTreeSet, HashMap, HashSet},
|
||||||
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
|
|
||||||
|
@ -69,9 +72,6 @@ pub(super) async fn map_request(
|
||||||
Req::GetPeerList(r) => Resp::GetPeerList(get_peer_list(state, r).await?),
|
Req::GetPeerList(r) => Resp::GetPeerList(get_peer_list(state, r).await?),
|
||||||
Req::SetLogLevel(r) => Resp::SetLogLevel(set_log_level(state, r).await?),
|
Req::SetLogLevel(r) => Resp::SetLogLevel(set_log_level(state, r).await?),
|
||||||
Req::SetLogCategories(r) => Resp::SetLogCategories(set_log_categories(state, r).await?),
|
Req::SetLogCategories(r) => Resp::SetLogCategories(set_log_categories(state, r).await?),
|
||||||
Req::SetBootstrapDaemon(r) => {
|
|
||||||
Resp::SetBootstrapDaemon(set_bootstrap_daemon(state, r).await?)
|
|
||||||
}
|
|
||||||
Req::GetTransactionPool(r) => {
|
Req::GetTransactionPool(r) => {
|
||||||
Resp::GetTransactionPool(get_transaction_pool(state, r).await?)
|
Resp::GetTransactionPool(get_transaction_pool(state, r).await?)
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,8 @@ pub(super) async fn map_request(
|
||||||
Req::GetPublicNodes(r) => Resp::GetPublicNodes(get_public_nodes(state, r).await?),
|
Req::GetPublicNodes(r) => Resp::GetPublicNodes(get_public_nodes(state, r).await?),
|
||||||
|
|
||||||
// Unsupported requests.
|
// Unsupported requests.
|
||||||
Req::Update(_)
|
Req::SetBootstrapDaemon(_)
|
||||||
|
| Req::Update(_)
|
||||||
| Req::StartMining(_)
|
| Req::StartMining(_)
|
||||||
| Req::StopMining(_)
|
| Req::StopMining(_)
|
||||||
| Req::MiningStatus(_)
|
| Req::MiningStatus(_)
|
||||||
|
@ -103,13 +104,13 @@ pub(super) async fn map_request(
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L486-L499>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L486-L499>
|
||||||
async fn get_height(
|
async fn get_height(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetHeightRequest,
|
_: GetHeightRequest,
|
||||||
) -> Result<GetHeightResponse, Error> {
|
) -> Result<GetHeightResponse, Error> {
|
||||||
let (height, hash) = helper::top_height(&mut state).await?;
|
let (height, hash) = helper::top_height(&mut state).await?;
|
||||||
let hash = Hex(hash);
|
let hash = Hex(hash);
|
||||||
|
|
||||||
Ok(GetHeightResponse {
|
Ok(GetHeightResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
height,
|
height,
|
||||||
hash,
|
hash,
|
||||||
})
|
})
|
||||||
|
@ -254,7 +255,7 @@ async fn get_transactions(
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(GetTransactionsResponse {
|
Ok(GetTransactionsResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
txs_as_hex,
|
txs_as_hex,
|
||||||
txs_as_json,
|
txs_as_json,
|
||||||
missed_tx,
|
missed_tx,
|
||||||
|
@ -265,7 +266,7 @@ async fn get_transactions(
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L790-L815>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L790-L815>
|
||||||
async fn get_alt_blocks_hashes(
|
async fn get_alt_blocks_hashes(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetAltBlocksHashesRequest,
|
_: GetAltBlocksHashesRequest,
|
||||||
) -> Result<GetAltBlocksHashesResponse, Error> {
|
) -> Result<GetAltBlocksHashesResponse, Error> {
|
||||||
let blks_hashes = blockchain::alt_chains(&mut state.blockchain_read)
|
let blks_hashes = blockchain::alt_chains(&mut state.blockchain_read)
|
||||||
.await?
|
.await?
|
||||||
|
@ -274,7 +275,7 @@ async fn get_alt_blocks_hashes(
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(GetAltBlocksHashesResponse {
|
Ok(GetAltBlocksHashesResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
blks_hashes,
|
blks_hashes,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -321,7 +322,7 @@ async fn is_key_image_spent(
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(IsKeyImageSpentResponse {
|
Ok(IsKeyImageSpentResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
spent_status,
|
spent_status,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -332,7 +333,7 @@ async fn send_raw_transaction(
|
||||||
request: SendRawTransactionRequest,
|
request: SendRawTransactionRequest,
|
||||||
) -> Result<SendRawTransactionResponse, Error> {
|
) -> Result<SendRawTransactionResponse, Error> {
|
||||||
let mut resp = SendRawTransactionResponse {
|
let mut resp = SendRawTransactionResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
double_spend: false,
|
double_spend: false,
|
||||||
fee_too_low: false,
|
fee_too_low: false,
|
||||||
invalid_input: false,
|
invalid_input: false,
|
||||||
|
@ -354,20 +355,20 @@ async fn send_raw_transaction(
|
||||||
};
|
};
|
||||||
|
|
||||||
if request.do_sanity_checks {
|
if request.do_sanity_checks {
|
||||||
// FIXME: these checks could be defined elsewhere.
|
/// FIXME: these checks could be defined elsewhere.
|
||||||
//
|
///
|
||||||
// <https://github.com/monero-project/monero/blob/893916ad091a92e765ce3241b94e706ad012b62a/src/cryptonote_core/tx_sanity_check.cpp#L42>
|
/// <https://github.com/monero-project/monero/blob/893916ad091a92e765ce3241b94e706ad012b62a/src/cryptonote_core/tx_sanity_check.cpp#L42>
|
||||||
fn tx_sanity_check(tx: &Transaction, rct_outs_available: u64) -> Result<(), &'static str> {
|
fn tx_sanity_check(tx: &Transaction, rct_outs_available: u64) -> Result<(), String> {
|
||||||
let Some(input) = tx.prefix().inputs.get(0) else {
|
let Some(input) = tx.prefix().inputs.first() else {
|
||||||
return Err("No inputs");
|
return Err("No inputs".to_string());
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut rct_indices = BTreeSet::new();
|
let mut rct_indices = vec![];
|
||||||
let n_indices: usize = 0;
|
let mut n_indices: usize = 0;
|
||||||
|
|
||||||
for input in tx.prefix().inputs {
|
for input in &tx.prefix().inputs {
|
||||||
match input {
|
match input {
|
||||||
Input::Gen(_) => return Err("Transaction is coinbase"),
|
Input::Gen(_) => return Err("Transaction is coinbase".to_string()),
|
||||||
Input::ToKey {
|
Input::ToKey {
|
||||||
amount,
|
amount,
|
||||||
key_offsets,
|
key_offsets,
|
||||||
|
@ -377,8 +378,19 @@ async fn send_raw_transaction(
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <https://github.com/monero-project/monero/blob/893916ad091a92e765ce3241b94e706ad012b62a/src/cryptonote_basic/cryptonote_format_utils.cpp#L1526>
|
||||||
|
fn relative_output_offsets_to_absolute(mut offsets: Vec<u64>) -> Vec<u64> {
|
||||||
|
assert!(!offsets.is_empty());
|
||||||
|
|
||||||
|
for i in 1..offsets.len() {
|
||||||
|
offsets[i] += offsets[i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
offsets
|
||||||
|
}
|
||||||
|
|
||||||
n_indices += key_offsets.len();
|
n_indices += key_offsets.len();
|
||||||
let absolute = todo!();
|
let absolute = relative_output_offsets_to_absolute(key_offsets.clone());
|
||||||
rct_indices.extend(absolute);
|
rct_indices.extend(absolute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,13 +406,12 @@ async fn send_raw_transaction(
|
||||||
|
|
||||||
let rct_indices_len = rct_indices.len();
|
let rct_indices_len = rct_indices.len();
|
||||||
if rct_indices_len < n_indices * 8 / 10 {
|
if rct_indices_len < n_indices * 8 / 10 {
|
||||||
return Err("amount of unique indices is too low (amount of rct indices is {rct_indices_len} out of total {n_indices} indices.");
|
return Err(format!("amount of unique indices is too low (amount of rct indices is {rct_indices_len} out of total {n_indices} indices."));
|
||||||
}
|
}
|
||||||
|
|
||||||
let offsets = Vec::with_capacity(rct_indices_len);
|
let median = cuprate_helper::num::median(rct_indices);
|
||||||
let median = todo!();
|
|
||||||
if median < rct_outs_available * 6 / 10 {
|
if median < rct_outs_available * 6 / 10 {
|
||||||
return Err("median offset index is too low (median is {median} out of total {rct_outs_available} offsets). Transactions should contain a higher fraction of recent outputs.");
|
return Err(format!("median offset index is too low (median is {median} out of total {rct_outs_available} offsets). Transactions should contain a higher fraction of recent outputs."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -458,46 +469,10 @@ async fn send_raw_transaction(
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1413-L1462>
|
|
||||||
async fn start_mining(
|
|
||||||
state: CupratedRpcHandler,
|
|
||||||
request: StartMiningRequest,
|
|
||||||
) -> Result<StartMiningResponse, Error> {
|
|
||||||
unreachable!();
|
|
||||||
Ok(StartMiningResponse {
|
|
||||||
base: ResponseBase::OK,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1464-L1482>
|
|
||||||
async fn stop_mining(
|
|
||||||
state: CupratedRpcHandler,
|
|
||||||
request: StopMiningRequest,
|
|
||||||
) -> Result<StopMiningResponse, Error> {
|
|
||||||
unreachable!();
|
|
||||||
Ok(StopMiningResponse {
|
|
||||||
base: ResponseBase::OK,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1484-L1523>
|
|
||||||
async fn mining_status(
|
|
||||||
state: CupratedRpcHandler,
|
|
||||||
request: MiningStatusRequest,
|
|
||||||
) -> Result<MiningStatusResponse, Error> {
|
|
||||||
unreachable!();
|
|
||||||
Ok(MiningStatusResponse {
|
|
||||||
base: ResponseBase::OK,
|
|
||||||
..todo!()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1525-L1535>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1525-L1535>
|
||||||
async fn save_bc(
|
async fn save_bc(mut state: CupratedRpcHandler, _: SaveBcRequest) -> Result<SaveBcResponse, Error> {
|
||||||
state: CupratedRpcHandler,
|
blockchain_manager::sync(&mut state.blockchain_manager).await?;
|
||||||
request: SaveBcRequest,
|
|
||||||
) -> Result<SaveBcResponse, Error> {
|
|
||||||
todo!();
|
|
||||||
Ok(SaveBcResponse {
|
Ok(SaveBcResponse {
|
||||||
base: ResponseBase::OK,
|
base: ResponseBase::OK,
|
||||||
})
|
})
|
||||||
|
@ -509,7 +484,7 @@ async fn get_peer_list(
|
||||||
request: GetPeerListRequest,
|
request: GetPeerListRequest,
|
||||||
) -> Result<GetPeerListResponse, Error> {
|
) -> Result<GetPeerListResponse, Error> {
|
||||||
Ok(GetPeerListResponse {
|
Ok(GetPeerListResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -521,7 +496,7 @@ async fn set_log_hash_rate(
|
||||||
) -> Result<SetLogHashRateResponse, Error> {
|
) -> Result<SetLogHashRateResponse, Error> {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
Ok(SetLogHashRateResponse {
|
Ok(SetLogHashRateResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +507,7 @@ async fn set_log_level(
|
||||||
) -> Result<SetLogLevelResponse, Error> {
|
) -> Result<SetLogLevelResponse, Error> {
|
||||||
todo!();
|
todo!();
|
||||||
Ok(SetLogLevelResponse {
|
Ok(SetLogLevelResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,27 +517,18 @@ async fn set_log_categories(
|
||||||
request: SetLogCategoriesRequest,
|
request: SetLogCategoriesRequest,
|
||||||
) -> Result<SetLogCategoriesResponse, Error> {
|
) -> Result<SetLogCategoriesResponse, Error> {
|
||||||
Ok(SetLogCategoriesResponse {
|
Ok(SetLogCategoriesResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1758-L1778>
|
|
||||||
async fn set_bootstrap_daemon(
|
|
||||||
state: CupratedRpcHandler,
|
|
||||||
request: SetBootstrapDaemonRequest,
|
|
||||||
) -> Result<SetBootstrapDaemonResponse, Error> {
|
|
||||||
todo!();
|
|
||||||
Ok(SetBootstrapDaemonResponse { status: Status::Ok })
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1663-L1687>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1663-L1687>
|
||||||
async fn get_transaction_pool(
|
async fn get_transaction_pool(
|
||||||
state: CupratedRpcHandler,
|
state: CupratedRpcHandler,
|
||||||
request: GetTransactionPoolRequest,
|
request: GetTransactionPoolRequest,
|
||||||
) -> Result<GetTransactionPoolResponse, Error> {
|
) -> Result<GetTransactionPoolResponse, Error> {
|
||||||
Ok(GetTransactionPoolResponse {
|
Ok(GetTransactionPoolResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -573,7 +539,7 @@ async fn get_transaction_pool_stats(
|
||||||
request: GetTransactionPoolStatsRequest,
|
request: GetTransactionPoolStatsRequest,
|
||||||
) -> Result<GetTransactionPoolStatsResponse, Error> {
|
) -> Result<GetTransactionPoolStatsResponse, Error> {
|
||||||
Ok(GetTransactionPoolStatsResponse {
|
Ok(GetTransactionPoolStatsResponse {
|
||||||
base: AccessResponseBase::OK,
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -593,7 +559,7 @@ async fn get_limit(
|
||||||
request: GetLimitRequest,
|
request: GetLimitRequest,
|
||||||
) -> Result<GetLimitResponse, Error> {
|
) -> Result<GetLimitResponse, Error> {
|
||||||
Ok(GetLimitResponse {
|
Ok(GetLimitResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -604,7 +570,7 @@ async fn set_limit(
|
||||||
request: SetLimitRequest,
|
request: SetLimitRequest,
|
||||||
) -> Result<SetLimitResponse, Error> {
|
) -> Result<SetLimitResponse, Error> {
|
||||||
Ok(SetLimitResponse {
|
Ok(SetLimitResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -615,7 +581,7 @@ async fn out_peers(
|
||||||
request: OutPeersRequest,
|
request: OutPeersRequest,
|
||||||
) -> Result<OutPeersResponse, Error> {
|
) -> Result<OutPeersResponse, Error> {
|
||||||
Ok(OutPeersResponse {
|
Ok(OutPeersResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -626,7 +592,7 @@ async fn in_peers(
|
||||||
request: InPeersRequest,
|
request: InPeersRequest,
|
||||||
) -> Result<InPeersResponse, Error> {
|
) -> Result<InPeersResponse, Error> {
|
||||||
Ok(InPeersResponse {
|
Ok(InPeersResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -637,7 +603,7 @@ async fn get_net_stats(
|
||||||
request: GetNetStatsRequest,
|
request: GetNetStatsRequest,
|
||||||
) -> Result<GetNetStatsResponse, Error> {
|
) -> Result<GetNetStatsResponse, Error> {
|
||||||
Ok(GetNetStatsResponse {
|
Ok(GetNetStatsResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -678,22 +644,11 @@ async fn get_outs(
|
||||||
// TODO: check txpool
|
// TODO: check txpool
|
||||||
|
|
||||||
Ok(GetOutsResponse {
|
Ok(GetOutsResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
outs,
|
outs,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3139-L3240>
|
|
||||||
async fn update(
|
|
||||||
state: CupratedRpcHandler,
|
|
||||||
request: UpdateRequest,
|
|
||||||
) -> Result<UpdateResponse, Error> {
|
|
||||||
Ok(UpdateResponse {
|
|
||||||
base: ResponseBase::OK,
|
|
||||||
..todo!()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3242-L3252>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3242-L3252>
|
||||||
async fn pop_blocks(
|
async fn pop_blocks(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
|
@ -703,7 +658,7 @@ async fn pop_blocks(
|
||||||
blockchain_manager::pop_blocks(&mut state.blockchain_manager, request.nblocks).await?;
|
blockchain_manager::pop_blocks(&mut state.blockchain_manager, request.nblocks).await?;
|
||||||
|
|
||||||
Ok(PopBlocksResponse {
|
Ok(PopBlocksResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
height,
|
height,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -714,7 +669,7 @@ async fn get_transaction_pool_hashes(
|
||||||
request: GetTransactionPoolHashesRequest,
|
request: GetTransactionPoolHashesRequest,
|
||||||
) -> Result<GetTransactionPoolHashesResponse, Error> {
|
) -> Result<GetTransactionPoolHashesResponse, Error> {
|
||||||
Ok(GetTransactionPoolHashesResponse {
|
Ok(GetTransactionPoolHashesResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -725,7 +680,49 @@ async fn get_public_nodes(
|
||||||
request: GetPublicNodesRequest,
|
request: GetPublicNodesRequest,
|
||||||
) -> Result<GetPublicNodesResponse, Error> {
|
) -> Result<GetPublicNodesResponse, Error> {
|
||||||
Ok(GetPublicNodesResponse {
|
Ok(GetPublicNodesResponse {
|
||||||
base: ResponseBase::OK,
|
base: helper::response_base(false),
|
||||||
..todo!()
|
..todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Unsupported RPC calls
|
||||||
|
|
||||||
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1758-L1778>
|
||||||
|
async fn set_bootstrap_daemon(
|
||||||
|
state: CupratedRpcHandler,
|
||||||
|
request: SetBootstrapDaemonRequest,
|
||||||
|
) -> Result<SetBootstrapDaemonResponse, Error> {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3139-L3240>
|
||||||
|
async fn update(
|
||||||
|
state: CupratedRpcHandler,
|
||||||
|
request: UpdateRequest,
|
||||||
|
) -> Result<UpdateResponse, Error> {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1413-L1462>
|
||||||
|
async fn start_mining(
|
||||||
|
state: CupratedRpcHandler,
|
||||||
|
request: StartMiningRequest,
|
||||||
|
) -> Result<StartMiningResponse, Error> {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1464-L1482>
|
||||||
|
async fn stop_mining(
|
||||||
|
state: CupratedRpcHandler,
|
||||||
|
request: StopMiningRequest,
|
||||||
|
) -> Result<StopMiningResponse, Error> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L1484-L1523>
|
||||||
|
async fn mining_status(
|
||||||
|
state: CupratedRpcHandler,
|
||||||
|
request: MiningStatusRequest,
|
||||||
|
) -> Result<MiningStatusResponse, Error> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
|
@ -242,3 +242,17 @@ pub(crate) async fn create_block_template(
|
||||||
|
|
||||||
Ok(block_template)
|
Ok(block_template)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainManagerRequest::Sync`]
|
||||||
|
pub(crate) async fn sync(blockchain_manager: &mut BlockchainManagerHandle) -> Result<(), Error> {
|
||||||
|
let BlockchainManagerResponse::Ok = blockchain_manager
|
||||||
|
.ready()
|
||||||
|
.await?
|
||||||
|
.call(BlockchainManagerRequest::Sync)
|
||||||
|
.await?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue