mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-23 03:59:37 +00:00
Compare commits
15 commits
8a3229b369
...
d7d8b3509e
Author | SHA1 | Date | |
---|---|---|---|
|
d7d8b3509e | ||
|
a10ed59201 | ||
|
2daf2555bb | ||
|
08b5ff2f05 | ||
|
294df3f163 | ||
|
1e0ab56a5e | ||
|
d7fef15cd6 | ||
|
1d435cc1f8 | ||
|
1a76934aac | ||
|
6af977f0a5 | ||
|
c7ae795837 | ||
|
37bcbb5ea0 | ||
|
f677b1ae2a | ||
|
50bd576bb1 | ||
|
9422c07cc8 |
18 changed files with 523 additions and 225 deletions
|
@ -4,6 +4,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use cuprate_consensus::BlockChainContextService;
|
use cuprate_consensus::BlockChainContextService;
|
||||||
|
use cuprate_pruning::PruningSeed;
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
use monero_serai::block::Block;
|
use monero_serai::block::Block;
|
||||||
use tower::Service;
|
use tower::Service;
|
||||||
|
@ -70,6 +71,9 @@ pub enum BlockchainManagerResponse {
|
||||||
/// Response to [`BlockchainManagerRequest::PopBlocks`]
|
/// Response to [`BlockchainManagerRequest::PopBlocks`]
|
||||||
PopBlocks { new_height: usize },
|
PopBlocks { new_height: usize },
|
||||||
|
|
||||||
|
/// Response to [`BlockchainManagerRequest::Prune`]
|
||||||
|
Prune(PruningSeed),
|
||||||
|
|
||||||
/// Response to [`BlockchainManagerRequest::Pruned`]
|
/// Response to [`BlockchainManagerRequest::Pruned`]
|
||||||
Pruned(bool),
|
Pruned(bool),
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use std::sync::Arc;
|
use std::{
|
||||||
|
sync::Arc,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use cuprate_types::HardFork;
|
use cuprate_p2p_core::{client::handshaker::builder::DummyAddressBook, ClearNet};
|
||||||
use monero_serai::block::Block;
|
use monero_serai::block::Block;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
|
@ -10,7 +13,10 @@ use cuprate_constants::{
|
||||||
build::RELEASE,
|
build::RELEASE,
|
||||||
rpc::{RESTRICTED_BLOCK_COUNT, RESTRICTED_BLOCK_HEADER_RANGE},
|
rpc::{RESTRICTED_BLOCK_COUNT, RESTRICTED_BLOCK_HEADER_RANGE},
|
||||||
};
|
};
|
||||||
use cuprate_helper::cast::u64_to_usize;
|
use cuprate_helper::{
|
||||||
|
cast::{u64_to_usize, usize_to_u64},
|
||||||
|
map::split_u128_into_low_high_bits,
|
||||||
|
};
|
||||||
use cuprate_rpc_interface::RpcHandler;
|
use cuprate_rpc_interface::RpcHandler;
|
||||||
use cuprate_rpc_types::{
|
use cuprate_rpc_types::{
|
||||||
base::{AccessResponseBase, ResponseBase},
|
base::{AccessResponseBase, ResponseBase},
|
||||||
|
@ -34,13 +40,14 @@ use cuprate_rpc_types::{
|
||||||
SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest,
|
SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest,
|
||||||
SyncInfoResponse,
|
SyncInfoResponse,
|
||||||
},
|
},
|
||||||
misc::{BlockHeader, Status},
|
misc::{BlockHeader, ChainInfo, GetBan, HardforkEntry, HistogramEntry, Status, TxBacklogEntry},
|
||||||
CORE_RPC_VERSION,
|
CORE_RPC_VERSION,
|
||||||
};
|
};
|
||||||
|
use cuprate_types::HardFork;
|
||||||
|
|
||||||
use crate::rpc::{
|
use crate::rpc::{
|
||||||
helper,
|
helper,
|
||||||
request::{blockchain, blockchain_context, blockchain_manager},
|
request::{address_book, blockchain, blockchain_context, blockchain_manager, txpool},
|
||||||
CupratedRpcHandler,
|
CupratedRpcHandler,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,7 +115,7 @@ async fn get_block_count(
|
||||||
request: GetBlockCountRequest,
|
request: GetBlockCountRequest,
|
||||||
) -> Result<GetBlockCountResponse, Error> {
|
) -> Result<GetBlockCountResponse, Error> {
|
||||||
Ok(GetBlockCountResponse {
|
Ok(GetBlockCountResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
count: helper::top_height(&mut state).await?.0,
|
count: helper::top_height(&mut state).await?.0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -141,7 +148,7 @@ async fn submit_block(
|
||||||
blockchain_manager::relay_block(&mut state.blockchain_manager, block).await?;
|
blockchain_manager::relay_block(&mut state.blockchain_manager, block).await?;
|
||||||
|
|
||||||
Ok(SubmitBlockResponse {
|
Ok(SubmitBlockResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
block_id,
|
block_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -152,7 +159,7 @@ async fn generate_blocks(
|
||||||
request: GenerateBlocksRequest,
|
request: GenerateBlocksRequest,
|
||||||
) -> Result<GenerateBlocksResponse, Error> {
|
) -> Result<GenerateBlocksResponse, Error> {
|
||||||
Ok(GenerateBlocksResponse {
|
Ok(GenerateBlocksResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
blocks: todo!(),
|
blocks: todo!(),
|
||||||
height: todo!(),
|
height: todo!(),
|
||||||
})
|
})
|
||||||
|
@ -167,7 +174,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: AccessResponseBase::OK,
|
||||||
block_header,
|
block_header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -203,7 +210,7 @@ async fn get_block_header_by_hash(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GetBlockHeaderByHashResponse {
|
Ok(GetBlockHeaderByHashResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
block_header,
|
block_header,
|
||||||
block_headers,
|
block_headers,
|
||||||
})
|
})
|
||||||
|
@ -219,7 +226,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: AccessResponseBase::OK,
|
||||||
block_header,
|
block_header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -267,7 +274,7 @@ async fn get_block_headers_range(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GetBlockHeadersRangeResponse {
|
Ok(GetBlockHeadersRangeResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -300,7 +307,7 @@ async fn get_block(
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(GetBlockResponse {
|
Ok(GetBlockResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
blob,
|
blob,
|
||||||
json,
|
json,
|
||||||
miner_tx_hash,
|
miner_tx_hash,
|
||||||
|
@ -314,9 +321,11 @@ async fn get_connections(
|
||||||
state: CupratedRpcHandler,
|
state: CupratedRpcHandler,
|
||||||
request: GetConnectionsRequest,
|
request: GetConnectionsRequest,
|
||||||
) -> Result<GetConnectionsResponse, Error> {
|
) -> Result<GetConnectionsResponse, Error> {
|
||||||
|
let connections = address_book::connection_info::<ClearNet>(&mut DummyAddressBook).await?;
|
||||||
|
|
||||||
Ok(GetConnectionsResponse {
|
Ok(GetConnectionsResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
connections: todo!(),
|
connections,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +335,7 @@ async fn get_info(
|
||||||
request: GetInfoRequest,
|
request: GetInfoRequest,
|
||||||
) -> Result<GetInfoResponse, Error> {
|
) -> Result<GetInfoResponse, Error> {
|
||||||
Ok(GetInfoResponse {
|
Ok(GetInfoResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
adjusted_time: todo!(),
|
adjusted_time: todo!(),
|
||||||
alt_blocks_count: todo!(),
|
alt_blocks_count: todo!(),
|
||||||
block_size_limit: todo!(),
|
block_size_limit: todo!(),
|
||||||
|
@ -377,20 +386,24 @@ async fn hard_fork_info(
|
||||||
let hard_fork = if request.version > 0 {
|
let hard_fork = if request.version > 0 {
|
||||||
HardFork::from_version(request.version)?
|
HardFork::from_version(request.version)?
|
||||||
} else {
|
} else {
|
||||||
// blockchain::current_hard_fork(&mut state).await?
|
blockchain_context::context(&mut state.blockchain_context)
|
||||||
todo!()
|
.await?
|
||||||
|
.unchecked_blockchain_context()
|
||||||
|
.current_hf
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let info = blockchain_context::hard_fork_info(&mut state.blockchain_context, hard_fork).await?;
|
||||||
|
|
||||||
Ok(HardForkInfoResponse {
|
Ok(HardForkInfoResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
earliest_height: todo!(),
|
earliest_height: info.earliest_height,
|
||||||
enabled: todo!("hard_fork.is_latest() is not always correct"),
|
enabled: info.enabled,
|
||||||
state: todo!(),
|
state: info.state,
|
||||||
threshold: todo!(),
|
threshold: info.threshold,
|
||||||
version: hard_fork.as_u8(),
|
version: info.version,
|
||||||
votes: todo!(),
|
votes: info.votes,
|
||||||
voting: todo!(),
|
voting: info.voting,
|
||||||
window: todo!(),
|
window: info.window,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,10 +412,22 @@ async fn set_bans(
|
||||||
state: CupratedRpcHandler,
|
state: CupratedRpcHandler,
|
||||||
request: SetBansRequest,
|
request: SetBansRequest,
|
||||||
) -> Result<SetBansResponse, Error> {
|
) -> Result<SetBansResponse, Error> {
|
||||||
todo!();
|
for peer in request.bans {
|
||||||
|
let address = todo!();
|
||||||
|
|
||||||
|
let ban = if peer.ban {
|
||||||
|
Some(Duration::from_secs(peer.seconds.into()))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
let set_ban = cuprate_p2p_core::types::SetBan { address, ban };
|
||||||
|
|
||||||
|
address_book::set_ban::<ClearNet>(&mut DummyAddressBook, set_ban).await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(SetBansResponse {
|
Ok(SetBansResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,9 +436,34 @@ async fn get_bans(
|
||||||
state: CupratedRpcHandler,
|
state: CupratedRpcHandler,
|
||||||
request: GetBansRequest,
|
request: GetBansRequest,
|
||||||
) -> Result<GetBansResponse, Error> {
|
) -> Result<GetBansResponse, Error> {
|
||||||
|
let now = Instant::now();
|
||||||
|
|
||||||
|
let bans = address_book::get_bans::<ClearNet>(&mut DummyAddressBook)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|ban| {
|
||||||
|
let seconds = if let Some(instant) = ban.unban_instant {
|
||||||
|
instant
|
||||||
|
.checked_duration_since(now)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs()
|
||||||
|
.try_into()
|
||||||
|
.unwrap_or(0)
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
GetBan {
|
||||||
|
host: ban.address.to_string(),
|
||||||
|
ip: todo!(),
|
||||||
|
seconds,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(GetBansResponse {
|
Ok(GetBansResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
bans: todo!(),
|
bans,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,46 +472,100 @@ async fn banned(
|
||||||
state: CupratedRpcHandler,
|
state: CupratedRpcHandler,
|
||||||
request: BannedRequest,
|
request: BannedRequest,
|
||||||
) -> Result<BannedResponse, Error> {
|
) -> Result<BannedResponse, Error> {
|
||||||
|
let peer = todo!("create Z::Addr from request.address");
|
||||||
|
let ban = address_book::get_ban::<ClearNet>(&mut DummyAddressBook, peer).await?;
|
||||||
|
|
||||||
|
let (banned, seconds) = if let Some(instant) = ban {
|
||||||
|
let seconds = instant
|
||||||
|
.checked_duration_since(Instant::now())
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs()
|
||||||
|
.try_into()
|
||||||
|
.unwrap_or(0);
|
||||||
|
|
||||||
|
(true, seconds)
|
||||||
|
} else {
|
||||||
|
(false, 0)
|
||||||
|
};
|
||||||
|
|
||||||
Ok(BannedResponse {
|
Ok(BannedResponse {
|
||||||
banned: todo!(),
|
banned,
|
||||||
seconds: todo!(),
|
seconds,
|
||||||
status: todo!(),
|
status: Status::Ok,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2880-L2932>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2880-L2932>
|
||||||
async fn flush_transaction_pool(
|
async fn flush_transaction_pool(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: FlushTransactionPoolRequest,
|
request: FlushTransactionPoolRequest,
|
||||||
) -> Result<FlushTransactionPoolResponse, Error> {
|
) -> Result<FlushTransactionPoolResponse, Error> {
|
||||||
todo!();
|
let tx_hashes = request
|
||||||
|
.txids
|
||||||
|
.into_iter()
|
||||||
|
.map(helper::hex_to_hash)
|
||||||
|
.collect::<Result<Vec<[u8; 32]>, _>>()?;
|
||||||
|
|
||||||
|
txpool::flush(&mut state.txpool_manager, tx_hashes).await?;
|
||||||
|
|
||||||
Ok(FlushTransactionPoolResponse { status: Status::Ok })
|
Ok(FlushTransactionPoolResponse { status: Status::Ok })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2934-L2979>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2934-L2979>
|
||||||
async fn get_output_histogram(
|
async fn get_output_histogram(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetOutputHistogramRequest,
|
request: GetOutputHistogramRequest,
|
||||||
) -> Result<GetOutputHistogramResponse, Error> {
|
) -> Result<GetOutputHistogramResponse, Error> {
|
||||||
|
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 {
|
Ok(GetOutputHistogramResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
histogram: todo!(),
|
histogram,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2998-L3013>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2998-L3013>
|
||||||
async fn get_coinbase_tx_sum(
|
async fn get_coinbase_tx_sum(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetCoinbaseTxSumRequest,
|
request: GetCoinbaseTxSumRequest,
|
||||||
) -> Result<GetCoinbaseTxSumResponse, Error> {
|
) -> Result<GetCoinbaseTxSumResponse, Error> {
|
||||||
|
let sum =
|
||||||
|
blockchain::coinbase_tx_sum(&mut state.blockchain_read, request.height, request.count)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
// Formats `u128` as hexadecimal strings.
|
||||||
|
let wide_emission_amount = format!("{:#x}", sum.fee_amount);
|
||||||
|
let wide_fee_amount = format!("{:#x}", sum.emission_amount);
|
||||||
|
|
||||||
|
let (emission_amount, emission_amount_top64) =
|
||||||
|
split_u128_into_low_high_bits(sum.emission_amount);
|
||||||
|
let (fee_amount, fee_amount_top64) = split_u128_into_low_high_bits(sum.fee_amount);
|
||||||
|
|
||||||
Ok(GetCoinbaseTxSumResponse {
|
Ok(GetCoinbaseTxSumResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
emission_amount: todo!(),
|
emission_amount,
|
||||||
emission_amount_top64: todo!(),
|
emission_amount_top64,
|
||||||
fee_amount: todo!(),
|
fee_amount,
|
||||||
fee_amount_top64: todo!(),
|
fee_amount_top64,
|
||||||
wide_emission_amount: todo!(),
|
wide_emission_amount,
|
||||||
wide_fee_amount: todo!(),
|
wide_fee_amount,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,46 +574,89 @@ async fn get_version(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetVersionRequest,
|
request: GetVersionRequest,
|
||||||
) -> Result<GetVersionResponse, Error> {
|
) -> Result<GetVersionResponse, Error> {
|
||||||
|
let current_height = helper::top_height(&mut state).await?.0;
|
||||||
|
let target_height = blockchain_manager::target_height(&mut state.blockchain_manager).await?;
|
||||||
|
|
||||||
|
let hard_forks = blockchain::hard_forks(&mut state.blockchain_read)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|(height, hf)| HardforkEntry {
|
||||||
|
height: usize_to_u64(height),
|
||||||
|
hf_version: hf.as_u8(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(GetVersionResponse {
|
Ok(GetVersionResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
version: CORE_RPC_VERSION,
|
version: CORE_RPC_VERSION,
|
||||||
release: RELEASE,
|
release: RELEASE,
|
||||||
current_height: helper::top_height(&mut state).await?.0,
|
current_height,
|
||||||
target_height: todo!(),
|
target_height,
|
||||||
hard_forks: todo!(),
|
hard_forks,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3015-L3031>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3015-L3031>
|
||||||
async fn get_fee_estimate(
|
async fn get_fee_estimate(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetFeeEstimateRequest,
|
request: GetFeeEstimateRequest,
|
||||||
) -> Result<GetFeeEstimateResponse, Error> {
|
) -> Result<GetFeeEstimateResponse, Error> {
|
||||||
|
let estimate =
|
||||||
|
blockchain_context::fee_estimate(&mut state.blockchain_context, request.grace_blocks)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(GetFeeEstimateResponse {
|
Ok(GetFeeEstimateResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
fee: todo!(),
|
fee: estimate.fee,
|
||||||
fees: todo!(),
|
fees: estimate.fees,
|
||||||
quantization_mask: todo!(),
|
quantization_mask: estimate.quantization_mask,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3033-L3064>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3033-L3064>
|
||||||
async fn get_alternate_chains(
|
async fn get_alternate_chains(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetAlternateChainsRequest,
|
request: GetAlternateChainsRequest,
|
||||||
) -> Result<GetAlternateChainsResponse, Error> {
|
) -> Result<GetAlternateChainsResponse, Error> {
|
||||||
|
let chains = blockchain::alt_chains(&mut state.blockchain_read)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|info| {
|
||||||
|
let block_hashes = info.block_hashes.into_iter().map(hex::encode).collect();
|
||||||
|
let (difficulty, difficulty_top64) = split_u128_into_low_high_bits(info.difficulty);
|
||||||
|
|
||||||
|
ChainInfo {
|
||||||
|
block_hash: hex::encode(info.block_hash),
|
||||||
|
block_hashes,
|
||||||
|
difficulty,
|
||||||
|
difficulty_top64,
|
||||||
|
height: info.height,
|
||||||
|
length: info.length,
|
||||||
|
main_chain_parent_block: hex::encode(info.main_chain_parent_block),
|
||||||
|
wide_difficulty: hex::encode(u128::to_ne_bytes(info.difficulty)),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(GetAlternateChainsResponse {
|
Ok(GetAlternateChainsResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
chains: todo!(),
|
chains,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3254-L3304>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3254-L3304>
|
||||||
async fn relay_tx(
|
async fn relay_tx(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: RelayTxRequest,
|
request: RelayTxRequest,
|
||||||
) -> Result<RelayTxResponse, Error> {
|
) -> Result<RelayTxResponse, Error> {
|
||||||
todo!();
|
let tx_hashes = request
|
||||||
|
.txids
|
||||||
|
.into_iter()
|
||||||
|
.map(helper::hex_to_hash)
|
||||||
|
.collect::<Result<Vec<[u8; 32]>, _>>()?;
|
||||||
|
|
||||||
|
txpool::relay(&mut state.txpool_manager, tx_hashes).await?;
|
||||||
|
|
||||||
Ok(RelayTxResponse { status: Status::Ok })
|
Ok(RelayTxResponse { status: Status::Ok })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +666,7 @@ async fn sync_info(
|
||||||
request: SyncInfoRequest,
|
request: SyncInfoRequest,
|
||||||
) -> Result<SyncInfoResponse, Error> {
|
) -> Result<SyncInfoResponse, Error> {
|
||||||
Ok(SyncInfoResponse {
|
Ok(SyncInfoResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
height: todo!(),
|
height: todo!(),
|
||||||
next_needed_pruning_seed: todo!(),
|
next_needed_pruning_seed: todo!(),
|
||||||
overview: todo!(),
|
overview: todo!(),
|
||||||
|
@ -531,12 +678,22 @@ async fn sync_info(
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3332-L3350>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3332-L3350>
|
||||||
async fn get_transaction_pool_backlog(
|
async fn get_transaction_pool_backlog(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetTransactionPoolBacklogRequest,
|
request: GetTransactionPoolBacklogRequest,
|
||||||
) -> Result<GetTransactionPoolBacklogResponse, Error> {
|
) -> Result<GetTransactionPoolBacklogResponse, Error> {
|
||||||
|
let backlog = txpool::backlog(&mut state.txpool_read)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| TxBacklogEntry {
|
||||||
|
weight: entry.weight,
|
||||||
|
fee: entry.fee,
|
||||||
|
time_in_pool: entry.time_in_pool.as_secs(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Ok(GetTransactionPoolBacklogResponse {
|
Ok(GetTransactionPoolBacklogResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
backlog: todo!(),
|
backlog,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +703,7 @@ async fn get_miner_data(
|
||||||
request: GetMinerDataRequest,
|
request: GetMinerDataRequest,
|
||||||
) -> Result<GetMinerDataResponse, Error> {
|
) -> Result<GetMinerDataResponse, Error> {
|
||||||
Ok(GetMinerDataResponse {
|
Ok(GetMinerDataResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
major_version: todo!(),
|
major_version: todo!(),
|
||||||
height: todo!(),
|
height: todo!(),
|
||||||
prev_id: todo!(),
|
prev_id: todo!(),
|
||||||
|
@ -560,13 +717,18 @@ async fn get_miner_data(
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3453-L3476>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3453-L3476>
|
||||||
async fn prune_blockchain(
|
async fn prune_blockchain(
|
||||||
state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: PruneBlockchainRequest,
|
request: PruneBlockchainRequest,
|
||||||
) -> Result<PruneBlockchainResponse, Error> {
|
) -> Result<PruneBlockchainResponse, Error> {
|
||||||
|
let pruned = blockchain_manager::pruned(&mut state.blockchain_manager).await?;
|
||||||
|
let pruning_seed = blockchain_manager::prune(&mut state.blockchain_manager)
|
||||||
|
.await?
|
||||||
|
.compress();
|
||||||
|
|
||||||
Ok(PruneBlockchainResponse {
|
Ok(PruneBlockchainResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
pruned: todo!(),
|
pruned,
|
||||||
pruning_seed: todo!(),
|
pruning_seed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +748,7 @@ async fn flush_cache(
|
||||||
todo!();
|
todo!();
|
||||||
|
|
||||||
Ok(FlushCacheResponse {
|
Ok(FlushCacheResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +758,7 @@ async fn add_aux_pow(
|
||||||
request: AddAuxPowRequest,
|
request: AddAuxPowRequest,
|
||||||
) -> Result<AddAuxPowResponse, Error> {
|
) -> Result<AddAuxPowResponse, Error> {
|
||||||
Ok(AddAuxPowResponse {
|
Ok(AddAuxPowResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
blocktemplate_blob: todo!(),
|
blocktemplate_blob: todo!(),
|
||||||
blockhashing_blob: todo!(),
|
blockhashing_blob: todo!(),
|
||||||
merkle_root: todo!(),
|
merkle_root: todo!(),
|
||||||
|
@ -611,7 +773,7 @@ async fn get_tx_ids_loose(
|
||||||
request: GetTxIdsLooseRequest,
|
request: GetTxIdsLooseRequest,
|
||||||
) -> Result<GetTxIdsLooseResponse, Error> {
|
) -> Result<GetTxIdsLooseResponse, Error> {
|
||||||
Ok(GetTxIdsLooseResponse {
|
Ok(GetTxIdsLooseResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
txids: todo!(),
|
txids: todo!(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
|
use cuprate_rpc_types::misc::ConnectionInfo;
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
use cuprate_helper::cast::usize_to_u64;
|
use cuprate_helper::cast::usize_to_u64;
|
||||||
use cuprate_p2p_core::{
|
use cuprate_p2p_core::{
|
||||||
services::{AddressBookRequest, AddressBookResponse},
|
services::{AddressBookRequest, AddressBookResponse},
|
||||||
|
types::BanState,
|
||||||
AddressBook, NetworkZone,
|
AddressBook, NetworkZone,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,6 +33,56 @@ pub(crate) async fn peerlist_size<Z: NetworkZone>(
|
||||||
Ok((usize_to_u64(white), usize_to_u64(grey)))
|
Ok((usize_to_u64(white), usize_to_u64(grey)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`AddressBookRequest::ConnectionInfo`]
|
||||||
|
pub(crate) async fn connection_info<Z: NetworkZone>(
|
||||||
|
address_book: &mut impl AddressBook<Z>,
|
||||||
|
) -> Result<Vec<ConnectionInfo>, Error> {
|
||||||
|
let AddressBookResponse::ConnectionInfo(vec) = address_book
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!(e))?
|
||||||
|
.call(AddressBookRequest::ConnectionInfo)
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!(e))?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: impl this map somewhere instead of inline.
|
||||||
|
let vec = vec
|
||||||
|
.into_iter()
|
||||||
|
.map(|info| ConnectionInfo {
|
||||||
|
address: info.address.to_string(),
|
||||||
|
address_type: info.address_type,
|
||||||
|
avg_download: info.avg_download,
|
||||||
|
avg_upload: info.avg_upload,
|
||||||
|
connection_id: info.connection_id,
|
||||||
|
current_download: info.current_download,
|
||||||
|
current_upload: info.current_upload,
|
||||||
|
height: info.height,
|
||||||
|
host: info.host,
|
||||||
|
incoming: info.incoming,
|
||||||
|
ip: info.ip,
|
||||||
|
live_time: info.live_time,
|
||||||
|
localhost: info.localhost,
|
||||||
|
local_ip: info.local_ip,
|
||||||
|
peer_id: info.peer_id,
|
||||||
|
port: info.port,
|
||||||
|
pruning_seed: info.pruning_seed,
|
||||||
|
recv_count: info.recv_count,
|
||||||
|
recv_idle_time: info.recv_idle_time,
|
||||||
|
rpc_credits_per_hash: info.rpc_credits_per_hash,
|
||||||
|
rpc_port: info.rpc_port,
|
||||||
|
send_count: info.send_count,
|
||||||
|
send_idle_time: info.send_idle_time,
|
||||||
|
state: info.state,
|
||||||
|
support_flags: info.support_flags,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Ok(vec)
|
||||||
|
}
|
||||||
|
|
||||||
/// [`AddressBookRequest::ConnectionCount`]
|
/// [`AddressBookRequest::ConnectionCount`]
|
||||||
pub(crate) async fn connection_count<Z: NetworkZone>(
|
pub(crate) async fn connection_count<Z: NetworkZone>(
|
||||||
address_book: &mut impl AddressBook<Z>,
|
address_book: &mut impl AddressBook<Z>,
|
||||||
|
@ -52,13 +104,13 @@ pub(crate) async fn connection_count<Z: NetworkZone>(
|
||||||
/// [`AddressBookRequest::SetBan`]
|
/// [`AddressBookRequest::SetBan`]
|
||||||
pub(crate) async fn set_ban<Z: NetworkZone>(
|
pub(crate) async fn set_ban<Z: NetworkZone>(
|
||||||
address_book: &mut impl AddressBook<Z>,
|
address_book: &mut impl AddressBook<Z>,
|
||||||
peer: cuprate_p2p_core::ban::SetBan<Z::Addr>,
|
set_ban: cuprate_p2p_core::types::SetBan<Z::Addr>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let AddressBookResponse::Ok = address_book
|
let AddressBookResponse::Ok = address_book
|
||||||
.ready()
|
.ready()
|
||||||
.await
|
.await
|
||||||
.map_err(|e| anyhow!(e))?
|
.map_err(|e| anyhow!(e))?
|
||||||
.call(AddressBookRequest::SetBan(peer))
|
.call(AddressBookRequest::SetBan(set_ban))
|
||||||
.await
|
.await
|
||||||
.map_err(|e| anyhow!(e))?
|
.map_err(|e| anyhow!(e))?
|
||||||
else {
|
else {
|
||||||
|
@ -90,7 +142,7 @@ pub(crate) async fn get_ban<Z: NetworkZone>(
|
||||||
/// [`AddressBookRequest::GetBans`]
|
/// [`AddressBookRequest::GetBans`]
|
||||||
pub(crate) async fn get_bans<Z: NetworkZone>(
|
pub(crate) async fn get_bans<Z: NetworkZone>(
|
||||||
address_book: &mut impl AddressBook<Z>,
|
address_book: &mut impl AddressBook<Z>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<Vec<BanState<Z::Addr>>, Error> {
|
||||||
let AddressBookResponse::GetBans(bans) = address_book
|
let AddressBookResponse::GetBans(bans) = address_book
|
||||||
.ready()
|
.ready()
|
||||||
.await
|
.await
|
||||||
|
@ -102,5 +154,5 @@ pub(crate) async fn get_bans<Z: NetworkZone>(
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(todo!())
|
Ok(bans)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Functions for [`BlockchainReadRequest`].
|
//! Functions for [`BlockchainReadRequest`].
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{BTreeMap, HashMap, HashSet},
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ use anyhow::Error;
|
||||||
use monero_serai::block::Block;
|
use monero_serai::block::Block;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
use cuprate_blockchain::service::BlockchainReadHandle;
|
use cuprate_blockchain::{service::BlockchainReadHandle, types::AltChainInfo};
|
||||||
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
||||||
use cuprate_types::{
|
use cuprate_types::{
|
||||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||||
Chain, CoinbaseTxSum, ExtendedBlockHeader, MinerData, OutputHistogramEntry,
|
Chain, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, HardFork, MinerData,
|
||||||
OutputHistogramInput, OutputOnChain,
|
OutputHistogramEntry, OutputHistogramInput, OutputOnChain,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// [`BlockchainReadRequest::Block`].
|
/// [`BlockchainReadRequest::Block`].
|
||||||
|
@ -343,3 +343,35 @@ pub(crate) async fn coinbase_tx_sum(
|
||||||
|
|
||||||
Ok(sum)
|
Ok(sum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainReadRequest::HardForks`]
|
||||||
|
pub(crate) async fn hard_forks(
|
||||||
|
blockchain_read: &mut BlockchainReadHandle,
|
||||||
|
) -> Result<BTreeMap<usize, HardFork>, Error> {
|
||||||
|
let BlockchainResponse::HardForks(hfs) = blockchain_read
|
||||||
|
.ready()
|
||||||
|
.await?
|
||||||
|
.call(BlockchainReadRequest::HardForks)
|
||||||
|
.await?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(hfs)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainReadRequest::AltChains`]
|
||||||
|
pub(crate) async fn alt_chains(
|
||||||
|
blockchain_read: &mut BlockchainReadHandle,
|
||||||
|
) -> Result<Vec<ChainInfo>, Error> {
|
||||||
|
let BlockchainResponse::AltChains(vec) = blockchain_read
|
||||||
|
.ready()
|
||||||
|
.await?
|
||||||
|
.call(BlockchainReadRequest::AltChains)
|
||||||
|
.await?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(vec)
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use monero_serai::block::Block;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
||||||
|
use cuprate_pruning::PruningSeed;
|
||||||
|
|
||||||
use crate::rpc::handler::{
|
use crate::rpc::handler::{
|
||||||
BlockchainManagerHandle, BlockchainManagerRequest, BlockchainManagerResponse,
|
BlockchainManagerHandle, BlockchainManagerRequest, BlockchainManagerResponse,
|
||||||
|
@ -30,8 +31,10 @@ pub(crate) async fn pop_blocks(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`BlockchainManagerRequest::Prune`]
|
/// [`BlockchainManagerRequest::Prune`]
|
||||||
pub(crate) async fn prune(blockchain_manager: &mut BlockchainManagerHandle) -> Result<(), Error> {
|
pub(crate) async fn prune(
|
||||||
let BlockchainManagerResponse::Ok = blockchain_manager
|
blockchain_manager: &mut BlockchainManagerHandle,
|
||||||
|
) -> Result<PruningSeed, Error> {
|
||||||
|
let BlockchainManagerResponse::Prune(seed) = blockchain_manager
|
||||||
.ready()
|
.ready()
|
||||||
.await?
|
.await?
|
||||||
.call(BlockchainManagerRequest::Prune)
|
.call(BlockchainManagerRequest::Prune)
|
||||||
|
@ -40,7 +43,7 @@ pub(crate) async fn prune(blockchain_manager: &mut BlockchainManagerHandle) -> R
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`BlockchainManagerRequest::Pruned`]
|
/// [`BlockchainManagerRequest::Pruned`]
|
||||||
|
|
|
@ -49,9 +49,17 @@ pub(crate) async fn size(txpool_read: &mut TxpoolReadHandle) -> Result<u64, Erro
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO
|
/// TODO
|
||||||
#[expect(clippy::needless_pass_by_ref_mut, reason = "TODO: remove after impl")]
|
|
||||||
pub(crate) async fn flush(
|
pub(crate) async fn flush(
|
||||||
txpool_read: &mut TxpoolReadHandle,
|
txpool_manager: &mut Infallible,
|
||||||
|
tx_hashes: Vec<[u8; 32]>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
todo!();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
pub(crate) async fn relay(
|
||||||
|
txpool_manager: &mut Infallible,
|
||||||
tx_hashes: Vec<[u8; 32]>,
|
tx_hashes: Vec<[u8; 32]>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
todo!();
|
todo!();
|
||||||
|
|
|
@ -423,7 +423,8 @@ impl<Z: BorshNetworkZone> Service<AddressBookRequest<Z>> for AddressBook<Z> {
|
||||||
AddressBookRequest::PeerlistSize
|
AddressBookRequest::PeerlistSize
|
||||||
| AddressBookRequest::ConnectionCount
|
| AddressBookRequest::ConnectionCount
|
||||||
| AddressBookRequest::SetBan(_)
|
| AddressBookRequest::SetBan(_)
|
||||||
| AddressBookRequest::GetBans => {
|
| AddressBookRequest::GetBans
|
||||||
|
| AddressBookRequest::ConnectionInfo => {
|
||||||
todo!("finish https://github.com/Cuprate/cuprate/pull/297")
|
todo!("finish https://github.com/Cuprate/cuprate/pull/297")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
//! Data structures related to bans.
|
|
||||||
|
|
||||||
use std::time::{Duration, Instant};
|
|
||||||
|
|
||||||
use crate::NetZoneAddress;
|
|
||||||
|
|
||||||
/// Data within [`crate::services::AddressBookRequest::SetBan`].
|
|
||||||
pub struct SetBan<A: NetZoneAddress> {
|
|
||||||
/// Address of the peer.
|
|
||||||
pub address: A,
|
|
||||||
/// - If [`Some`], how long this peer should be banned for
|
|
||||||
/// - If [`None`], the peer will be unbanned
|
|
||||||
pub ban: Option<Duration>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data within [`crate::services::AddressBookResponse::GetBans`].
|
|
||||||
pub struct BanState<A: NetZoneAddress> {
|
|
||||||
/// Address of the peer.
|
|
||||||
pub address: A,
|
|
||||||
/// - If [`Some`], the peer is banned until this [`Instant`]
|
|
||||||
/// - If [`None`], the peer is not currently banned
|
|
||||||
pub unban_instant: Option<Instant>,
|
|
||||||
}
|
|
|
@ -111,7 +111,8 @@ impl<N: NetworkZone> Service<AddressBookRequest<N>> for DummyAddressBook {
|
||||||
AddressBookRequest::PeerlistSize
|
AddressBookRequest::PeerlistSize
|
||||||
| AddressBookRequest::ConnectionCount
|
| AddressBookRequest::ConnectionCount
|
||||||
| AddressBookRequest::SetBan(_)
|
| AddressBookRequest::SetBan(_)
|
||||||
| AddressBookRequest::GetBans => {
|
| AddressBookRequest::GetBans
|
||||||
|
| AddressBookRequest::ConnectionInfo => {
|
||||||
todo!("finish https://github.com/Cuprate/cuprate/pull/297")
|
todo!("finish https://github.com/Cuprate/cuprate/pull/297")
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -75,7 +75,6 @@ use cuprate_wire::{
|
||||||
NetworkAddress,
|
NetworkAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod ban;
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
mod constants;
|
mod constants;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
@ -83,6 +82,7 @@ pub mod handles;
|
||||||
mod network_zones;
|
mod network_zones;
|
||||||
pub mod protocol;
|
pub mod protocol;
|
||||||
pub mod services;
|
pub mod services;
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
pub use network_zones::{ClearNet, ClearNetServerCfg};
|
pub use network_zones::{ClearNet, ClearNetServerCfg};
|
||||||
|
|
|
@ -4,9 +4,9 @@ use cuprate_pruning::{PruningError, PruningSeed};
|
||||||
use cuprate_wire::{CoreSyncData, PeerListEntryBase};
|
use cuprate_wire::{CoreSyncData, PeerListEntryBase};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ban::{BanState, SetBan},
|
|
||||||
client::InternalPeerID,
|
client::InternalPeerID,
|
||||||
handles::ConnectionHandle,
|
handles::ConnectionHandle,
|
||||||
|
types::{BanState, ConnectionInfo, SetBan},
|
||||||
NetZoneAddress, NetworkAddressIncorrectZone, NetworkZone,
|
NetZoneAddress, NetworkAddressIncorrectZone, NetworkZone,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,6 +118,9 @@ pub enum AddressBookRequest<Z: NetworkZone> {
|
||||||
/// Get the amount of white & grey peers.
|
/// Get the amount of white & grey peers.
|
||||||
PeerlistSize,
|
PeerlistSize,
|
||||||
|
|
||||||
|
/// Get information on all connections.
|
||||||
|
ConnectionInfo,
|
||||||
|
|
||||||
/// Get the amount of incoming & outgoing connections.
|
/// Get the amount of incoming & outgoing connections.
|
||||||
ConnectionCount,
|
ConnectionCount,
|
||||||
|
|
||||||
|
@ -152,6 +155,9 @@ pub enum AddressBookResponse<Z: NetworkZone> {
|
||||||
/// Response to [`AddressBookRequest::PeerlistSize`].
|
/// Response to [`AddressBookRequest::PeerlistSize`].
|
||||||
PeerlistSize { white: usize, grey: usize },
|
PeerlistSize { white: usize, grey: usize },
|
||||||
|
|
||||||
|
/// Response to [`AddressBookRequest::ConnectionInfo`].
|
||||||
|
ConnectionInfo(Vec<ConnectionInfo<Z::Addr>>),
|
||||||
|
|
||||||
/// Response to [`AddressBookRequest::ConnectionCount`].
|
/// Response to [`AddressBookRequest::ConnectionCount`].
|
||||||
ConnectionCount { incoming: usize, outgoing: usize },
|
ConnectionCount { incoming: usize, outgoing: usize },
|
||||||
|
|
||||||
|
|
54
p2p/p2p-core/src/types.rs
Normal file
54
p2p/p2p-core/src/types.rs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
//! General data structures.
|
||||||
|
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
use crate::NetZoneAddress;
|
||||||
|
|
||||||
|
/// Data within [`crate::services::AddressBookRequest::SetBan`].
|
||||||
|
pub struct SetBan<A: NetZoneAddress> {
|
||||||
|
/// Address of the peer.
|
||||||
|
pub address: A,
|
||||||
|
/// - If [`Some`], how long this peer should be banned for
|
||||||
|
/// - If [`None`], the peer will be unbanned
|
||||||
|
pub ban: Option<Duration>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Data within [`crate::services::AddressBookResponse::GetBans`].
|
||||||
|
pub struct BanState<A: NetZoneAddress> {
|
||||||
|
/// Address of the peer.
|
||||||
|
pub address: A,
|
||||||
|
/// - If [`Some`], the peer is banned until this [`Instant`]
|
||||||
|
/// - If [`None`], the peer is not currently banned
|
||||||
|
pub unban_instant: Option<Instant>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: reduce fields and map to RPC type.
|
||||||
|
//
|
||||||
|
/// Data within [`crate::services::AddressBookResponse::ConnectionInfo`].
|
||||||
|
pub struct ConnectionInfo<A: NetZoneAddress> {
|
||||||
|
pub address: A,
|
||||||
|
pub address_type: u8,
|
||||||
|
pub avg_download: u64,
|
||||||
|
pub avg_upload: u64,
|
||||||
|
pub connection_id: String,
|
||||||
|
pub current_download: u64,
|
||||||
|
pub current_upload: u64,
|
||||||
|
pub height: u64,
|
||||||
|
pub host: String,
|
||||||
|
pub incoming: bool,
|
||||||
|
pub ip: String,
|
||||||
|
pub live_time: u64,
|
||||||
|
pub localhost: bool,
|
||||||
|
pub local_ip: bool,
|
||||||
|
pub peer_id: String,
|
||||||
|
pub port: String,
|
||||||
|
pub pruning_seed: u32,
|
||||||
|
pub recv_count: u64,
|
||||||
|
pub recv_idle_time: u64,
|
||||||
|
pub rpc_credits_per_hash: u32,
|
||||||
|
pub rpc_port: u16,
|
||||||
|
pub send_count: u64,
|
||||||
|
pub send_idle_time: u64,
|
||||||
|
pub state: String,
|
||||||
|
pub support_flags: u32,
|
||||||
|
}
|
|
@ -58,61 +58,37 @@ pub struct ResponseBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResponseBase {
|
impl ResponseBase {
|
||||||
/// `const` version of [`Default::default`].
|
/// [`Status::Ok`] and trusted [`Self`].
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use cuprate_rpc_types::{misc::*, base::*};
|
|
||||||
///
|
|
||||||
/// let new = ResponseBase::new();
|
|
||||||
/// assert_eq!(new, ResponseBase {
|
|
||||||
/// status: Status::Ok,
|
|
||||||
/// untrusted: false,
|
|
||||||
/// });
|
|
||||||
/// ```
|
|
||||||
pub const fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
status: Status::Ok,
|
|
||||||
untrusted: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns OK and trusted [`Self`].
|
|
||||||
///
|
///
|
||||||
/// This is the most common version of [`Self`].
|
/// This is the most common version of [`Self`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_rpc_types::{misc::*, base::*};
|
/// use cuprate_rpc_types::{misc::*, base::*};
|
||||||
///
|
///
|
||||||
/// let ok = ResponseBase::ok();
|
/// assert_eq!(ResponseBase::OK, ResponseBase {
|
||||||
/// assert_eq!(ok, ResponseBase {
|
|
||||||
/// status: Status::Ok,
|
/// status: Status::Ok,
|
||||||
/// untrusted: false,
|
/// untrusted: false,
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn ok() -> Self {
|
pub const OK: Self = Self {
|
||||||
Self {
|
status: Status::Ok,
|
||||||
status: Status::Ok,
|
untrusted: false,
|
||||||
untrusted: false,
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Same as [`Self::ok`] but with [`Self::untrusted`] set to `true`.
|
/// Same as [`Self::OK`] but with [`Self::untrusted`] set to `true`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_rpc_types::{misc::*, base::*};
|
/// use cuprate_rpc_types::{misc::*, base::*};
|
||||||
///
|
///
|
||||||
/// let ok_untrusted = ResponseBase::ok_untrusted();
|
/// assert_eq!(ResponseBase::OK_UNTRUSTED, ResponseBase {
|
||||||
/// assert_eq!(ok_untrusted, ResponseBase {
|
|
||||||
/// status: Status::Ok,
|
/// status: Status::Ok,
|
||||||
/// untrusted: true,
|
/// untrusted: true,
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn ok_untrusted() -> Self {
|
pub const OK_UNTRUSTED: Self = Self {
|
||||||
Self {
|
status: Status::Ok,
|
||||||
status: Status::Ok,
|
untrusted: true,
|
||||||
untrusted: true,
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
|
@ -148,9 +124,9 @@ impl AccessResponseBase {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_rpc_types::{misc::*, base::*};
|
/// use cuprate_rpc_types::{misc::*, base::*};
|
||||||
///
|
///
|
||||||
/// let new = AccessResponseBase::new(ResponseBase::ok());
|
/// let new = AccessResponseBase::new(ResponseBase::OK);
|
||||||
/// assert_eq!(new, AccessResponseBase {
|
/// assert_eq!(new, AccessResponseBase {
|
||||||
/// response_base: ResponseBase::ok(),
|
/// response_base: ResponseBase::OK,
|
||||||
/// credits: 0,
|
/// credits: 0,
|
||||||
/// top_hash: "".into(),
|
/// top_hash: "".into(),
|
||||||
/// });
|
/// });
|
||||||
|
@ -163,47 +139,41 @@ impl AccessResponseBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns OK and trusted [`Self`].
|
/// [`Status::Ok`] and trusted [`Self`].
|
||||||
///
|
///
|
||||||
/// This is the most common version of [`Self`].
|
/// This is the most common version of [`Self`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_rpc_types::{misc::*, base::*};
|
/// use cuprate_rpc_types::{misc::*, base::*};
|
||||||
///
|
///
|
||||||
/// let ok = AccessResponseBase::ok();
|
/// assert_eq!(AccessResponseBase::OK, AccessResponseBase {
|
||||||
/// assert_eq!(ok, AccessResponseBase {
|
/// response_base: ResponseBase::OK,
|
||||||
/// response_base: ResponseBase::ok(),
|
|
||||||
/// credits: 0,
|
/// credits: 0,
|
||||||
/// top_hash: "".into(),
|
/// top_hash: "".into(),
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn ok() -> Self {
|
pub const OK: Self = Self {
|
||||||
Self {
|
response_base: ResponseBase::OK,
|
||||||
response_base: ResponseBase::ok(),
|
credits: 0,
|
||||||
credits: 0,
|
top_hash: String::new(),
|
||||||
top_hash: String::new(),
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Same as [`Self::ok`] but with `untrusted` set to `true`.
|
/// Same as [`Self::OK`] but with `untrusted` set to `true`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_rpc_types::{misc::*, base::*};
|
/// use cuprate_rpc_types::{misc::*, base::*};
|
||||||
///
|
///
|
||||||
/// let ok_untrusted = AccessResponseBase::ok_untrusted();
|
/// assert_eq!(AccessResponseBase::OK_UNTRUSTED, AccessResponseBase {
|
||||||
/// assert_eq!(ok_untrusted, AccessResponseBase {
|
|
||||||
/// response_base: ResponseBase::ok_untrusted(),
|
/// response_base: ResponseBase::ok_untrusted(),
|
||||||
/// credits: 0,
|
/// credits: 0,
|
||||||
/// top_hash: "".into(),
|
/// top_hash: "".into(),
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn ok_untrusted() -> Self {
|
pub const OK_UNTRUSTED: Self = Self {
|
||||||
Self {
|
response_base: ResponseBase::OK_UNTRUSTED,
|
||||||
response_base: ResponseBase::ok_untrusted(),
|
credits: 0,
|
||||||
credits: 0,
|
top_hash: String::new(),
|
||||||
top_hash: String::new(),
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
|
|
|
@ -184,7 +184,7 @@ define_request_and_response! {
|
||||||
// <https://serde.rs/field-attrs.html#flatten>.
|
// <https://serde.rs/field-attrs.html#flatten>.
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BLOCK_TEMPLATE_RESPONSE => GetBlockTemplateResponse {
|
GET_BLOCK_TEMPLATE_RESPONSE => GetBlockTemplateResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
blockhashing_blob: "1010f4bae0b4069d648e741d85ca0e7acb4501f051b27e9b107d3cd7a3f03aa7f776089117c81a00000000e0c20372be23d356347091025c5b5e8f2abf83ab618378565cce2b703491523401".into(),
|
blockhashing_blob: "1010f4bae0b4069d648e741d85ca0e7acb4501f051b27e9b107d3cd7a3f03aa7f776089117c81a00000000e0c20372be23d356347091025c5b5e8f2abf83ab618378565cce2b703491523401".into(),
|
||||||
blocktemplate_blob: "1010f4bae0b4069d648e741d85ca0e7acb4501f051b27e9b107d3cd7a3f03aa7f776089117c81a0000000002c681c30101ff8a81c3010180e0a596bb11033b7eedf47baf878f3490cb20b696079c34bd017fe59b0d070e74d73ffabc4bb0e05f011decb630f3148d0163b3bd39690dde4078e4cfb69fecf020d6278a27bad10c58023c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".into(),
|
blocktemplate_blob: "1010f4bae0b4069d648e741d85ca0e7acb4501f051b27e9b107d3cd7a3f03aa7f776089117c81a0000000002c681c30101ff8a81c3010180e0a596bb11033b7eedf47baf878f3490cb20b696079c34bd017fe59b0d070e74d73ffabc4bb0e05f011decb630f3148d0163b3bd39690dde4078e4cfb69fecf020d6278a27bad10c58023c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".into(),
|
||||||
difficulty_top64: 0,
|
difficulty_top64: 0,
|
||||||
|
@ -240,7 +240,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BLOCK_COUNT_RESPONSE => GetBlockCountResponse {
|
GET_BLOCK_COUNT_RESPONSE => GetBlockCountResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
count: 3195019,
|
count: 3195019,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
|
@ -332,7 +332,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GENERATE_BLOCKS_RESPONSE => GenerateBlocksResponse {
|
GENERATE_BLOCKS_RESPONSE => GenerateBlocksResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
blocks: vec!["49b712db7760e3728586f8434ee8bc8d7b3d410dac6bb6e98bf5845c83b917e4".into()],
|
blocks: vec!["49b712db7760e3728586f8434ee8bc8d7b3d410dac6bb6e98bf5845c83b917e4".into()],
|
||||||
height: 9783,
|
height: 9783,
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_LAST_BLOCK_HEADER_RESPONSE => GetLastBlockHeaderResponse {
|
GET_LAST_BLOCK_HEADER_RESPONSE => GetLastBlockHeaderResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
block_header: BlockHeader {
|
block_header: BlockHeader {
|
||||||
block_size: 200419,
|
block_size: 200419,
|
||||||
block_weight: 200419,
|
block_weight: 200419,
|
||||||
|
@ -409,7 +409,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BLOCK_HEADER_BY_HASH_RESPONSE => GetBlockHeaderByHashResponse {
|
GET_BLOCK_HEADER_BY_HASH_RESPONSE => GetBlockHeaderByHashResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
block_headers: vec![],
|
block_headers: vec![],
|
||||||
block_header: BlockHeader {
|
block_header: BlockHeader {
|
||||||
block_size: 210,
|
block_size: 210,
|
||||||
|
@ -464,7 +464,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BLOCK_HEADER_BY_HEIGHT_RESPONSE => GetBlockHeaderByHeightResponse {
|
GET_BLOCK_HEADER_BY_HEIGHT_RESPONSE => GetBlockHeaderByHeightResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
block_header: BlockHeader {
|
block_header: BlockHeader {
|
||||||
block_size: 210,
|
block_size: 210,
|
||||||
block_weight: 210,
|
block_weight: 210,
|
||||||
|
@ -519,7 +519,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BLOCK_HEADERS_RANGE_RESPONSE => GetBlockHeadersRangeResponse {
|
GET_BLOCK_HEADERS_RANGE_RESPONSE => GetBlockHeadersRangeResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
headers: vec![
|
headers: vec![
|
||||||
BlockHeader {
|
BlockHeader {
|
||||||
block_size: 301413,
|
block_size: 301413,
|
||||||
|
@ -601,7 +601,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BLOCK_RESPONSE => GetBlockResponse {
|
GET_BLOCK_RESPONSE => GetBlockResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
blob: "1010c58bab9b06b27bdecfc6cd0a46172d136c08831cf67660377ba992332363228b1b722781e7807e07f502cef8a70101ff92f8a7010180e0a596bb1103d7cbf826b665d7a532c316982dc8dbc24f285cbc18bbcc27c7164cd9b3277a85d034019f629d8b36bd16a2bfce3ea80c31dc4d8762c67165aec21845494e32b7582fe00211000000297a787a000000000000000000000000".into(),
|
blob: "1010c58bab9b06b27bdecfc6cd0a46172d136c08831cf67660377ba992332363228b1b722781e7807e07f502cef8a70101ff92f8a7010180e0a596bb1103d7cbf826b665d7a532c316982dc8dbc24f285cbc18bbcc27c7164cd9b3277a85d034019f629d8b36bd16a2bfce3ea80c31dc4d8762c67165aec21845494e32b7582fe00211000000297a787a000000000000000000000000".into(),
|
||||||
block_header: BlockHeader {
|
block_header: BlockHeader {
|
||||||
block_size: 106,
|
block_size: 106,
|
||||||
|
@ -654,7 +654,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_CONNECTIONS_RESPONSE => GetConnectionsResponse {
|
GET_CONNECTIONS_RESPONSE => GetConnectionsResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
connections: vec![
|
connections: vec![
|
||||||
ConnectionInfo {
|
ConnectionInfo {
|
||||||
address: "3evk3kezfjg44ma6tvesy7rbxwwpgpympj45xar5fo4qajrsmkoaqdqd.onion:18083".into(),
|
address: "3evk3kezfjg44ma6tvesy7rbxwwpgpympj45xar5fo4qajrsmkoaqdqd.onion:18083".into(),
|
||||||
|
@ -728,7 +728,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_INFO_RESPONSE => GetInfoResponse {
|
GET_INFO_RESPONSE => GetInfoResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
adjusted_time: 1721245289,
|
adjusted_time: 1721245289,
|
||||||
alt_blocks_count: 16,
|
alt_blocks_count: 16,
|
||||||
block_size_limit: 600000,
|
block_size_limit: 600000,
|
||||||
|
@ -831,7 +831,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
HARD_FORK_INFO_RESPONSE => HardForkInfoResponse {
|
HARD_FORK_INFO_RESPONSE => HardForkInfoResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
earliest_height: 2689608,
|
earliest_height: 2689608,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
state: 0,
|
state: 0,
|
||||||
|
@ -877,7 +877,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SET_BANS_RESPONSE => SetBansResponse {
|
SET_BANS_RESPONSE => SetBansResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -892,7 +892,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_BANS_RESPONSE => GetBansResponse {
|
GET_BANS_RESPONSE => GetBansResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
bans: vec![
|
bans: vec![
|
||||||
GetBan {
|
GetBan {
|
||||||
host: "104.248.206.131".into(),
|
host: "104.248.206.131".into(),
|
||||||
|
@ -994,7 +994,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_OUTPUT_HISTOGRAM_RESPONSE => GetOutputHistogramResponse {
|
GET_OUTPUT_HISTOGRAM_RESPONSE => GetOutputHistogramResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
histogram: vec![HistogramEntry {
|
histogram: vec![HistogramEntry {
|
||||||
amount: 20000000000,
|
amount: 20000000000,
|
||||||
recent_instances: 0,
|
recent_instances: 0,
|
||||||
|
@ -1028,7 +1028,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_COINBASE_TX_SUM_RESPONSE => GetCoinbaseTxSumResponse {
|
GET_COINBASE_TX_SUM_RESPONSE => GetCoinbaseTxSumResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
emission_amount: 9387854817320,
|
emission_amount: 9387854817320,
|
||||||
emission_amount_top64: 0,
|
emission_amount_top64: 0,
|
||||||
fee_amount: 83981380000,
|
fee_amount: 83981380000,
|
||||||
|
@ -1057,7 +1057,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_VERSION_RESPONSE => GetVersionResponse {
|
GET_VERSION_RESPONSE => GetVersionResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
current_height: 3195051,
|
current_height: 3195051,
|
||||||
hard_forks: vec![
|
hard_forks: vec![
|
||||||
HardforkEntry {
|
HardforkEntry {
|
||||||
|
@ -1143,12 +1143,16 @@ define_request_and_response! {
|
||||||
get_fee_estimate,
|
get_fee_estimate,
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
core_rpc_server_commands_defs.h => 2250..=2277,
|
core_rpc_server_commands_defs.h => 2250..=2277,
|
||||||
GetFeeEstimate (empty),
|
|
||||||
Request {},
|
GetFeeEstimate,
|
||||||
|
|
||||||
|
Request {
|
||||||
|
grace_blocks: u64 = default_zero::<u64>(), "default_zero",
|
||||||
|
},
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_FEE_ESTIMATE_RESPONSE => GetFeeEstimateResponse {
|
GET_FEE_ESTIMATE_RESPONSE => GetFeeEstimateResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
fee: 20000,
|
fee: 20000,
|
||||||
fees: vec![20000,80000,320000,4000000],
|
fees: vec![20000,80000,320000,4000000],
|
||||||
quantization_mask: 10000,
|
quantization_mask: 10000,
|
||||||
|
@ -1170,7 +1174,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_ALTERNATE_CHAINS_RESPONSE => GetAlternateChainsResponse {
|
GET_ALTERNATE_CHAINS_RESPONSE => GetAlternateChainsResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
chains: vec![
|
chains: vec![
|
||||||
ChainInfo {
|
ChainInfo {
|
||||||
block_hash: "4826c7d45d7cf4f02985b5c405b0e5d7f92c8d25e015492ce19aa3b209295dce".into(),
|
block_hash: "4826c7d45d7cf4f02985b5c405b0e5d7f92c8d25e015492ce19aa3b209295dce".into(),
|
||||||
|
@ -1238,7 +1242,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SYNC_INFO_RESPONSE => SyncInfoResponse {
|
SYNC_INFO_RESPONSE => SyncInfoResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
height: 3195157,
|
height: 3195157,
|
||||||
next_needed_pruning_seed: 0,
|
next_needed_pruning_seed: 0,
|
||||||
overview: "[]".into(),
|
overview: "[]".into(),
|
||||||
|
@ -1328,7 +1332,7 @@ define_request_and_response! {
|
||||||
// TODO: enable test after binary string impl.
|
// TODO: enable test after binary string impl.
|
||||||
// #[doc = serde_doc_test!(
|
// #[doc = serde_doc_test!(
|
||||||
// GET_TRANSACTION_POOL_BACKLOG_RESPONSE => GetTransactionPoolBacklogResponse {
|
// GET_TRANSACTION_POOL_BACKLOG_RESPONSE => GetTransactionPoolBacklogResponse {
|
||||||
// base: ResponseBase::ok(),
|
// base: ResponseBase::OK,
|
||||||
// backlog: "...Binary...".into(),
|
// backlog: "...Binary...".into(),
|
||||||
// }
|
// }
|
||||||
// )]
|
// )]
|
||||||
|
@ -1370,7 +1374,7 @@ define_request_and_response! {
|
||||||
// TODO: enable test after binary string impl.
|
// TODO: enable test after binary string impl.
|
||||||
// #[doc = serde_doc_test!(
|
// #[doc = serde_doc_test!(
|
||||||
// GET_OUTPUT_DISTRIBUTION_RESPONSE => GetOutputDistributionResponse {
|
// GET_OUTPUT_DISTRIBUTION_RESPONSE => GetOutputDistributionResponse {
|
||||||
// base: AccessResponseBase::ok(),
|
// base: AccessResponseBase::OK,
|
||||||
// distributions: vec![Distribution::Uncompressed(DistributionUncompressed {
|
// distributions: vec![Distribution::Uncompressed(DistributionUncompressed {
|
||||||
// start_height: 1462078,
|
// start_height: 1462078,
|
||||||
// base: 0,
|
// base: 0,
|
||||||
|
@ -1394,7 +1398,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_MINER_DATA_RESPONSE => GetMinerDataResponse {
|
GET_MINER_DATA_RESPONSE => GetMinerDataResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
already_generated_coins: 18186022843595960691,
|
already_generated_coins: 18186022843595960691,
|
||||||
difficulty: "0x48afae42de".into(),
|
difficulty: "0x48afae42de".into(),
|
||||||
height: 2731375,
|
height: 2731375,
|
||||||
|
@ -1447,7 +1451,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
PRUNE_BLOCKCHAIN_RESPONSE => PruneBlockchainResponse {
|
PRUNE_BLOCKCHAIN_RESPONSE => PruneBlockchainResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
pruned: true,
|
pruned: true,
|
||||||
pruning_seed: 387,
|
pruning_seed: 387,
|
||||||
}
|
}
|
||||||
|
@ -1513,7 +1517,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
FLUSH_CACHE_RESPONSE => FlushCacheResponse {
|
FLUSH_CACHE_RESPONSE => FlushCacheResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -1542,7 +1546,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
ADD_AUX_POW_RESPONSE => AddAuxPowResponse {
|
ADD_AUX_POW_RESPONSE => AddAuxPowResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
aux_pow: vec![AuxPow {
|
aux_pow: vec![AuxPow {
|
||||||
hash: "7b35762de164b20885e15dbe656b1138db06bb402fa1796f5765a23933d8859a".into(),
|
hash: "7b35762de164b20885e15dbe656b1138db06bb402fa1796f5765a23933d8859a".into(),
|
||||||
id: "3200b4ea97c3b2081cd4190b58e49572b2319fed00d030ad51809dff06b5d8c8".into(),
|
id: "3200b4ea97c3b2081cd4190b58e49572b2319fed00d030ad51809dff06b5d8c8".into(),
|
||||||
|
|
|
@ -102,7 +102,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_HEIGHT_RESPONSE => GetHeightResponse {
|
GET_HEIGHT_RESPONSE => GetHeightResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
hash: "68bb1a1cff8e2a44c3221e8e1aff80bc6ca45d06fa8eff4d2a3a7ac31d4efe3f".into(),
|
hash: "68bb1a1cff8e2a44c3221e8e1aff80bc6ca45d06fa8eff4d2a3a7ac31d4efe3f".into(),
|
||||||
height: 3195160,
|
height: 3195160,
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_ALT_BLOCKS_HASHES_RESPONSE => GetAltBlocksHashesResponse {
|
GET_ALT_BLOCKS_HASHES_RESPONSE => GetAltBlocksHashesResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
blks_hashes: vec!["8ee10db35b1baf943f201b303890a29e7d45437bd76c2bd4df0d2f2ee34be109".into()],
|
blks_hashes: vec!["8ee10db35b1baf943f201b303890a29e7d45437bd76c2bd4df0d2f2ee34be109".into()],
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
|
@ -187,7 +187,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
IS_KEY_IMAGE_SPENT_RESPONSE => IsKeyImageSpentResponse {
|
IS_KEY_IMAGE_SPENT_RESPONSE => IsKeyImageSpentResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
spent_status: vec![1, 1],
|
spent_status: vec![1, 1],
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
|
@ -283,7 +283,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
START_MINING_RESPONSE => StartMiningResponse {
|
START_MINING_RESPONSE => StartMiningResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -298,7 +298,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
STOP_MINING_RESPONSE => StopMiningResponse {
|
STOP_MINING_RESPONSE => StopMiningResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -313,7 +313,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
MINING_STATUS_RESPONSE => MiningStatusResponse {
|
MINING_STATUS_RESPONSE => MiningStatusResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
active: false,
|
active: false,
|
||||||
address: "".into(),
|
address: "".into(),
|
||||||
bg_idle_threshold: 0,
|
bg_idle_threshold: 0,
|
||||||
|
@ -359,7 +359,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SAVE_BC_RESPONSE => SaveBcResponse {
|
SAVE_BC_RESPONSE => SaveBcResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -385,7 +385,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_PEER_LIST_RESPONSE => GetPeerListResponse {
|
GET_PEER_LIST_RESPONSE => GetPeerListResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
gray_list: vec![
|
gray_list: vec![
|
||||||
Peer {
|
Peer {
|
||||||
host: "161.97.193.0".into(),
|
host: "161.97.193.0".into(),
|
||||||
|
@ -467,7 +467,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SET_LOG_HASH_RATE_RESPONSE => SetLogHashRateResponse {
|
SET_LOG_HASH_RATE_RESPONSE => SetLogHashRateResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -492,7 +492,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SET_LOG_LEVEL_RESPONSE => SetLogLevelResponse {
|
SET_LOG_LEVEL_RESPONSE => SetLogLevelResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
ResponseBase {}
|
ResponseBase {}
|
||||||
|
@ -516,7 +516,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SET_LOG_CATEGORIES_RESPONSE => SetLogCategoriesResponse {
|
SET_LOG_CATEGORIES_RESPONSE => SetLogCategoriesResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
categories: "*:INFO".into(),
|
categories: "*:INFO".into(),
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
|
@ -582,7 +582,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_TRANSACTION_POOL_STATS_RESPONSE => GetTransactionPoolStatsResponse {
|
GET_TRANSACTION_POOL_STATS_RESPONSE => GetTransactionPoolStatsResponse {
|
||||||
base: AccessResponseBase::ok(),
|
base: AccessResponseBase::OK,
|
||||||
pool_stats: TxpoolStats {
|
pool_stats: TxpoolStats {
|
||||||
bytes_max: 11843,
|
bytes_max: 11843,
|
||||||
bytes_med: 2219,
|
bytes_med: 2219,
|
||||||
|
@ -644,7 +644,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_LIMIT_RESPONSE => GetLimitResponse {
|
GET_LIMIT_RESPONSE => GetLimitResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
limit_down: 1280000,
|
limit_down: 1280000,
|
||||||
limit_up: 1280000,
|
limit_up: 1280000,
|
||||||
}
|
}
|
||||||
|
@ -676,7 +676,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
SET_LIMIT_RESPONSE => SetLimitResponse {
|
SET_LIMIT_RESPONSE => SetLimitResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
limit_down: 1024,
|
limit_down: 1024,
|
||||||
limit_up: 128,
|
limit_up: 128,
|
||||||
}
|
}
|
||||||
|
@ -707,7 +707,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
OUT_PEERS_RESPONSE => OutPeersResponse {
|
OUT_PEERS_RESPONSE => OutPeersResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
out_peers: 3232235535,
|
out_peers: 3232235535,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
|
@ -740,7 +740,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_NET_STATS_RESPONSE => GetNetStatsResponse {
|
GET_NET_STATS_RESPONSE => GetNetStatsResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
start_time: 1721251858,
|
start_time: 1721251858,
|
||||||
total_bytes_in: 16283817214,
|
total_bytes_in: 16283817214,
|
||||||
total_bytes_out: 34225244079,
|
total_bytes_out: 34225244079,
|
||||||
|
@ -779,7 +779,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_OUTS_RESPONSE => GetOutsResponse {
|
GET_OUTS_RESPONSE => GetOutsResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
outs: vec![
|
outs: vec![
|
||||||
OutKey {
|
OutKey {
|
||||||
height: 51941,
|
height: 51941,
|
||||||
|
@ -823,7 +823,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
UPDATE_RESPONSE => UpdateResponse {
|
UPDATE_RESPONSE => UpdateResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
auto_uri: "".into(),
|
auto_uri: "".into(),
|
||||||
hash: "".into(),
|
hash: "".into(),
|
||||||
path: "".into(),
|
path: "".into(),
|
||||||
|
@ -860,7 +860,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
POP_BLOCKS_RESPONSE => PopBlocksResponse {
|
POP_BLOCKS_RESPONSE => PopBlocksResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
height: 76482,
|
height: 76482,
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
|
@ -879,7 +879,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_TRANSACTION_POOL_HASHES_RESPONSE => GetTransactionPoolHashesResponse {
|
GET_TRANSACTION_POOL_HASHES_RESPONSE => GetTransactionPoolHashesResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
tx_hashes: vec![
|
tx_hashes: vec![
|
||||||
"aa928aed888acd6152c60194d50a4df29b0b851be6169acf11b6a8e304dd6c03".into(),
|
"aa928aed888acd6152c60194d50a4df29b0b851be6169acf11b6a8e304dd6c03".into(),
|
||||||
"794345f321a98f3135151f3056c0fdf8188646a8dab27de971428acf3551dd11".into(),
|
"794345f321a98f3135151f3056c0fdf8188646a8dab27de971428acf3551dd11".into(),
|
||||||
|
@ -929,7 +929,7 @@ define_request_and_response! {
|
||||||
|
|
||||||
#[doc = serde_doc_test!(
|
#[doc = serde_doc_test!(
|
||||||
GET_PUBLIC_NODES_RESPONSE => GetPublicNodesResponse {
|
GET_PUBLIC_NODES_RESPONSE => GetPublicNodesResponse {
|
||||||
base: ResponseBase::ok(),
|
base: ResponseBase::OK,
|
||||||
gray: vec![],
|
gray: vec![],
|
||||||
white: vec![
|
white: vec![
|
||||||
PublicNode {
|
PublicNode {
|
||||||
|
|
|
@ -121,6 +121,8 @@ fn map_request(
|
||||||
R::DatabaseSize => database_size(env),
|
R::DatabaseSize => database_size(env),
|
||||||
R::OutputHistogram(input) => output_histogram(env, input),
|
R::OutputHistogram(input) => output_histogram(env, input),
|
||||||
R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count),
|
R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count),
|
||||||
|
R::HardForks => hard_forks(env),
|
||||||
|
R::AltChains => alt_chains(env),
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SOMEDAY: post-request handling, run some code for each request? */
|
/* SOMEDAY: post-request handling, run some code for each request? */
|
||||||
|
@ -648,3 +650,13 @@ fn output_histogram(env: &ConcreteEnv, input: OutputHistogramInput) -> ResponseR
|
||||||
fn coinbase_tx_sum(env: &ConcreteEnv, height: usize, count: u64) -> ResponseResult {
|
fn coinbase_tx_sum(env: &ConcreteEnv, height: usize, count: u64) -> ResponseResult {
|
||||||
Ok(BlockchainResponse::CoinbaseTxSum(todo!()))
|
Ok(BlockchainResponse::CoinbaseTxSum(todo!()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainReadRequest::HardForks`]
|
||||||
|
fn hard_forks(env: &ConcreteEnv) -> ResponseResult {
|
||||||
|
Ok(BlockchainResponse::HardForks(todo!()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainReadRequest::AltChains`]
|
||||||
|
fn alt_chains(env: &ConcreteEnv) -> ResponseResult {
|
||||||
|
Ok(BlockchainResponse::AltChains(todo!()))
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
//! responses are also tested in Cuprate's blockchain database crate.
|
//! responses are also tested in Cuprate's blockchain database crate.
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{BTreeMap, HashMap, HashSet},
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ use monero_serai::block::Block;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation},
|
types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation},
|
||||||
AltBlockInformation, ChainId, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput,
|
AltBlockInformation, ChainId, ChainInfo, CoinbaseTxSum, HardFork, OutputHistogramEntry,
|
||||||
|
OutputHistogramInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- ReadRequest
|
//---------------------------------------------------------------------------------------------------- ReadRequest
|
||||||
|
@ -128,6 +129,12 @@ pub enum BlockchainReadRequest {
|
||||||
///
|
///
|
||||||
/// TODO: document fields after impl.
|
/// TODO: document fields after impl.
|
||||||
CoinbaseTxSum { height: usize, count: u64 },
|
CoinbaseTxSum { height: usize, count: u64 },
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
HardForks,
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
AltChains,
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- WriteRequest
|
//---------------------------------------------------------------------------------------------------- WriteRequest
|
||||||
|
@ -276,6 +283,14 @@ pub enum BlockchainResponse {
|
||||||
/// Response to [`BlockchainReadRequest::CoinbaseTxSum`].
|
/// Response to [`BlockchainReadRequest::CoinbaseTxSum`].
|
||||||
CoinbaseTxSum(CoinbaseTxSum),
|
CoinbaseTxSum(CoinbaseTxSum),
|
||||||
|
|
||||||
|
/// Response to [`BlockchainReadRequest::HardForks`].
|
||||||
|
///
|
||||||
|
/// - Key = height at which the hardfork activated
|
||||||
|
/// - Value = hardfork version
|
||||||
|
HardForks(BTreeMap<usize, HardFork>),
|
||||||
|
|
||||||
|
AltChains(Vec<ChainInfo>),
|
||||||
|
|
||||||
//------------------------------------------------------ Writes
|
//------------------------------------------------------ Writes
|
||||||
/// A generic Ok response to indicate a request was successfully handled.
|
/// A generic Ok response to indicate a request was successfully handled.
|
||||||
///
|
///
|
||||||
|
|
|
@ -177,8 +177,6 @@ pub struct OutputHistogramEntry {
|
||||||
pub struct CoinbaseTxSum {
|
pub struct CoinbaseTxSum {
|
||||||
pub emission_amount: u128,
|
pub emission_amount: u128,
|
||||||
pub fee_amount: u128,
|
pub fee_amount: u128,
|
||||||
pub wide_emission_amount: u128,
|
|
||||||
pub wide_fee_amount: u128,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data to create a custom block template.
|
/// Data to create a custom block template.
|
||||||
|
@ -242,7 +240,6 @@ pub struct ChainInfo {
|
||||||
pub height: u64,
|
pub height: u64,
|
||||||
pub length: u64,
|
pub length: u64,
|
||||||
pub main_chain_parent_block: [u8; 32],
|
pub main_chain_parent_block: [u8; 32],
|
||||||
pub wide_difficulty: u128,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
|
|
Loading…
Reference in a new issue