Compare commits

..

5 commits

Author SHA1 Message Date
hinto.janai
e2f25bd52d
get_info 2024-10-15 20:58:44 -04:00
hinto.janai
548639b2f6
generate_blocks 2024-10-15 20:14:15 -04:00
hinto.janai
d56477cd61
get_tx_ids_loose 2024-10-15 16:58:14 -04:00
hinto.janai
7148ba1668
add_aux_pow 2024-10-15 16:45:54 -04:00
hinto.janai
5926f24d22
calc_pow 2024-10-15 16:19:35 -04:00
11 changed files with 386 additions and 69 deletions

View file

@ -3,13 +3,13 @@
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use anyhow::Error; use anyhow::Error;
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;
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
use cuprate_consensus::BlockChainContextService;
use cuprate_pruning::PruningSeed;
use cuprate_rpc_interface::RpcHandler; use cuprate_rpc_interface::RpcHandler;
use cuprate_rpc_types::{ use cuprate_rpc_types::{
bin::{BinRequest, BinResponse}, bin::{BinRequest, BinResponse},
@ -17,12 +17,12 @@ use cuprate_rpc_types::{
other::{OtherRequest, OtherResponse}, other::{OtherRequest, OtherResponse},
}; };
use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle};
use cuprate_types::{AddAuxPow, AuxPow, HardFork};
use crate::rpc::{bin, json, other}; use crate::rpc::{bin, json, other};
/// TODO: use real type when public. /// TODO: use real type when public.
#[derive(Clone)] #[derive(Clone)]
#[expect(clippy::large_enum_variant)]
pub enum BlockchainManagerRequest { pub enum BlockchainManagerRequest {
/// Pop blocks off the top of the blockchain. /// Pop blocks off the top of the blockchain.
/// ///
@ -56,6 +56,38 @@ pub enum BlockchainManagerRequest {
/// The height of the next block in the chain. /// The height of the next block in the chain.
TargetHeight, TargetHeight,
/// Calculate proof-of-work for this block.
CalculatePow {
/// The hardfork of the protocol at this block height.
hardfork: HardFork,
/// The height of the block.
height: usize,
/// The block data.
block: Block,
/// The seed hash for the proof-of-work.
seed_hash: [u8; 32],
},
/// TODO
AddAuxPow {
/// TODO
blocktemplate_blob: Vec<u8>,
/// TODO
aux_pow: Vec<AuxPow>,
},
/// TODO
GenerateBlocks {
/// TODO
amount_of_blocks: u64,
/// TODO
prev_block: [u8; 32],
/// TODO
starting_nonce: u32,
/// TODO
wallet_address: String,
},
} }
/// TODO: use real type when public. /// TODO: use real type when public.
@ -88,6 +120,20 @@ pub enum BlockchainManagerResponse {
/// Response to [`BlockchainManagerRequest::TargetHeight`] /// Response to [`BlockchainManagerRequest::TargetHeight`]
TargetHeight { height: usize }, TargetHeight { height: usize },
/// Response to [`BlockchainManagerRequest::CalculatePow`]
CalculatePow([u8; 32]),
/// Response to [`BlockchainManagerRequest::AddAuxPow`]
AddAuxPow(AddAuxPow),
/// Response to [`BlockchainManagerRequest::GenerateBlocks`]
GenerateBlocks {
/// TODO
blocks: Vec<[u8; 32]>,
/// TODO
height: usize,
},
} }
/// TODO: use real type when public. /// TODO: use real type when public.

View file

