mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-11 05:15:24 +00:00
sig docs, remove HardForks
request
This commit is contained in:
parent
98dfaa4870
commit
13eedc6d80
8 changed files with 36 additions and 52 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1010,6 +1010,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"thiserror",
|
||||
"thread_local",
|
||||
"tokio",
|
||||
|
|
|
@ -65,6 +65,7 @@ rayon = { workspace = true }
|
|||
serde_bytes = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
strum = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
thread_local = { workspace = true }
|
||||
tokio-util = { workspace = true }
|
||||
|
|
|
@ -5,7 +5,9 @@ use std::{
|
|||
|
||||
use anyhow::{anyhow, Error};
|
||||
use cuprate_p2p_core::{client::handshaker::builder::DummyAddressBook, ClearNet};
|
||||
use futures::TryFutureExt;
|
||||
use monero_serai::block::Block;
|
||||
use strum::{EnumCount, VariantArray};
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_consensus::{BlockchainReadRequest, BlockchainResponse};
|
||||
|
@ -673,14 +675,20 @@ async fn get_version(
|
|||
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();
|
||||
let mut hard_forks = Vec::with_capacity(HardFork::COUNT);
|
||||
|
||||
// FIXME: use an iterator `collect()` version.
|
||||
for hf in HardFork::VARIANTS {
|
||||
if let Ok(hf) = blockchain_context::hard_fork_info(&mut state.blockchain_context, *hf).await
|
||||
{
|
||||
let entry = HardforkEntry {
|
||||
height: hf.earliest_height,
|
||||
hf_version: hf.version,
|
||||
};
|
||||
|
||||
hard_forks.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(GetVersionResponse {
|
||||
base: ResponseBase::OK,
|
||||
|
|
|
@ -344,22 +344,6 @@ pub(crate) async fn coinbase_tx_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,
|
||||
|
|
|
@ -121,7 +121,6 @@ fn map_request(
|
|||
R::DatabaseSize => database_size(env),
|
||||
R::OutputHistogram(input) => output_histogram(env, input),
|
||||
R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count),
|
||||
R::HardForks => hard_forks(env),
|
||||
R::AltChains => alt_chains(env),
|
||||
R::AltChainCount => alt_chain_count(env),
|
||||
}
|
||||
|
@ -652,11 +651,6 @@ fn coinbase_tx_sum(env: &ConcreteEnv, height: usize, count: u64) -> ResponseResu
|
|||
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!()))
|
||||
|
|
|
@ -22,12 +22,16 @@ pub enum TxpoolReadRequest {
|
|||
/// Get information on all transactions in the pool.
|
||||
Backlog,
|
||||
|
||||
/// TODO
|
||||
/// Get information on all transactions in
|
||||
/// the pool for block template purposes.
|
||||
///
|
||||
/// This is only slightly different to [`TxpoolReadRequest::Backlog`].
|
||||
BlockTemplateBacklog,
|
||||
|
||||
/// Get the number of transactions in the pool.
|
||||
Size {
|
||||
/// TODO
|
||||
/// If this is [`true`], the size returned will
|
||||
/// include private transactions in the pool.
|
||||
include_sensitive_txs: bool,
|
||||
},
|
||||
}
|
||||
|
@ -47,13 +51,13 @@ pub enum TxpoolReadResponse {
|
|||
|
||||
/// Response to [`TxpoolReadRequest::Backlog`].
|
||||
///
|
||||
/// The inner `Vec` contains information on all
|
||||
/// The inner [`Vec`] contains information on all
|
||||
/// the transactions currently in the pool.
|
||||
Backlog(Vec<TxEntry>),
|
||||
|
||||
/// Response to [`TxpoolReadRequest::BlockTemplateBacklog`].
|
||||
///
|
||||
/// TODO
|
||||
/// The inner [`Vec`] contains information on transactions
|
||||
BlockTemplateBacklog(Vec<BlockTemplateTxEntry>),
|
||||
|
||||
/// Response to [`TxpoolReadRequest::Size`].
|
||||
|
|
|
@ -13,15 +13,16 @@ pub struct TxEntry {
|
|||
pub time_in_pool: std::time::Duration,
|
||||
}
|
||||
|
||||
/// TODO
|
||||
/// Data about a transaction in the pool
|
||||
/// for use in a block template.
|
||||
///
|
||||
/// Used in [`TxpoolReadResponse::BlockTemplateBacklog`](crate::service::interface::TxpoolReadResponse::BlockTemplateBacklog).
|
||||
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
||||
pub struct BlockTemplateTxEntry {
|
||||
/// TODO
|
||||
/// The transaction's ID (hash).
|
||||
pub id: [u8; 32],
|
||||
/// TODO
|
||||
/// The transaction's weight.
|
||||
pub weight: u64,
|
||||
/// TODO
|
||||
/// The transaction's fee.
|
||||
pub fee: u64,
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//! responses are also tested in Cuprate's blockchain database crate.
|
||||
//---------------------------------------------------------------------------------------------------- Import
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
collections::{HashMap, HashSet},
|
||||
ops::Range,
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@ use monero_serai::block::Block;
|
|||
|
||||
use crate::{
|
||||
types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation},
|
||||
AltBlockInformation, ChainId, ChainInfo, CoinbaseTxSum, HardFork, OutputHistogramEntry,
|
||||
AltBlockInformation, ChainId, ChainInfo, CoinbaseTxSum, OutputHistogramEntry,
|
||||
OutputHistogramInput,
|
||||
};
|
||||
|
||||
|
@ -130,13 +130,10 @@ pub enum BlockchainReadRequest {
|
|||
/// TODO: document fields after impl.
|
||||
CoinbaseTxSum { height: usize, count: u64 },
|
||||
|
||||
/// TODO
|
||||
HardForks,
|
||||
|
||||
/// TODO
|
||||
/// Get information on all alternative chains.
|
||||
AltChains,
|
||||
|
||||
/// TODO
|
||||
/// Get the amount of alternative chains that exist.
|
||||
AltChainCount,
|
||||
}
|
||||
|
||||
|
@ -286,13 +283,7 @@ pub enum BlockchainResponse {
|
|||
/// Response to [`BlockchainReadRequest::CoinbaseTxSum`].
|
||||
CoinbaseTxSum(CoinbaseTxSum),
|
||||
|
||||
/// Response to [`BlockchainReadRequest::HardForks`].
|
||||
///
|
||||
/// - Key = height at which the hardfork activated
|
||||
/// - Value = hardfork version
|
||||
HardForks(BTreeMap<usize, HardFork>),
|
||||
|
||||
/// TODO
|
||||
/// Response to [`BlockchainReadRequest::AltChains`].
|
||||
AltChains(Vec<ChainInfo>),
|
||||
|
||||
/// Response to [`BlockchainReadRequest::AltChainCount`].
|
||||
|
|
Loading…
Reference in a new issue