mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 19:49:33 +00:00
cuprate_types::rpc
, from
module for cuprate_rpc_types
This commit is contained in:
parent
0b50091b5d
commit
2104bb0e17
22 changed files with 1132 additions and 238 deletions
|
@ -31,7 +31,7 @@ cuprate-txpool = { workspace = true }
|
||||||
cuprate-database = { workspace = true, features = ["serde"] }
|
cuprate-database = { workspace = true, features = ["serde"] }
|
||||||
cuprate-pruning = { workspace = true }
|
cuprate-pruning = { workspace = true }
|
||||||
cuprate-test-utils = { workspace = true }
|
cuprate-test-utils = { workspace = true }
|
||||||
cuprate-types = { workspace = true }
|
cuprate-types = { workspace = true, features = ["json"] }
|
||||||
cuprate-json-rpc = { workspace = true }
|
cuprate-json-rpc = { workspace = true }
|
||||||
cuprate-rpc-interface = { workspace = true }
|
cuprate-rpc-interface = { workspace = true }
|
||||||
cuprate-rpc-types = { workspace = true }
|
cuprate-rpc-types = { workspace = true }
|
||||||
|
|
|
@ -15,7 +15,7 @@ use cuprate_rpc_types::{
|
||||||
json::{GetOutputDistributionRequest, GetOutputDistributionResponse},
|
json::{GetOutputDistributionRequest, GetOutputDistributionResponse},
|
||||||
misc::RequestedInfo,
|
misc::RequestedInfo,
|
||||||
};
|
};
|
||||||
use cuprate_types::BlockCompleteEntry;
|
use cuprate_types::{BlockCompleteEntry, PoolInfoExtent};
|
||||||
|
|
||||||
use crate::rpc::{helper, request::blockchain, CupratedRpcHandler};
|
use crate::rpc::{helper, request::blockchain, CupratedRpcHandler};
|
||||||
|
|
||||||
|
@ -61,14 +61,44 @@ async fn get_blocks(
|
||||||
RequestedInfo::PoolOnly => (false, true),
|
RequestedInfo::PoolOnly => (false, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let pool_info_extent = PoolInfoExtent::None;
|
||||||
|
|
||||||
if get_pool {
|
if get_pool {
|
||||||
|
let allow_sensitive = !state.is_restricted();
|
||||||
let max_tx_count = if state.is_restricted() {
|
let max_tx_count = if state.is_restricted() {
|
||||||
RESTRICTED_TRANSACTIONS_COUNT
|
RESTRICTED_TRANSACTIONS_COUNT
|
||||||
} else {
|
} else {
|
||||||
usize::MAX
|
usize::MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
todo!();
|
// bool incremental;
|
||||||
|
// std::vector<std::pair<crypto::hash, tx_memory_pool::tx_details>> added_pool_txs;
|
||||||
|
// bool success = m_core.get_pool_info((time_t)req.pool_info_since, allow_sensitive, max_tx_count, added_pool_txs, res.remaining_added_pool_txids, res.removed_pool_txids, incremental);
|
||||||
|
// if (success)
|
||||||
|
// {
|
||||||
|
// res.added_pool_txs.clear();
|
||||||
|
// if (m_rpc_payment)
|
||||||
|
// {
|
||||||
|
// CHECK_PAYMENT_SAME_TS(req, res, added_pool_txs.size() * COST_PER_TX + (res.remaining_added_pool_txids.size() + res.removed_pool_txids.size()) * COST_PER_POOL_HASH);
|
||||||
|
// }
|
||||||
|
// for (const auto &added_pool_tx: added_pool_txs)
|
||||||
|
// {
|
||||||
|
// COMMAND_RPC_GET_BLOCKS_FAST::pool_tx_info info;
|
||||||
|
// info.tx_hash = added_pool_tx.first;
|
||||||
|
// std::stringstream oss;
|
||||||
|
// binary_archive<true> ar(oss);
|
||||||
|
// bool r = req.prune
|
||||||
|
// ? const_cast<cryptonote::transaction&>(added_pool_tx.second.tx).serialize_base(ar)
|
||||||
|
// : ::serialization::serialize(ar, const_cast<cryptonote::transaction&>(added_pool_tx.second.tx));
|
||||||
|
// if (!r)
|
||||||
|
// {
|
||||||
|
// res.status = "Failed to serialize transaction";
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// info.tx_blob = oss.str();
|
||||||
|
// info.double_spend_seen = added_pool_tx.second.double_spend_seen;
|
||||||
|
// res.added_pool_txs.push_back(std::move(info));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if get_blocks {
|
if get_blocks {
|
||||||
|
@ -79,11 +109,15 @@ async fn get_blocks(
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok(GetBlocksResponse {
|
Ok(GetBlocksResponse {
|
||||||
// base: ResponseBase::OK,
|
base: AccessResponseBase::OK,
|
||||||
// ..todo!()
|
blocks: todo!(),
|
||||||
// })
|
start_height: todo!(),
|
||||||
Ok(todo!())
|
current_height: todo!(),
|
||||||
|
output_indices: todo!(),
|
||||||
|
daemon_time: todo!(),
|
||||||
|
pool_info: todo!(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L817-L857>
|
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L817-L857>
|
||||||
|
|
|
@ -669,7 +669,7 @@ async fn get_output_histogram(
|
||||||
mut state: CupratedRpcHandler,
|
mut state: CupratedRpcHandler,
|
||||||
request: GetOutputHistogramRequest,
|
request: GetOutputHistogramRequest,
|
||||||
) -> Result<GetOutputHistogramResponse, Error> {
|
) -> Result<GetOutputHistogramResponse, Error> {
|
||||||
let input = cuprate_types::OutputHistogramInput {
|
let input = cuprate_types::rpc::OutputHistogramInput {
|
||||||
amounts: request.amounts,
|
amounts: request.amounts,
|
||||||
min_count: request.min_count,
|
min_count: request.min_count,
|
||||||
max_count: request.max_count,
|
max_count: request.max_count,
|
||||||
|
@ -1042,7 +1042,7 @@ fn add_aux_pow_inner(
|
||||||
.map(|aux| {
|
.map(|aux| {
|
||||||
let id = helper::hex_to_hash(aux.id)?;
|
let id = helper::hex_to_hash(aux.id)?;
|
||||||
let hash = helper::hex_to_hash(aux.hash)?;
|
let hash = helper::hex_to_hash(aux.hash)?;
|
||||||
Ok(cuprate_types::AuxPow { id, hash })
|
Ok(cuprate_types::rpc::AuxPow { id, hash })
|
||||||
})
|
})
|
||||||
.collect::<Result<Box<[_]>, Error>>()?;
|
.collect::<Result<Box<[_]>, Error>>()?;
|
||||||
// Some of the code below requires that the
|
// Some of the code below requires that the
|
||||||
|
@ -1058,7 +1058,7 @@ fn add_aux_pow_inner(
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn find_nonce(
|
fn find_nonce(
|
||||||
aux_pow: &[cuprate_types::AuxPow],
|
aux_pow: &[cuprate_types::rpc::AuxPow],
|
||||||
non_zero_len: NonZero<usize>,
|
non_zero_len: NonZero<usize>,
|
||||||
aux_pow_len: usize,
|
aux_pow_len: usize,
|
||||||
) -> Result<(u32, Box<[u32]>), Error> {
|
) -> Result<(u32, Box<[u32]>), Error> {
|
||||||
|
|
|
@ -13,8 +13,8 @@ use cuprate_blockchain::service::BlockchainReadHandle;
|
||||||
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, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, OutputHistogramEntry,
|
rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput},
|
||||||
OutputHistogramInput, OutputOnChain,
|
Chain, ExtendedBlockHeader, OutputOnChain,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// [`BlockchainReadRequest::Block`].
|
/// [`BlockchainReadRequest::Block`].
|
||||||
|
|
|
@ -8,7 +8,10 @@ use cuprate_consensus_context::{
|
||||||
BlockChainContext, BlockChainContextRequest, BlockChainContextResponse,
|
BlockChainContext, BlockChainContextRequest, BlockChainContextResponse,
|
||||||
BlockChainContextService,
|
BlockChainContextService,
|
||||||
};
|
};
|
||||||
use cuprate_types::{FeeEstimate, HardFork, HardForkInfo};
|
use cuprate_types::{
|
||||||
|
rpc::{FeeEstimate, HardForkInfo},
|
||||||
|
HardFork,
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: use `anyhow::Error` over `tower::BoxError` in blockchain context.
|
// FIXME: use `anyhow::Error` over `tower::BoxError` in blockchain context.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Functions to send [`TxpoolReadRequest`]s.
|
//! Functions to send [`TxpoolReadRequest`]s.
|
||||||
|
|
||||||
use std::convert::Infallible;
|
use std::{convert::Infallible, num::NonZero};
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
@ -13,6 +13,10 @@ use cuprate_txpool::{
|
||||||
},
|
},
|
||||||
TxEntry,
|
TxEntry,
|
||||||
};
|
};
|
||||||
|
use cuprate_types::{
|
||||||
|
rpc::{PoolInfoFull, PoolInfoIncremental, PoolTxInfo},
|
||||||
|
PoolInfo,
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: use `anyhow::Error` over `tower::BoxError` in txpool.
|
// FIXME: use `anyhow::Error` over `tower::BoxError` in txpool.
|
||||||
|
|
||||||
|
@ -53,6 +57,31 @@ pub(crate) async fn size(
|
||||||
Ok(usize_to_u64(size))
|
Ok(usize_to_u64(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
pub(crate) async fn pool_info(
|
||||||
|
txpool_read: &mut TxpoolReadHandle,
|
||||||
|
include_sensitive_txs: bool,
|
||||||
|
max_tx_count: usize,
|
||||||
|
start_time: Option<NonZero<usize>>,
|
||||||
|
) -> Result<Vec<PoolInfo>, Error> {
|
||||||
|
let TxpoolReadResponse::PoolInfo(vec) = txpool_read
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!(e))?
|
||||||
|
.call(TxpoolReadRequest::PoolInfo {
|
||||||
|
include_sensitive_txs,
|
||||||
|
max_tx_count,
|
||||||
|
start_time,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!(e))?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(vec)
|
||||||
|
}
|
||||||
|
|
||||||
/// TODO
|
/// TODO
|
||||||
pub(crate) async fn flush(
|
pub(crate) async fn flush(
|
||||||
txpool_manager: &mut Infallible,
|
txpool_manager: &mut Infallible,
|
||||||
|
|
|
@ -36,7 +36,10 @@ mod alt_chains;
|
||||||
mod task;
|
mod task;
|
||||||
mod tokens;
|
mod tokens;
|
||||||
|
|
||||||
use cuprate_types::{Chain, ChainInfo, FeeEstimate, HardForkInfo};
|
use cuprate_types::{
|
||||||
|
rpc::{ChainInfo, FeeEstimate, HardForkInfo},
|
||||||
|
Chain,
|
||||||
|
};
|
||||||
use difficulty::DifficultyCache;
|
use difficulty::DifficultyCache;
|
||||||
use rx_vms::RandomXVm;
|
use rx_vms::RandomXVm;
|
||||||
use weight::BlockWeightsCache;
|
use weight::BlockWeightsCache;
|
||||||
|
|
|
@ -11,12 +11,12 @@ use serde::{Deserialize, Serialize};
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use cuprate_epee_encoding::container_as_blob::ContainerAsBlob;
|
use cuprate_epee_encoding::container_as_blob::ContainerAsBlob;
|
||||||
|
|
||||||
use cuprate_types::BlockCompleteEntry;
|
use cuprate_types::{BlockCompleteEntry, PoolInfo};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
base::AccessResponseBase,
|
base::AccessResponseBase,
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin, PoolInfo},
|
misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin},
|
||||||
rpc_call::RpcCallValue,
|
rpc_call::RpcCallValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
380
rpc/types/src/from.rs
Normal file
380
rpc/types/src/from.rs
Normal file
|
@ -0,0 +1,380 @@
|
||||||
|
//! [`From`] implementations from other crate's types into [`crate`] types.
|
||||||
|
|
||||||
|
#![allow(unused_variables, unreachable_code, reason = "TODO")]
|
||||||
|
|
||||||
|
use cuprate_types::rpc::{
|
||||||
|
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, ConnectionInfo, GetBan,
|
||||||
|
GetMinerDataTxBacklogEntry, GetOutputsOut, HardforkEntry, HistogramEntry, OutKey, OutKeyBin,
|
||||||
|
OutputDistributionData, Peer, PublicNode, SetBan, Span, SpentKeyImageInfo, SyncInfoPeer,
|
||||||
|
TxBacklogEntry, TxInfo, TxOutputIndices, TxpoolHisto, TxpoolStats,
|
||||||
|
};
|
||||||
|
|
||||||
|
impl From<BlockHeader> for crate::misc::BlockHeader {
|
||||||
|
fn from(x: BlockHeader) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// block_size: u64,
|
||||||
|
// block_weight: u64,
|
||||||
|
// cumulative_difficulty_top64: u64,
|
||||||
|
// cumulative_difficulty: u64,
|
||||||
|
// depth: u64,
|
||||||
|
// difficulty_top64: u64,
|
||||||
|
// difficulty: u64,
|
||||||
|
// hash: String,
|
||||||
|
// height: u64,
|
||||||
|
// long_term_weight: u64,
|
||||||
|
// major_version: u8,
|
||||||
|
// miner_tx_hash: String,
|
||||||
|
// minor_version: u8,
|
||||||
|
// nonce: u32,
|
||||||
|
// num_txes: u64,
|
||||||
|
// orphan_status: bool,
|
||||||
|
// pow_hash: String,
|
||||||
|
// prev_hash: String,
|
||||||
|
// reward: u64,
|
||||||
|
// timestamp: u64,
|
||||||
|
// wide_cumulative_difficulty: String,
|
||||||
|
// wide_difficulty: String,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ConnectionInfo> for crate::misc::ConnectionInfo {
|
||||||
|
fn from(x: ConnectionInfo) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// address: String,
|
||||||
|
// address_type: AddressType,
|
||||||
|
// avg_download: u64,
|
||||||
|
// avg_upload: u64,
|
||||||
|
// connection_id: String,
|
||||||
|
// current_download: u64,
|
||||||
|
// current_upload: u64,
|
||||||
|
// height: u64,
|
||||||
|
// host: String,
|
||||||
|
// incoming: bool,
|
||||||
|
// ip: String,
|
||||||
|
// live_time: u64,
|
||||||
|
// localhost: bool,
|
||||||
|
// local_ip: bool,
|
||||||
|
// peer_id: String,
|
||||||
|
// port: String,
|
||||||
|
// pruning_seed: u32,
|
||||||
|
// recv_count: u64,
|
||||||
|
// recv_idle_time: u64,
|
||||||
|
// rpc_credits_per_hash: u32,
|
||||||
|
// rpc_port: u16,
|
||||||
|
// send_count: u64,
|
||||||
|
// send_idle_time: u64,
|
||||||
|
// // Exists in the original definition, but isn't
|
||||||
|
// // used or (de)serialized for RPC purposes.
|
||||||
|
// // ssl: bool,
|
||||||
|
// state: ConnectionState,
|
||||||
|
// support_flags: u32,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<SetBan> for crate::misc::SetBan {
|
||||||
|
fn from(x: SetBan) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// #[cfg_attr(feature = "serde", serde(default = "default_string"))]
|
||||||
|
// host: String,
|
||||||
|
// #[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
// ip: u32,
|
||||||
|
// ban: bool,
|
||||||
|
// seconds: u32,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<GetBan> for crate::misc::GetBan {
|
||||||
|
fn from(x: GetBan) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// host: String,
|
||||||
|
// ip: u32,
|
||||||
|
// seconds: u32,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<HistogramEntry> for crate::misc::HistogramEntry {
|
||||||
|
fn from(x: HistogramEntry) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// amount: u64,
|
||||||
|
// total_instances: u64,
|
||||||
|
// unlocked_instances: u64,
|
||||||
|
// recent_instances: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<HardforkEntry> for crate::misc::HardforkEntry {
|
||||||
|
fn from(x: HardforkEntry) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// height: u64,
|
||||||
|
// hf_version: u8,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ChainInfo> for crate::misc::ChainInfo {
|
||||||
|
fn from(x: ChainInfo) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// block_hash: [u8; 32],
|
||||||
|
// block_hashes: Vec<[u8; 32]>,
|
||||||
|
// difficulty_top64: u64,
|
||||||
|
// difficulty_low64: u64,
|
||||||
|
// height: u64,
|
||||||
|
// length: u64,
|
||||||
|
// main_chain_parent_block: [u8; 32],
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<SyncInfoPeer> for crate::misc::SyncInfoPeer {
|
||||||
|
fn from(x: SyncInfoPeer) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// info: ConnectionInfo,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Span> for crate::misc::Span {
|
||||||
|
fn from(x: Span) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// connection_id: String,
|
||||||
|
// nblocks: u64,
|
||||||
|
// rate: u32,
|
||||||
|
// remote_address: String,
|
||||||
|
// size: u64,
|
||||||
|
// speed: u32,
|
||||||
|
// start_block_height: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TxBacklogEntry> for crate::misc::TxBacklogEntry {
|
||||||
|
fn from(x: TxBacklogEntry) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// weight: u64,
|
||||||
|
// fee: u64,
|
||||||
|
// time_in_pool: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OutputDistributionData> for crate::misc::OutputDistributionData {
|
||||||
|
fn from(x: OutputDistributionData) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// distribution: Vec<u64>,
|
||||||
|
// start_height: u64,
|
||||||
|
// base: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<GetMinerDataTxBacklogEntry> for crate::misc::GetMinerDataTxBacklogEntry {
|
||||||
|
fn from(x: GetMinerDataTxBacklogEntry) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// id: String,
|
||||||
|
// weight: u64,
|
||||||
|
// fee: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AuxPow> for crate::misc::AuxPow {
|
||||||
|
fn from(x: AuxPow) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// id: [u8; 32],
|
||||||
|
// hash: [u8; 32],
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TxOutputIndices> for crate::misc::TxOutputIndices {
|
||||||
|
fn from(x: TxOutputIndices) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// indices: Vec<u64>,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<BlockOutputIndices> for crate::misc::BlockOutputIndices {
|
||||||
|
fn from(x: BlockOutputIndices) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// indices: Vec<TxOutputIndices>,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<GetOutputsOut> for crate::misc::GetOutputsOut {
|
||||||
|
fn from(x: GetOutputsOut) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// amount: u64,
|
||||||
|
// index: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OutKeyBin> for crate::misc::OutKeyBin {
|
||||||
|
fn from(x: OutKeyBin) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// key: [u8; 32],
|
||||||
|
// mask: [u8; 32],
|
||||||
|
// unlocked: bool,
|
||||||
|
// height: u64,
|
||||||
|
// txid: [u8; 32],
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Peer> for crate::misc::Peer {
|
||||||
|
fn from(x: Peer) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// id: u64,
|
||||||
|
// host: String,
|
||||||
|
// ip: u32,
|
||||||
|
// port: u16,
|
||||||
|
// #[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
// rpc_port: u16 = default_zero::<u16>(),
|
||||||
|
// #[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
// rpc_credits_per_hash: u32 = default_zero::<u32>(),
|
||||||
|
// last_seen: u64,
|
||||||
|
// #[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
// pruning_seed: u32 = default_zero::<u32>(),
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<PublicNode> for crate::misc::PublicNode {
|
||||||
|
fn from(x: PublicNode) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// host: String,
|
||||||
|
// last_seen: u64,
|
||||||
|
// rpc_port: u16,
|
||||||
|
// rpc_credits_per_hash: u32,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TxInfo> for crate::misc::TxInfo {
|
||||||
|
fn from(x: TxInfo) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// blob_size: u64,
|
||||||
|
// do_not_relay: bool,
|
||||||
|
// double_spend_seen: bool,
|
||||||
|
// fee: u64,
|
||||||
|
// id_hash: String,
|
||||||
|
// kept_by_block: bool,
|
||||||
|
// last_failed_height: u64,
|
||||||
|
// last_failed_id_hash: String,
|
||||||
|
// last_relayed_time: u64,
|
||||||
|
// max_used_block_height: u64,
|
||||||
|
// max_used_block_id_hash: String,
|
||||||
|
// receive_time: u64,
|
||||||
|
// relayed: bool,
|
||||||
|
// tx_blob: String,
|
||||||
|
// tx_json: String, // TODO: this should be another struct
|
||||||
|
// #[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
// weight: u64 = default_zero::<u64>(),
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<SpentKeyImageInfo> for crate::misc::SpentKeyImageInfo {
|
||||||
|
fn from(x: SpentKeyImageInfo) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// id_hash: String,
|
||||||
|
// txs_hashes: Vec<String>,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TxpoolHisto> for crate::misc::TxpoolHisto {
|
||||||
|
fn from(x: TxpoolHisto) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// txs: u32,
|
||||||
|
// bytes: u64,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TxpoolStats> for crate::misc::TxpoolStats {
|
||||||
|
fn from(x: TxpoolStats) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// bytes_max: u32,
|
||||||
|
// bytes_med: u32,
|
||||||
|
// bytes_min: u32,
|
||||||
|
// bytes_total: u64,
|
||||||
|
// fee_total: u64,
|
||||||
|
// histo_98pc: u64,
|
||||||
|
// histo: Vec<TxpoolHisto>,
|
||||||
|
// num_10m: u32,
|
||||||
|
// num_double_spends: u32,
|
||||||
|
// num_failing: u32,
|
||||||
|
// num_not_relayed: u32,
|
||||||
|
// oldest: u64,
|
||||||
|
// txs_total: u32,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OutKey> for crate::misc::OutKey {
|
||||||
|
fn from(x: OutKey) -> Self {
|
||||||
|
todo!();
|
||||||
|
|
||||||
|
// Self {
|
||||||
|
// key: String,
|
||||||
|
// mask: String,
|
||||||
|
// unlocked: bool,
|
||||||
|
// height: u64,
|
||||||
|
// txid: String,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ mod constants;
|
||||||
#[cfg(any(feature = "serde", feature = "epee"))]
|
#[cfg(any(feature = "serde", feature = "epee"))]
|
||||||
mod defaults;
|
mod defaults;
|
||||||
mod free;
|
mod free;
|
||||||
|
mod from;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod rpc_call;
|
mod rpc_call;
|
||||||
|
|
||||||
|
|
|
@ -15,25 +15,20 @@
|
||||||
mod binary_string;
|
mod binary_string;
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod key_image_spent_status;
|
mod key_image_spent_status;
|
||||||
#[expect(clippy::module_inception)]
|
|
||||||
mod misc;
|
|
||||||
mod pool_info;
|
|
||||||
mod pool_info_extent;
|
|
||||||
mod requested_info;
|
mod requested_info;
|
||||||
mod status;
|
mod status;
|
||||||
mod tx_entry;
|
mod tx_entry;
|
||||||
|
mod types;
|
||||||
|
|
||||||
pub use binary_string::BinaryString;
|
pub use binary_string::BinaryString;
|
||||||
pub use distribution::{Distribution, DistributionCompressedBinary, DistributionUncompressed};
|
pub use distribution::{Distribution, DistributionCompressedBinary, DistributionUncompressed};
|
||||||
pub use key_image_spent_status::KeyImageSpentStatus;
|
pub use key_image_spent_status::KeyImageSpentStatus;
|
||||||
pub use misc::{
|
|
||||||
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, ConnectionInfo, GetBan,
|
|
||||||
GetMinerDataTxBacklogEntry, GetOutputsOut, HardforkEntry, HistogramEntry, OutKey, OutKeyBin,
|
|
||||||
OutputDistributionData, Peer, PoolTxInfo, PublicNode, SetBan, Span, SpentKeyImageInfo,
|
|
||||||
SyncInfoPeer, TxBacklogEntry, TxInfo, TxOutputIndices, TxpoolHisto, TxpoolStats,
|
|
||||||
};
|
|
||||||
pub use pool_info::PoolInfo;
|
|
||||||
pub use pool_info_extent::PoolInfoExtent;
|
|
||||||
pub use requested_info::RequestedInfo;
|
pub use requested_info::RequestedInfo;
|
||||||
pub use status::Status;
|
pub use status::Status;
|
||||||
pub use tx_entry::TxEntry;
|
pub use tx_entry::TxEntry;
|
||||||
|
pub use types::{
|
||||||
|
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, ConnectionInfo, GetBan,
|
||||||
|
GetMinerDataTxBacklogEntry, GetOutputsOut, HardforkEntry, HistogramEntry, OutKey, OutKeyBin,
|
||||||
|
OutputDistributionData, Peer, PublicNode, SetBan, Span, SpentKeyImageInfo, SyncInfoPeer,
|
||||||
|
TxBacklogEntry, TxInfo, TxOutputIndices, TxpoolHisto, TxpoolStats,
|
||||||
|
};
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
//! the [`crate::misc::ConnectionInfo`] struct defined here.
|
//! the [`crate::misc::ConnectionInfo`] struct defined here.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
#[cfg(feature = "serde")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
use cuprate_epee_encoding::epee_object;
|
|
||||||
|
|
||||||
#[cfg(any(feature = "epee", feature = "serde"))]
|
#[cfg(any(feature = "epee", feature = "serde"))]
|
||||||
use crate::defaults::default_zero;
|
use crate::defaults::default_zero;
|
||||||
|
|
||||||
|
@ -28,7 +22,7 @@ use crate::macros::monero_definition_link;
|
||||||
/// - The original Monero definition site with [`monero_definition_link`]
|
/// - The original Monero definition site with [`monero_definition_link`]
|
||||||
/// - The request/responses where the `struct` is used
|
/// - The request/responses where the `struct` is used
|
||||||
macro_rules! define_struct_and_impl_epee {
|
macro_rules! define_struct_and_impl_epee {
|
||||||
(
|
($(
|
||||||
// Optional `struct` attributes.
|
// Optional `struct` attributes.
|
||||||
$( #[$struct_attr:meta] )*
|
$( #[$struct_attr:meta] )*
|
||||||
// The `struct`'s name.
|
// The `struct`'s name.
|
||||||
|
@ -40,24 +34,26 @@ macro_rules! define_struct_and_impl_epee {
|
||||||
$field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
|
$field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
)*) => {
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
$(
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
$( #[$struct_attr] )*
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct $struct_name {
|
$( #[$struct_attr] )*
|
||||||
$(
|
pub struct $struct_name {
|
||||||
$( #[$field_attr] )*
|
$(
|
||||||
pub $field_name: $field_type,
|
$( #[$field_attr] )*
|
||||||
)*
|
pub $field_name: $field_type,
|
||||||
}
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
epee_object! {
|
cuprate_epee_encoding::epee_object! {
|
||||||
$struct_name,
|
$struct_name,
|
||||||
$(
|
$(
|
||||||
$field_name: $field_type $(= $field_default)?,
|
$field_name: $field_type $(= $field_default)?,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,20 +328,6 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
|
||||||
#[doc = monero_definition_link!(
|
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
|
||||||
210..=221
|
|
||||||
)]
|
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
PoolTxInfo {
|
|
||||||
tx_hash: [u8; 32],
|
|
||||||
tx_blob: String,
|
|
||||||
double_spend_seen: bool,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
@ -29,7 +29,8 @@ use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThre
|
||||||
use cuprate_helper::map::combine_low_high_bits_to_u128;
|
use cuprate_helper::map::combine_low_high_bits_to_u128;
|
||||||
use cuprate_types::{
|
use cuprate_types::{
|
||||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||||
Chain, ChainId, ExtendedBlockHeader, OutputHistogramInput, OutputOnChain, TxsInBlock,
|
rpc::OutputHistogramInput,
|
||||||
|
Chain, ChainId, ExtendedBlockHeader, OutputOnChain, TxsInBlock,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums.
|
//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums.
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
num::NonZero,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_types::TransactionVerificationData;
|
use cuprate_types::{PoolInfo, TransactionVerificationData};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tx::TxEntry,
|
tx::TxEntry,
|
||||||
|
@ -40,6 +41,17 @@ pub enum TxpoolReadRequest {
|
||||||
/// include private transactions in the pool.
|
/// include private transactions in the pool.
|
||||||
include_sensitive_txs: bool,
|
include_sensitive_txs: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Get general information on the txpool.
|
||||||
|
PoolInfo {
|
||||||
|
/// If this is [`true`], the size returned will
|
||||||
|
/// include private transactions in the pool.
|
||||||
|
include_sensitive_txs: bool,
|
||||||
|
/// TODO
|
||||||
|
max_tx_count: usize,
|
||||||
|
/// TODO
|
||||||
|
start_time: Option<NonZero<usize>>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
||||||
|
@ -79,6 +91,9 @@ pub enum TxpoolReadResponse {
|
||||||
/// The inner value is the amount of
|
/// The inner value is the amount of
|
||||||
/// transactions currently in the pool.
|
/// transactions currently in the pool.
|
||||||
Size(usize),
|
Size(usize),
|
||||||
|
|
||||||
|
/// Response to [`TxpoolReadRequest::PoolInfo`].
|
||||||
|
PoolInfo(Vec<PoolInfo>),
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
)]
|
)]
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
num::NonZero,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +75,11 @@ fn map_request(
|
||||||
TxpoolReadRequest::Size {
|
TxpoolReadRequest::Size {
|
||||||
include_sensitive_txs,
|
include_sensitive_txs,
|
||||||
} => size(env, include_sensitive_txs),
|
} => size(env, include_sensitive_txs),
|
||||||
|
TxpoolReadRequest::PoolInfo {
|
||||||
|
include_sensitive_txs,
|
||||||
|
max_tx_count,
|
||||||
|
start_time,
|
||||||
|
} => pool_info(include_sensitive_txs, max_tx_count, start_time),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,3 +212,12 @@ fn backlog(env: &ConcreteEnv) -> ReadResponseResult {
|
||||||
fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
|
fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
|
||||||
Ok(TxpoolReadResponse::Size(todo!()))
|
Ok(TxpoolReadResponse::Size(todo!()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`TxpoolReadRequest::PoolInfo`].
|
||||||
|
fn pool_info(
|
||||||
|
include_sensitive_txs: bool,
|
||||||
|
max_tx_count: usize,
|
||||||
|
start_time: Option<NonZero<usize>>,
|
||||||
|
) -> ReadResponseResult {
|
||||||
|
Ok(TxpoolReadResponse::PoolInfo(todo!()))
|
||||||
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ json = ["hex", "dep:cuprate-helper"]
|
||||||
hex = ["serde", "dep:hex"]
|
hex = ["serde", "dep:hex"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-epee-encoding = { workspace = true, optional = true, features = ["std"] }
|
cuprate-epee-encoding = { workspace = true, optional = true, features = ["std"] }
|
||||||
cuprate-helper = { workspace = true, optional = true, features = ["cast"] }
|
cuprate-helper = { workspace = true, optional = true, features = ["cast"] }
|
||||||
cuprate-fixed-bytes = { workspace = true, features = ["std", "serde"] }
|
cuprate-fixed-bytes = { workspace = true, features = ["std", "serde"] }
|
||||||
|
|
||||||
bytes = { workspace = true }
|
bytes = { workspace = true }
|
||||||
curve25519-dalek = { workspace = true }
|
curve25519-dalek = { workspace = true }
|
||||||
|
|
|
@ -12,10 +12,11 @@ use monero_serai::block::Block;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
types::{Chain, ExtendedBlockHeader, OutputOnChain, TxsInBlock, VerifiedBlockInformation},
|
types::{Chain, ExtendedBlockHeader, OutputOnChain, TxsInBlock, VerifiedBlockInformation},
|
||||||
AltBlockInformation, BlockCompleteEntry, ChainId, ChainInfo, CoinbaseTxSum,
|
AltBlockInformation, BlockCompleteEntry, ChainId,
|
||||||
OutputHistogramEntry, OutputHistogramInput,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::rpc::{ChainInfo, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- ReadRequest
|
//---------------------------------------------------------------------------------------------------- ReadRequest
|
||||||
/// A read request to the blockchain database.
|
/// A read request to the blockchain database.
|
||||||
///
|
///
|
||||||
|
|
|
@ -13,20 +13,24 @@ mod address_type;
|
||||||
mod block_complete_entry;
|
mod block_complete_entry;
|
||||||
mod connection_state;
|
mod connection_state;
|
||||||
mod hard_fork;
|
mod hard_fork;
|
||||||
|
mod pool_info;
|
||||||
|
mod pool_info_extent;
|
||||||
mod transaction_verification_data;
|
mod transaction_verification_data;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
|
pub mod rpc;
|
||||||
|
|
||||||
pub use address_type::AddressType;
|
pub use address_type::AddressType;
|
||||||
pub use block_complete_entry::{BlockCompleteEntry, PrunedTxBlobEntry, TransactionBlobs};
|
pub use block_complete_entry::{BlockCompleteEntry, PrunedTxBlobEntry, TransactionBlobs};
|
||||||
pub use connection_state::ConnectionState;
|
pub use connection_state::ConnectionState;
|
||||||
pub use hard_fork::{HardFork, HardForkError};
|
pub use hard_fork::{HardFork, HardForkError};
|
||||||
|
pub use pool_info::PoolInfo;
|
||||||
|
pub use pool_info_extent::PoolInfoExtent;
|
||||||
pub use transaction_verification_data::{
|
pub use transaction_verification_data::{
|
||||||
CachedVerificationState, TransactionVerificationData, TxVersion,
|
CachedVerificationState, TransactionVerificationData, TxVersion,
|
||||||
};
|
};
|
||||||
pub use types::{
|
pub use types::{
|
||||||
AddAuxPow, AltBlockInformation, AuxPow, Chain, ChainId, ChainInfo, CoinbaseTxSum,
|
AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, TxsInBlock,
|
||||||
ExtendedBlockHeader, FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry,
|
|
||||||
OutputHistogramEntry, OutputHistogramInput, OutputOnChain, TxsInBlock,
|
|
||||||
VerifiedBlockInformation, VerifiedTransactionInformation,
|
VerifiedBlockInformation, VerifiedTransactionInformation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,25 +2,20 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use crate::misc::PoolInfoExtent;
|
use crate::pool_info_extent::PoolInfoExtent;
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use cuprate_epee_encoding::{
|
use cuprate_epee_encoding::{
|
||||||
epee_object, error,
|
error,
|
||||||
macros::bytes::{Buf, BufMut},
|
macros::bytes::{Buf, BufMut},
|
||||||
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder,
|
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_fixed_bytes::ByteArrayVec;
|
use cuprate_fixed_bytes::ByteArrayVec;
|
||||||
|
|
||||||
use crate::misc::PoolTxInfo;
|
use crate::rpc::{PoolInfoFull, PoolInfoIncremental, PoolTxInfo};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- PoolInfo
|
//---------------------------------------------------------------------------------------------------- PoolInfo
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
/// Used in RPC's `get_blocks.bin`.
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
|
||||||
223..=228
|
|
||||||
)]
|
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
@ -31,39 +26,6 @@ pub enum PoolInfo {
|
||||||
Full(PoolInfoFull),
|
Full(PoolInfoFull),
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Internal data
|
|
||||||
/// Data within [`PoolInfo::Incremental`].
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct PoolInfoIncremental {
|
|
||||||
pub added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
pub remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
pub removed_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
epee_object! {
|
|
||||||
PoolInfoIncremental,
|
|
||||||
added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
removed_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data within [`PoolInfo::Full`].
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct PoolInfoFull {
|
|
||||||
pub added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
pub remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
epee_object! {
|
|
||||||
PoolInfoFull,
|
|
||||||
added_pool_txs: Vec<PoolTxInfo>,
|
|
||||||
remaining_added_pool_txids: ByteArrayVec<32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- PoolInfo epee impl
|
//---------------------------------------------------------------------------------------------------- PoolInfo epee impl
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
/// [`EpeeObjectBuilder`] for [`GetBlocksResponse`].
|
/// [`EpeeObjectBuilder`] for [`GetBlocksResponse`].
|
|
@ -12,12 +12,7 @@ use cuprate_epee_encoding::{
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- PoolInfoExtent
|
//---------------------------------------------------------------------------------------------------- PoolInfoExtent
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
/// Used in RPC's `get_blocks.bin`.
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"rpc/core_rpc_server_commands_defs.h",
|
|
||||||
223..=228
|
|
||||||
)]
|
|
||||||
/// Used in [`crate::bin::GetBlocksResponse`].
|
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
586
types/src/rpc.rs
Normal file
586
types/src/rpc.rs
Normal file
|
@ -0,0 +1,586 @@
|
||||||
|
//! Various types (in)directly used in RPC.
|
||||||
|
//!
|
||||||
|
//! These types map very closely to types within `cuprate-rpc-types`,
|
||||||
|
//! however they use more canonical types when appropriate, for example,
|
||||||
|
//! instead of `hash: String`, this module's types would use something like
|
||||||
|
//! `hash: [u8; 32]`.
|
||||||
|
//!
|
||||||
|
//! - TODO: finish making fields canonical after <https://github.com/Cuprate/cuprate/pull/355>
|
||||||
|
//! - TODO: can epee handle `u128`? there are a lot of `(top_64 | low_64)` fields
|
||||||
|
|
||||||
|
use cuprate_fixed_bytes::ByteArrayVec;
|
||||||
|
|
||||||
|
use crate::{AddressType, ConnectionState};
|
||||||
|
|
||||||
|
const fn default_string() -> String {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_zero<T: From<u8>>() -> T {
|
||||||
|
T::from(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Output a string link to `monerod` source code.
|
||||||
|
macro_rules! monero_definition_link {
|
||||||
|
(
|
||||||
|
$commit:literal, // Git commit hash
|
||||||
|
$file_path:literal, // File path within `monerod`'s `src/`, e.g. `rpc/core_rpc_server_commands_defs.h`
|
||||||
|
$start:literal$(..=$end:literal)? // File lines, e.g. `0..=123` or `0`
|
||||||
|
) => {
|
||||||
|
concat!(
|
||||||
|
"[Definition](https://github.com/monero-project/monero/blob/",
|
||||||
|
stringify!($commit),
|
||||||
|
"/src/",
|
||||||
|
$file_path,
|
||||||
|
"#L",
|
||||||
|
stringify!($start),
|
||||||
|
$(
|
||||||
|
"-L",
|
||||||
|
stringify!($end),
|
||||||
|
)?
|
||||||
|
")."
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This macro (local to this file) defines all the misc types.
|
||||||
|
///
|
||||||
|
/// This macro:
|
||||||
|
/// 1. Defines a `struct` with all `pub` fields
|
||||||
|
/// 2. Implements `serde` on the struct
|
||||||
|
/// 3. Implements `epee` on the struct
|
||||||
|
///
|
||||||
|
/// When using, consider documenting:
|
||||||
|
/// - The original Monero definition site with [`monero_definition_link`]
|
||||||
|
/// - The request/responses where the `struct` is used
|
||||||
|
macro_rules! define_struct_and_impl_epee {
|
||||||
|
($(
|
||||||
|
// Optional `struct` attributes.
|
||||||
|
$( #[$struct_attr:meta] )*
|
||||||
|
// The `struct`'s name.
|
||||||
|
$struct_name:ident {
|
||||||
|
// And any fields.
|
||||||
|
$(
|
||||||
|
$( #[$field_attr:meta] )* // Field attributes
|
||||||
|
// Field name => the type => optional `epee_object` default value.
|
||||||
|
$field_name:ident: $field_type:ty $(= $field_default:expr_2021)?,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
)*) => {
|
||||||
|
$(
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
$( #[$struct_attr] )*
|
||||||
|
pub struct $struct_name {
|
||||||
|
$(
|
||||||
|
$( #[$field_attr] )*
|
||||||
|
pub $field_name: $field_type,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "epee")]
|
||||||
|
cuprate_epee_encoding::epee_object! {
|
||||||
|
$struct_name,
|
||||||
|
$(
|
||||||
|
$field_name: $field_type $(= $field_default)?,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1163..=1212
|
||||||
|
)]
|
||||||
|
BlockHeader {
|
||||||
|
block_size: u64,
|
||||||
|
block_weight: u64,
|
||||||
|
cumulative_difficulty_top64: u64,
|
||||||
|
cumulative_difficulty: u64,
|
||||||
|
depth: u64,
|
||||||
|
difficulty_top64: u64,
|
||||||
|
difficulty: u64,
|
||||||
|
hash: String,
|
||||||
|
height: u64,
|
||||||
|
long_term_weight: u64,
|
||||||
|
major_version: u8,
|
||||||
|
miner_tx_hash: String,
|
||||||
|
minor_version: u8,
|
||||||
|
nonce: u32,
|
||||||
|
num_txes: u64,
|
||||||
|
orphan_status: bool,
|
||||||
|
pow_hash: String,
|
||||||
|
prev_hash: String,
|
||||||
|
reward: u64,
|
||||||
|
timestamp: u64,
|
||||||
|
wide_cumulative_difficulty: String,
|
||||||
|
wide_difficulty: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"cryptonote_protocol/cryptonote_protocol_defs.h",
|
||||||
|
47..=116
|
||||||
|
)]
|
||||||
|
ConnectionInfo {
|
||||||
|
address: String,
|
||||||
|
address_type: AddressType,
|
||||||
|
avg_download: u64,
|
||||||
|
avg_upload: u64,
|
||||||
|
connection_id: String,
|
||||||
|
current_download: u64,
|
||||||
|
current_upload: u64,
|
||||||
|
height: u64,
|
||||||
|
host: String,
|
||||||
|
incoming: bool,
|
||||||
|
ip: String,
|
||||||
|
live_time: u64,
|
||||||
|
localhost: bool,
|
||||||
|
local_ip: bool,
|
||||||
|
peer_id: String,
|
||||||
|
port: String,
|
||||||
|
pruning_seed: u32,
|
||||||
|
recv_count: u64,
|
||||||
|
recv_idle_time: u64,
|
||||||
|
rpc_credits_per_hash: u32,
|
||||||
|
rpc_port: u16,
|
||||||
|
send_count: u64,
|
||||||
|
send_idle_time: u64,
|
||||||
|
// Exists in the original definition, but isn't
|
||||||
|
// used or (de)serialized for RPC purposes.
|
||||||
|
// ssl: bool,
|
||||||
|
state: ConnectionState,
|
||||||
|
support_flags: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2034..=2047
|
||||||
|
)]
|
||||||
|
SetBan {
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_string"))]
|
||||||
|
host: String,
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
ip: u32,
|
||||||
|
ban: bool,
|
||||||
|
seconds: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1999..=2010
|
||||||
|
)]
|
||||||
|
GetBan {
|
||||||
|
host: String,
|
||||||
|
ip: u32,
|
||||||
|
seconds: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2139..=2156
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
HistogramEntry {
|
||||||
|
amount: u64,
|
||||||
|
total_instances: u64,
|
||||||
|
unlocked_instances: u64,
|
||||||
|
recent_instances: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2180..=2191
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
HardforkEntry {
|
||||||
|
height: u64,
|
||||||
|
hf_version: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2289..=2310
|
||||||
|
)]
|
||||||
|
ChainInfo {
|
||||||
|
block_hash: [u8; 32],
|
||||||
|
block_hashes: Vec<[u8; 32]>,
|
||||||
|
difficulty_top64: u64,
|
||||||
|
difficulty_low64: u64,
|
||||||
|
height: u64,
|
||||||
|
length: u64,
|
||||||
|
main_chain_parent_block: [u8; 32],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2393..=2400
|
||||||
|
)]
|
||||||
|
SyncInfoPeer {
|
||||||
|
info: ConnectionInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2402..=2421
|
||||||
|
)]
|
||||||
|
Span {
|
||||||
|
connection_id: String,
|
||||||
|
nblocks: u64,
|
||||||
|
rate: u32,
|
||||||
|
remote_address: String,
|
||||||
|
size: u64,
|
||||||
|
speed: u32,
|
||||||
|
start_block_height: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1637..=1642
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
TxBacklogEntry {
|
||||||
|
weight: u64,
|
||||||
|
fee: u64,
|
||||||
|
time_in_pool: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/rpc_handler.h",
|
||||||
|
45..=50
|
||||||
|
)]
|
||||||
|
OutputDistributionData {
|
||||||
|
distribution: Vec<u64>,
|
||||||
|
start_height: u64,
|
||||||
|
base: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1016..=1027
|
||||||
|
)]
|
||||||
|
GetMinerDataTxBacklogEntry {
|
||||||
|
id: String,
|
||||||
|
weight: u64,
|
||||||
|
fee: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1070..=1079
|
||||||
|
)]
|
||||||
|
AuxPow {
|
||||||
|
id: [u8; 32],
|
||||||
|
hash: [u8; 32],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
192..=199
|
||||||
|
)]
|
||||||
|
TxOutputIndices {
|
||||||
|
indices: Vec<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
201..=208
|
||||||
|
)]
|
||||||
|
BlockOutputIndices {
|
||||||
|
indices: Vec<TxOutputIndices>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
512..=521
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
GetOutputsOut {
|
||||||
|
amount: u64,
|
||||||
|
index: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
538..=553
|
||||||
|
)]
|
||||||
|
OutKeyBin {
|
||||||
|
key: [u8; 32],
|
||||||
|
mask: [u8; 32],
|
||||||
|
unlocked: bool,
|
||||||
|
height: u64,
|
||||||
|
txid: [u8; 32],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1335..=1367
|
||||||
|
)]
|
||||||
|
Peer {
|
||||||
|
id: u64,
|
||||||
|
host: String,
|
||||||
|
ip: u32,
|
||||||
|
port: u16,
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
rpc_port: u16 = default_zero::<u16>(),
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
rpc_credits_per_hash: u32 = default_zero::<u32>(),
|
||||||
|
last_seen: u64,
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
pruning_seed: u32 = default_zero::<u32>(),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1398..=1417
|
||||||
|
)]
|
||||||
|
PublicNode {
|
||||||
|
host: String,
|
||||||
|
last_seen: u64,
|
||||||
|
rpc_port: u16,
|
||||||
|
rpc_credits_per_hash: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1519..=1556
|
||||||
|
)]
|
||||||
|
TxInfo {
|
||||||
|
blob_size: u64,
|
||||||
|
do_not_relay: bool,
|
||||||
|
double_spend_seen: bool,
|
||||||
|
fee: u64,
|
||||||
|
id_hash: String,
|
||||||
|
kept_by_block: bool,
|
||||||
|
last_failed_height: u64,
|
||||||
|
last_failed_id_hash: String,
|
||||||
|
last_relayed_time: u64,
|
||||||
|
max_used_block_height: u64,
|
||||||
|
max_used_block_id_hash: String,
|
||||||
|
receive_time: u64,
|
||||||
|
relayed: bool,
|
||||||
|
tx_blob: String,
|
||||||
|
tx_json: String, // TODO: this should be another struct
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_zero"))]
|
||||||
|
weight: u64 = default_zero::<u64>(),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1558..=1567
|
||||||
|
)]
|
||||||
|
SpentKeyImageInfo {
|
||||||
|
id_hash: String,
|
||||||
|
txs_hashes: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1666..=1675
|
||||||
|
)]
|
||||||
|
#[derive(Copy)]
|
||||||
|
TxpoolHisto {
|
||||||
|
txs: u32,
|
||||||
|
bytes: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1677..=1710
|
||||||
|
)]
|
||||||
|
TxpoolStats {
|
||||||
|
bytes_max: u32,
|
||||||
|
bytes_med: u32,
|
||||||
|
bytes_min: u32,
|
||||||
|
bytes_total: u64,
|
||||||
|
fee_total: u64,
|
||||||
|
histo_98pc: u64,
|
||||||
|
histo: Vec<TxpoolHisto>,
|
||||||
|
num_10m: u32,
|
||||||
|
num_double_spends: u32,
|
||||||
|
num_failing: u32,
|
||||||
|
num_not_relayed: u32,
|
||||||
|
oldest: u64,
|
||||||
|
txs_total: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"cc73fe71162d564ffda8e549b79a350bca53c454",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
582..=597
|
||||||
|
)]
|
||||||
|
OutKey {
|
||||||
|
key: String,
|
||||||
|
mask: String,
|
||||||
|
unlocked: bool,
|
||||||
|
height: u64,
|
||||||
|
txid: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"blockchain_db/lmdb/db_lmdb.cpp",
|
||||||
|
4222
|
||||||
|
)]
|
||||||
|
OutputHistogramInput {
|
||||||
|
amounts: Vec<u64>,
|
||||||
|
min_count: u64,
|
||||||
|
max_count: u64,
|
||||||
|
unlocked: bool,
|
||||||
|
recent_cutoff: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2139..=2156
|
||||||
|
)]
|
||||||
|
OutputHistogramEntry {
|
||||||
|
amount: u64,
|
||||||
|
total_instances: u64,
|
||||||
|
unlocked_instances: u64,
|
||||||
|
recent_instances: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2228..=2247
|
||||||
|
)]
|
||||||
|
CoinbaseTxSum {
|
||||||
|
emission_amount_top64: u64,
|
||||||
|
emission_amount_low64: u64,
|
||||||
|
fee_amount_top64: u64,
|
||||||
|
fee_amount_low64: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1027..=1033
|
||||||
|
)]
|
||||||
|
MinerData {
|
||||||
|
major_version: u8,
|
||||||
|
height: u64,
|
||||||
|
prev_id: [u8; 32],
|
||||||
|
seed_hash: [u8; 32],
|
||||||
|
difficulty_top64: u64,
|
||||||
|
difficulty_low64: u64,
|
||||||
|
median_weight: u64,
|
||||||
|
already_generated_coins: u64,
|
||||||
|
tx_backlog: Vec<MinerDataTxBacklogEntry>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1037..=1039
|
||||||
|
)]
|
||||||
|
MinerDataTxBacklogEntry {
|
||||||
|
id: [u8; 32],
|
||||||
|
weight: u64,
|
||||||
|
fee: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1973..=1980
|
||||||
|
)]
|
||||||
|
HardForkInfo {
|
||||||
|
earliest_height: u64,
|
||||||
|
enabled: bool,
|
||||||
|
state: u32,
|
||||||
|
threshold: u32,
|
||||||
|
version: u8,
|
||||||
|
votes: u32,
|
||||||
|
voting: u8,
|
||||||
|
window: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2264..=2267
|
||||||
|
)]
|
||||||
|
FeeEstimate {
|
||||||
|
fee: u64,
|
||||||
|
fees: Vec<u64>,
|
||||||
|
quantization_mask: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
1115..=1119
|
||||||
|
)]
|
||||||
|
AddAuxPow {
|
||||||
|
blocktemplate_blob: Vec<u8>,
|
||||||
|
blockhashing_blob: Vec<u8>,
|
||||||
|
merkle_root: [u8; 32],
|
||||||
|
merkle_tree_depth: u64,
|
||||||
|
aux_pow: Vec<AuxPow>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
227..=229
|
||||||
|
)]
|
||||||
|
PoolTxInfo {
|
||||||
|
tx_hash: [u8; 32],
|
||||||
|
tx_blob: Vec<u8>,
|
||||||
|
double_spend_seen: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
254..=256
|
||||||
|
)]
|
||||||
|
PoolInfoIncremental {
|
||||||
|
added_pool_txs: Vec<PoolTxInfo>,
|
||||||
|
remaining_added_pool_txids: ByteArrayVec<32>,
|
||||||
|
removed_pool_txids: ByteArrayVec<32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
"893916ad091a92e765ce3241b94e706ad012b62a",
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
254..=256
|
||||||
|
)]
|
||||||
|
PoolInfoFull {
|
||||||
|
added_pool_txs: Vec<PoolTxInfo>,
|
||||||
|
remaining_added_pool_txids: ByteArrayVec<32>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
// use super::*;
|
||||||
|
}
|
|
@ -147,118 +147,6 @@ pub struct OutputOnChain {
|
||||||
pub commitment: EdwardsPoint,
|
pub commitment: EdwardsPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Input required to generate an output histogram.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_output_histogram`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct OutputHistogramInput {
|
|
||||||
pub amounts: Vec<u64>,
|
|
||||||
pub min_count: u64,
|
|
||||||
pub max_count: u64,
|
|
||||||
pub unlocked: bool,
|
|
||||||
pub recent_cutoff: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A single entry in an output histogram.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_output_histogram`.
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct OutputHistogramEntry {
|
|
||||||
pub amount: u64,
|
|
||||||
pub total_instances: u64,
|
|
||||||
pub unlocked_instances: u64,
|
|
||||||
pub recent_instances: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data of summed coinbase transactions.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_coinbase_tx_sum`.
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct CoinbaseTxSum {
|
|
||||||
pub emission_amount: u128,
|
|
||||||
pub fee_amount: u128,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data to create a custom block template.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_miner_data`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct MinerData {
|
|
||||||
pub major_version: u8,
|
|
||||||
pub height: u64,
|
|
||||||
pub prev_id: [u8; 32],
|
|
||||||
pub seed_hash: [u8; 32],
|
|
||||||
pub difficulty: u128,
|
|
||||||
pub median_weight: u64,
|
|
||||||
pub already_generated_coins: u64,
|
|
||||||
pub tx_backlog: Vec<MinerDataTxBacklogEntry>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A transaction in the txpool.
|
|
||||||
///
|
|
||||||
/// Used in [`MinerData::tx_backlog`].
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct MinerDataTxBacklogEntry {
|
|
||||||
pub id: [u8; 32],
|
|
||||||
pub weight: u64,
|
|
||||||
pub fee: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information on a [`HardFork`].
|
|
||||||
///
|
|
||||||
/// Used in RPC's `hard_fork_info`.
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct HardForkInfo {
|
|
||||||
pub earliest_height: u64,
|
|
||||||
pub enabled: bool,
|
|
||||||
pub state: u32,
|
|
||||||
pub threshold: u32,
|
|
||||||
pub version: u8,
|
|
||||||
pub votes: u32,
|
|
||||||
pub voting: u8,
|
|
||||||
pub window: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Estimated fee data.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_fee_estimate`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct FeeEstimate {
|
|
||||||
pub fee: u64,
|
|
||||||
pub fees: Vec<u64>,
|
|
||||||
pub quantization_mask: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information on a (maybe alternate) chain.
|
|
||||||
///
|
|
||||||
/// Used in RPC's `get_alternate_chains`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct ChainInfo {
|
|
||||||
pub block_hash: [u8; 32],
|
|
||||||
pub block_hashes: Vec<[u8; 32]>,
|
|
||||||
pub difficulty: u128,
|
|
||||||
pub height: u64,
|
|
||||||
pub length: u64,
|
|
||||||
pub main_chain_parent_block: [u8; 32],
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used in RPC's `add_aux_pow`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct AuxPow {
|
|
||||||
pub id: [u8; 32],
|
|
||||||
pub hash: [u8; 32],
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used in RPC's `add_aux_pow`.
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct AddAuxPow {
|
|
||||||
pub blocktemplate_blob: Vec<u8>,
|
|
||||||
pub blockhashing_blob: Vec<u8>,
|
|
||||||
pub merkle_root: [u8; 32],
|
|
||||||
pub merkle_tree_depth: u64,
|
|
||||||
pub aux_pow: Vec<AuxPow>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The inner response for a request for txs in a block.
|
/// The inner response for a request for txs in a block.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct TxsInBlock {
|
pub struct TxsInBlock {
|
||||||
|
|
Loading…
Reference in a new issue