@ -40,15 +40,22 @@ use cuprate_rpc_types::{
SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest, SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest,
SyncInfoResponse, SyncInfoResponse,
}, },
misc::{BlockHeader, ChainInfo, GetBan, HardforkEntry, HistogramEntry, Status, TxBacklogEntry}, misc::{
AuxPow, BlockHeader, ChainInfo, GetBan, HardforkEntry, HistogramEntry, Status,
TxBacklogEntry,
},
CORE_RPC_VERSION, CORE_RPC_VERSION,
}; };
use cuprate_types::HardFork; use cuprate_types::{Chain, HardFork};
use crate::rpc::{ use crate::{
constants::VERSION_BUILD,
rpc::{
helper, helper,
request::{address_book, blockchain, blockchain_context, blockchain_manager, txpool}, request::{address_book, blockchain, blockchain_context, blockchain_manager, txpool},
CupratedRpcHandler, CupratedRpcHandler,
},
statics::START_INSTANT_UNIX,
}; };
/// Map a [`JsonRpcRequest`] to the function that will lead to a [`JsonRpcResponse`]. /// Map a [`JsonRpcRequest`] to the function that will lead to a [`JsonRpcResponse`].
@ -158,10 +165,29 @@ async fn generate_blocks(
state: CupratedRpcHandler, state: CupratedRpcHandler,
request: GenerateBlocksRequest, request: GenerateBlocksRequest,
) -> Result<GenerateBlocksResponse, Error> { ) -> Result<GenerateBlocksResponse, Error> {
if todo!("active cuprated chain") != todo!("regtest chain") {
return Err(anyhow!("Regtest required when generating blocks"));
}
// TODO: is this value only used as a local variable in the handler?
// it may not be needed in the request type.
let prev_block = helper::hex_to_hash(request.prev_block)?;
let (blocks, height) = blockchain_manager::generate_blocks(
&mut state.blockchain_manager,
request.amount_of_blocks,
prev_block,
request.starting_nonce,
request.wallet_address,
)
.await?;
let blocks = blocks.into_iter().map(hex::encode).collect();
Ok(GenerateBlocksResponse { Ok(GenerateBlocksResponse {
base: ResponseBase::OK, base: ResponseBase::OK,
blocks: todo!(), blocks,
height: todo!(), height,
}) })
} }
@ -331,50 +357,120 @@ async fn get_connections(
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L501-L582> /// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L501-L582>
async fn get_info( async fn get_info(
state: CupratedRpcHandler, mut state: CupratedRpcHandler,
request: GetInfoRequest, request: GetInfoRequest,
) -> Result<GetInfoResponse, Error> { ) -> Result<GetInfoResponse, Error> {
let restricted = state.restricted();
let context = blockchain_context::context(&mut state.blockchain_context).await?;
let c = context.unchecked_blockchain_context();
let cumulative_difficulty = c.cumulative_difficulty;
let adjusted_time = c.current_adjusted_timestamp_for_time_lock(); // TODO: is this correct?
let c = &c.context_to_verify_block;
let alt_blocks_count = if restricted {
0
} else {
blockchain::alt_chain_count(&mut state.blockchain_read).await?
};
let block_weight_limit = usize_to_u64(c.effective_median_weight); // TODO: is this correct?
let block_weight_median = usize_to_u64(c.median_weight_for_block_reward); // TODO: is this correct?
let block_size_limit = block_weight_limit;
let block_size_median = block_weight_median;
let (bootstrap_daemon_address, was_bootstrap_ever_used) = if restricted {
(String::new(), false)
} else {
todo!()
};
let busy_syncing = blockchain_manager::syncing(&mut state.blockchain_manager).await?;
let (cumulative_difficulty, cumulative_difficulty_top64) =
split_u128_into_low_high_bits(cumulative_difficulty);
let (database_size, free_space) = blockchain::database_size(&mut state.blockchain_read).await?;
let (database_size, free_space) = if restricted {
let database_size = todo!(); // round_up(res.database_size, 5ull* 1024 * 1024 * 1024) */
(database_size, u64::MAX)
} else {
(database_size, free_space)
};
let (difficulty, difficulty_top64) = split_u128_into_low_high_bits(c.next_difficulty);
let height = usize_to_u64(c.chain_height);
let height_without_bootstrap = if restricted { 0 } else { height };
let (incoming_connections_count, outgoing_connections_count) = if restricted {
(0, 0)
} else {
address_book::connection_count::<ClearNet>(&mut DummyAddressBook).await?
};
let mainnet = todo!();
let nettype = todo!();
let offline = todo!();
let rpc_connections_count = if restricted { 0 } else { todo!() };
let stagenet = todo!();
let start_time = if restricted { 0 } else { *START_INSTANT_UNIX };
let synchronized = blockchain_manager::synced(&mut state.blockchain_manager).await?;
let target_height = blockchain_manager::target_height(&mut state.blockchain_manager).await?;
let target = blockchain_manager::target(&mut state.blockchain_manager)
.await?
.as_secs();
let testnet = todo!();
let top_block_hash = hex::encode(c.top_hash);
let tx_count = blockchain::total_tx_count(&mut state.blockchain_read).await?;
let tx_pool_size = txpool::size(&mut state.txpool_read, !restricted).await?;
let update_available = if restricted { false } else { todo!() };
let version = if restricted {
String::new()
} else {
VERSION_BUILD.to_string()
};
let (white_peerlist_size, grey_peerlist_size) = if restricted {
(0, 0)
} else {
address_book::peerlist_size::<ClearNet>(&mut DummyAddressBook).await?
};
let wide_cumulative_difficulty = format!("{cumulative_difficulty:#x}");
let wide_difficulty = format!("{:#x}", c.next_difficulty);
Ok(GetInfoResponse { Ok(GetInfoResponse {
base: AccessResponseBase::OK, base: AccessResponseBase::OK,
adjusted_time: todo!(), adjusted_time,
alt_blocks_count: todo!(), alt_blocks_count,
block_size_limit: todo!(), block_size_limit,
block_size_median: todo!(), block_size_median,
block_weight_limit: todo!(), block_weight_limit,
block_weight_median: todo!(), block_weight_median,
bootstrap_daemon_address: todo!(), bootstrap_daemon_address,
busy_syncing: todo!(), busy_syncing,
cumulative_difficulty_top64: todo!(), cumulative_difficulty_top64,
cumulative_difficulty: todo!(), cumulative_difficulty,
database_size: todo!(), database_size,
difficulty_top64: todo!(), difficulty_top64,
difficulty: todo!(), difficulty,
free_space: todo!(), free_space,
grey_peerlist_size: todo!(), grey_peerlist_size,
height: todo!(), height,
height_without_bootstrap: todo!(), height_without_bootstrap,
incoming_connections_count: todo!(), incoming_connections_count,
mainnet: todo!(), mainnet,
nettype: todo!(), nettype,
offline: todo!(), offline,
outgoing_connections_count: todo!(), outgoing_connections_count,
restricted: todo!(), restricted,
rpc_connections_count: todo!(), rpc_connections_count,
stagenet: todo!(), stagenet,
start_time: todo!(), start_time,
synchronized: todo!(), synchronized,
target_height: todo!(), target_height,
target: todo!(), target,
testnet: todo!(), testnet,
top_block_hash: todo!(), top_block_hash,
tx_count: todo!(), tx_count,
tx_pool_size: todo!(), tx_pool_size,
update_available: todo!(), update_available,
version: todo!(), version,
was_bootstrap_ever_used: todo!(), was_bootstrap_ever_used,
white_peerlist_size: todo!(), white_peerlist_size,
wide_cumulative_difficulty: todo!(), wide_cumulative_difficulty,
wide_difficulty: todo!(), wide_difficulty,
}) })
} }
@ -734,10 +830,26 @@ async fn prune_blockchain(
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2035-L2070> /// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2035-L2070>
async fn calc_pow( async fn calc_pow(
state: CupratedRpcHandler, mut state: CupratedRpcHandler,
request: CalcPowRequest, mut request: CalcPowRequest,
) -> Result<CalcPowResponse, Error> { ) -> Result<CalcPowResponse, Error> {
Ok(CalcPowResponse { pow_hash: todo!() }) let hardfork = HardFork::from_version(request.major_version)?;
let mut block_blob: Vec<u8> = hex::decode(request.block_blob)?;
let block = Block::read(&mut block_blob.as_slice())?;
let seed_hash = helper::hex_to_hash(request.seed_hash)?;
let pow_hash = blockchain_manager::calculate_pow(
&mut state.blockchain_manager,
hardfork,
request.height,
block,
seed_hash,
)
.await?;
let hex = hex::encode(pow_hash);
Ok(CalcPowResponse { pow_hash: hex })
} }
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3542-L3551> /// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3542-L3551>
@ -745,7 +857,7 @@ async fn flush_cache(
state: CupratedRpcHandler, state: CupratedRpcHandler,
request: FlushCacheRequest, request: FlushCacheRequest,
) -> Result<FlushCacheResponse, Error> { ) -> Result<FlushCacheResponse, Error> {
todo!(); // TODO: cuprated doesn't need this call; decide behavior.
Ok(FlushCacheResponse { Ok(FlushCacheResponse {
base: ResponseBase::OK, base: ResponseBase::OK,
@ -754,16 +866,43 @@ async fn flush_cache(
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2072-L2207> /// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2072-L2207>
async fn add_aux_pow( async fn add_aux_pow(
state: CupratedRpcHandler, mut state: CupratedRpcHandler,
request: AddAuxPowRequest, request: AddAuxPowRequest,
) -> Result<AddAuxPowResponse, Error> { ) -> Result<AddAuxPowResponse, Error> {
let blocktemplate_blob = hex::decode(request.blocktemplate_blob)?;
let aux_pow = request
.aux_pow
.into_iter()
.map(|aux| {
let id = helper::hex_to_hash(aux.id)?;
let hash = helper::hex_to_hash(aux.hash)?;
Ok(cuprate_types::AuxPow { id, hash })
})
.collect::<Result<Vec<_>, Error>>()?;
let resp =
blockchain_manager::add_aux_pow(&mut state.blockchain_manager, blocktemplate_blob, aux_pow)
.await?;
let blocktemplate_blob = hex::encode(resp.blocktemplate_blob);
let blockhashing_blob = hex::encode(resp.blockhashing_blob);
let merkle_root = hex::encode(resp.merkle_root);
let aux_pow = resp
.aux_pow
.into_iter()
.map(|aux| AuxPow {
id: hex::encode(aux.id),
hash: hex::encode(aux.hash),
})
.collect::<Vec<AuxPow>>();
Ok(AddAuxPowResponse { Ok(AddAuxPowResponse {
base: ResponseBase::OK, base: ResponseBase::OK,
blocktemplate_blob: todo!(), blocktemplate_blob,
blockhashing_blob: todo!(), blockhashing_blob,
merkle_root: todo!(), merkle_root,
merkle_tree_depth: todo!(), merkle_tree_depth: resp.merkle_tree_depth,
aux_pow: todo!(), aux_pow,
}) })
} }
@ -772,6 +911,9 @@ async fn get_tx_ids_loose(
state: CupratedRpcHandler, state: CupratedRpcHandler,
request: GetTxIdsLooseRequest, request: GetTxIdsLooseRequest,
) -> Result<GetTxIdsLooseResponse, Error> { ) -> Result<GetTxIdsLooseResponse, Error> {
// TODO: this RPC call is not yet in the v0.18 branch.
return Err(anyhow!("not implemented"));
Ok(GetTxIdsLooseResponse { Ok(GetTxIdsLooseResponse {
base: ResponseBase::OK, base: ResponseBase::OK,
txids: todo!(), txids: todo!(),

View file

@ -375,3 +375,19 @@ pub(crate) async fn alt_chains(
Ok(vec) Ok(vec)
} }
/// [`BlockchainReadRequest::AltChainCount`]
pub(crate) async fn alt_chain_count(
blockchain_read: &mut BlockchainReadHandle,
) -> Result<u64, Error> {
let BlockchainResponse::AltChainCount(count) = blockchain_read
.ready()
.await?
.call(BlockchainReadRequest::AltChainCount)
.await?
else {
unreachable!();
};
Ok(usize_to_u64(count))
}

View file

@ -1,6 +1,7 @@
//! Functions for [`BlockchainManagerRequest`] & [`BlockchainManagerResponse`]. //! Functions for [`BlockchainManagerRequest`] & [`BlockchainManagerResponse`].
use anyhow::Error; use anyhow::Error;
use cuprate_types::{AddAuxPow, AuxPow, HardFork};
use monero_serai::block::Block; use monero_serai::block::Block;
use tower::{Service, ServiceExt}; use tower::{Service, ServiceExt};
@ -142,3 +143,74 @@ pub(crate) async fn target_height(
Ok(usize_to_u64(height)) Ok(usize_to_u64(height))
} }
/// [`BlockchainManagerRequest::CalculatePow`]
pub(crate) async fn calculate_pow(
blockchain_manager: &mut BlockchainManagerHandle,
hardfork: HardFork,
height: u64,
block: Block,
seed_hash: [u8; 32],
) -> Result<[u8; 32], Error> {
let BlockchainManagerResponse::CalculatePow(hash) = blockchain_manager
.ready()
.await?
.call(BlockchainManagerRequest::CalculatePow {
hardfork,
height: u64_to_usize(height),
block,
seed_hash,
})
.await?
else {
unreachable!();
};
Ok(hash)
}
/// [`BlockchainManagerRequest::AddAuxPow`]
pub(crate) async fn add_aux_pow(
blockchain_manager: &mut BlockchainManagerHandle,
blocktemplate_blob: Vec<u8>,
aux_pow: Vec<AuxPow>,
) -> Result<AddAuxPow, Error> {
let BlockchainManagerResponse::AddAuxPow(response) = blockchain_manager
.ready()
.await?
.call(BlockchainManagerRequest::AddAuxPow {
blocktemplate_blob,
aux_pow,
})
.await?
else {
unreachable!();
};
Ok(response)
}
/// [`BlockchainManagerRequest::GenerateBlocks`]
pub(crate) async fn generate_blocks(
blockchain_manager: &mut BlockchainManagerHandle,
amount_of_blocks: u64,
prev_block: [u8; 32],
starting_nonce: u32,
wallet_address: String,
) -> Result<(Vec<[u8; 32]>, u64), Error> {
let BlockchainManagerResponse::GenerateBlocks { blocks, height } = blockchain_manager
.ready()
.await?
.call(BlockchainManagerRequest::GenerateBlocks {
amount_of_blocks,
prev_block,
starting_nonce,
wallet_address,
})
.await?
else {
unreachable!();
};
Ok((blocks, usize_to_u64(height)))
}

View file

@ -33,12 +33,17 @@ pub(crate) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<Tx
} }
/// [`TxpoolReadRequest::Size`] /// [`TxpoolReadRequest::Size`]
pub(crate) async fn size(txpool_read: &mut TxpoolReadHandle) -> Result<u64, Error> { pub(crate) async fn size(
txpool_read: &mut TxpoolReadHandle,
include_sensitive_txs: bool,
) -> Result<u64, Error> {
let TxpoolReadResponse::Size(size) = txpool_read let TxpoolReadResponse::Size(size) = txpool_read
.ready() .ready()
.await .await
.map_err(|e| anyhow!(e))? .map_err(|e| anyhow!(e))?
.call(TxpoolReadRequest::Size) .call(TxpoolReadRequest::Size {
include_sensitive_txs,
})
.await .await
.map_err(|e| anyhow!(e))? .map_err(|e| anyhow!(e))?
else { else {

View file

@ -123,6 +123,7 @@ fn map_request(
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::HardForks => hard_forks(env),
R::AltChains => alt_chains(env), R::AltChains => alt_chains(env),
R::AltChainCount => alt_chain_count(env),
} }
/* SOMEDAY: post-request handling, run some code for each request? */ /* SOMEDAY: post-request handling, run some code for each request? */
@ -660,3 +661,8 @@ fn hard_forks(env: &ConcreteEnv) -> ResponseResult {
fn alt_chains(env: &ConcreteEnv) -> ResponseResult { fn alt_chains(env: &ConcreteEnv) -> ResponseResult {
Ok(BlockchainResponse::AltChains(todo!())) Ok(BlockchainResponse::AltChains(todo!()))
} }
/// [`BlockchainReadRequest::AltChainCount`]
fn alt_chain_count(env: &ConcreteEnv) -> ResponseResult {
Ok(BlockchainResponse::AltChainCount(todo!()))
}

View file

@ -20,7 +20,10 @@ pub enum TxpoolReadRequest {
Backlog, Backlog,
/// Get the number of transactions in the pool. /// Get the number of transactions in the pool.
Size, Size {
/// TODO
include_sensitive_txs: bool,
},
} }
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse //---------------------------------------------------------------------------------------------------- TxpoolReadResponse

View file

@ -66,7 +66,9 @@ fn map_request(
TxpoolReadRequest::TxBlob(tx_hash) => tx_blob(env, &tx_hash), TxpoolReadRequest::TxBlob(tx_hash) => tx_blob(env, &tx_hash),
TxpoolReadRequest::TxVerificationData(tx_hash) => tx_verification_data(env, &tx_hash), TxpoolReadRequest::TxVerificationData(tx_hash) => tx_verification_data(env, &tx_hash),
TxpoolReadRequest::Backlog => backlog(env), TxpoolReadRequest::Backlog => backlog(env),
TxpoolReadRequest::Size => size(env), TxpoolReadRequest::Size {
include_sensitive_txs,
} => size(env, include_sensitive_txs),
} }
} }
@ -119,6 +121,6 @@ fn backlog(env: &ConcreteEnv) -> ReadResponseResult {
/// [`TxpoolReadRequest::Size`]. /// [`TxpoolReadRequest::Size`].
#[inline] #[inline]
fn size(env: &ConcreteEnv) -> ReadResponseResult { fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
Ok(TxpoolReadResponse::Size(todo!())) Ok(TxpoolReadResponse::Size(todo!()))
} }

View file

@ -135,6 +135,9 @@ pub enum BlockchainReadRequest {
/// TODO /// TODO
AltChains, AltChains,
/// TODO
AltChainCount,
} }
//---------------------------------------------------------------------------------------------------- WriteRequest //---------------------------------------------------------------------------------------------------- WriteRequest
@ -289,8 +292,12 @@ pub enum BlockchainResponse {
/// - Value = hardfork version /// - Value = hardfork version
HardForks(BTreeMap<usize, HardFork>), HardForks(BTreeMap<usize, HardFork>),
/// TODO
AltChains(Vec<ChainInfo>), AltChains(Vec<ChainInfo>),
/// Response to [`BlockchainReadRequest::AltChainCount`].
AltChainCount(usize),
//------------------------------------------------------ Writes //------------------------------------------------------ Writes
/// A generic Ok response to indicate a request was successfully handled. /// A generic Ok response to indicate a request was successfully handled.
/// ///

View file

@ -20,9 +20,10 @@ pub use transaction_verification_data::{
CachedVerificationState, TransactionVerificationData, TxVersion, CachedVerificationState, TransactionVerificationData, TxVersion,
}; };
pub use types::{ pub use types::{
AltBlockInformation, Chain, ChainId, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, AddAuxPow, AltBlockInformation, AuxPow, Chain, ChainId, ChainInfo, CoinbaseTxSum,
FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry, OutputHistogramEntry, ExtendedBlockHeader, FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry,
OutputHistogramInput, OutputOnChain, VerifiedBlockInformation, VerifiedTransactionInformation, OutputHistogramEntry, OutputHistogramInput, OutputOnChain, VerifiedBlockInformation,
VerifiedTransactionInformation,
}; };
//---------------------------------------------------------------------------------------------------- Feature-gated //---------------------------------------------------------------------------------------------------- Feature-gated

View file

@ -242,6 +242,23 @@ pub struct ChainInfo {
pub main_chain_parent_block: [u8; 32], 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>,
}
//---------------------------------------------------------------------------------------------------- Tests //---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)] #[cfg(test)]
mod test { mod test {