mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-25 11:55:53 +00:00
Compare commits
No commits in common. "13eedc6d800ed9d0857dd442ceffb6ca6cdaa5dd" and "bf07f2c84c196e46849c921fc0302692f751e8f6" have entirely different histories.
13eedc6d80
...
bf07f2c84c
14 changed files with 91 additions and 249 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1010,7 +1010,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"strum",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|
|
@ -65,7 +65,6 @@ rayon = { workspace = true }
|
||||||
serde_bytes = { workspace = true }
|
serde_bytes = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
strum = { workspace = true }
|
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
thread_local = { workspace = true }
|
thread_local = { workspace = true }
|
||||||
tokio-util = { workspace = true }
|
tokio-util = { workspace = true }
|
||||||
|
|
|
@ -5,9 +5,7 @@ use std::{
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use cuprate_p2p_core::{client::handshaker::builder::DummyAddressBook, ClearNet};
|
use cuprate_p2p_core::{client::handshaker::builder::DummyAddressBook, ClearNet};
|
||||||
use futures::TryFutureExt;
|
|
||||||
use monero_serai::block::Block;
|
use monero_serai::block::Block;
|
||||||
use strum::{EnumCount, VariantArray};
|
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
use cuprate_consensus::{BlockchainReadRequest, BlockchainResponse};
|
use cuprate_consensus::{BlockchainReadRequest, BlockchainResponse};
|
||||||
|
@ -675,20 +673,14 @@ async fn get_version(
|
||||||
let current_height = helper::top_height(&mut state).await?.0;
|
let current_height = helper::top_height(&mut state).await?.0;
|
||||||
let target_height = blockchain_manager::target_height(&mut state.blockchain_manager).await?;
|
let target_height = blockchain_manager::target_height(&mut state.blockchain_manager).await?;
|
||||||
|
|
||||||
let mut hard_forks = Vec::with_capacity(HardFork::COUNT);
|
let hard_forks = blockchain::hard_forks(&mut state.blockchain_read)
|
||||||
|
.await?
|
||||||
// FIXME: use an iterator `collect()` version.
|
.into_iter()
|
||||||
for hf in HardFork::VARIANTS {
|
.map(|(height, hf)| HardforkEntry {
|
||||||
if let Ok(hf) = blockchain_context::hard_fork_info(&mut state.blockchain_context, *hf).await
|
height: usize_to_u64(height),
|
||||||
{
|
hf_version: hf.as_u8(),
|
||||||
let entry = HardforkEntry {
|
})
|
||||||
height: hf.earliest_height,
|
.collect();
|
||||||
hf_version: hf.version,
|
|
||||||
};
|
|
||||||
|
|
||||||
hard_forks.push(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(GetVersionResponse {
|
Ok(GetVersionResponse {
|
||||||
base: ResponseBase::OK,
|
base: ResponseBase::OK,
|
||||||
|
|
|
@ -52,45 +52,32 @@ pub(crate) async fn connection_info<Z: NetworkZone>(
|
||||||
// FIXME: impl this map somewhere instead of inline.
|
// FIXME: impl this map somewhere instead of inline.
|
||||||
let vec = vec
|
let vec = vec
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|info| {
|
.map(|info| ConnectionInfo {
|
||||||
use cuprate_p2p_core::types::AddressType as A1;
|
address: info.address.to_string(),
|
||||||
use cuprate_rpc_types::misc::AddressType as A2;
|
address_type: info.address_type,
|
||||||
|
avg_download: info.avg_download,
|
||||||
let address_type = match info.address_type {
|
avg_upload: info.avg_upload,
|
||||||
A1::Invalid => A2::Invalid,
|
connection_id: info.connection_id,
|
||||||
A1::Ipv4 => A2::Ipv4,
|
current_download: info.current_download,
|
||||||
A1::Ipv6 => A2::Ipv6,
|
current_upload: info.current_upload,
|
||||||
A1::I2p => A2::I2p,
|
height: info.height,
|
||||||
A1::Tor => A2::Tor,
|
host: info.host,
|
||||||
};
|
incoming: info.incoming,
|
||||||
|
ip: info.ip,
|
||||||
ConnectionInfo {
|
live_time: info.live_time,
|
||||||
address: info.address.to_string(),
|
localhost: info.localhost,
|
||||||
address_type,
|
local_ip: info.local_ip,
|
||||||
avg_download: info.avg_download,
|
peer_id: info.peer_id,
|
||||||
avg_upload: info.avg_upload,
|
port: info.port,
|
||||||
connection_id: hex::encode(info.connection_id.to_ne_bytes()),
|
pruning_seed: info.pruning_seed,
|
||||||
current_download: info.current_download,
|
recv_count: info.recv_count,
|
||||||
current_upload: info.current_upload,
|
recv_idle_time: info.recv_idle_time,
|
||||||
height: info.height,
|
rpc_credits_per_hash: info.rpc_credits_per_hash,
|
||||||
host: info.host,
|
rpc_port: info.rpc_port,
|
||||||
incoming: info.incoming,
|
send_count: info.send_count,
|
||||||
ip: info.ip,
|
send_idle_time: info.send_idle_time,
|
||||||
live_time: info.live_time,
|
state: info.state,
|
||||||
localhost: info.localhost,
|
support_flags: info.support_flags,
|
||||||
local_ip: info.local_ip,
|
|
||||||
peer_id: info.peer_id,
|
|
||||||
port: info.port,
|
|
||||||
pruning_seed: info.pruning_seed.compress(),
|
|
||||||
recv_count: info.recv_count,
|
|
||||||
recv_idle_time: info.recv_idle_time,
|
|
||||||
rpc_credits_per_hash: info.rpc_credits_per_hash,
|
|
||||||
rpc_port: info.rpc_port,
|
|
||||||
send_count: info.send_count,
|
|
||||||
send_idle_time: info.send_idle_time,
|
|
||||||
state: info.state,
|
|
||||||
support_flags: info.support_flags,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -190,10 +177,10 @@ pub(crate) async fn spans<Z: NetworkZone>(
|
||||||
let vec = vec
|
let vec = vec
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|span| Span {
|
.map(|span| Span {
|
||||||
connection_id: hex::encode(span.connection_id.to_ne_bytes()),
|
connection_id: span.connection_id,
|
||||||
nblocks: span.nblocks,
|
nblocks: span.nblocks,
|
||||||
rate: span.rate,
|
rate: span.rate,
|
||||||
remote_address: span.remote_address.to_string(),
|
remote_address: span.remote_address,
|
||||||
size: span.size,
|
size: span.size,
|
||||||
speed: span.speed,
|
speed: span.speed,
|
||||||
start_block_height: span.start_block_height,
|
start_block_height: span.start_block_height,
|
||||||
|
|
|
@ -344,6 +344,22 @@ pub(crate) async fn coinbase_tx_sum(
|
||||||
Ok(sum)
|
Ok(sum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainReadRequest::HardForks`]
|
||||||
|
pub(crate) async fn hard_forks(
|
||||||
|
blockchain_read: &mut BlockchainReadHandle,
|
||||||
|
) -> Result<BTreeMap<usize, HardFork>, Error> {
|
||||||
|
let BlockchainResponse::HardForks(hfs) = blockchain_read
|
||||||
|
.ready()
|
||||||
|
.await?
|
||||||
|
.call(BlockchainReadRequest::HardForks)
|
||||||
|
.await?
|
||||||
|
else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(hfs)
|
||||||
|
}
|
||||||
|
|
||||||
/// [`BlockchainReadRequest::AltChains`]
|
/// [`BlockchainReadRequest::AltChains`]
|
||||||
pub(crate) async fn alt_chains(
|
pub(crate) async fn alt_chains(
|
||||||
blockchain_read: &mut BlockchainReadHandle,
|
blockchain_read: &mut BlockchainReadHandle,
|
||||||
|
|
|
@ -133,13 +133,10 @@ pub enum AddressBookRequest<Z: NetworkZone> {
|
||||||
/// Get the state of all bans.
|
/// Get the state of all bans.
|
||||||
GetBans,
|
GetBans,
|
||||||
|
|
||||||
/// Get [`Span`] data.
|
/// TODO
|
||||||
///
|
|
||||||
/// This is data that describes an active downloading process,
|
|
||||||
/// if we are fully synced, this will return an empty [`Vec`].
|
|
||||||
Spans,
|
Spans,
|
||||||
|
|
||||||
/// Get the next [`PruningSeed`] needed for a pruned sync.
|
/// TODO
|
||||||
NextNeededPruningSeed,
|
NextNeededPruningSeed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +177,7 @@ pub enum AddressBookResponse<Z: NetworkZone> {
|
||||||
GetBans(Vec<BanState<Z::Addr>>),
|
GetBans(Vec<BanState<Z::Addr>>),
|
||||||
|
|
||||||
/// Response to [`AddressBookRequest::Spans`].
|
/// Response to [`AddressBookRequest::Spans`].
|
||||||
Spans(Vec<Span<Z::Addr>>),
|
Spans(Vec<Span>),
|
||||||
|
|
||||||
/// Response to [`AddressBookRequest::NextNeededPruningSeed`].
|
/// Response to [`AddressBookRequest::NextNeededPruningSeed`].
|
||||||
NextNeededPruningSeed(PruningSeed),
|
NextNeededPruningSeed(PruningSeed),
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use cuprate_pruning::PruningSeed;
|
|
||||||
|
|
||||||
use crate::NetZoneAddress;
|
use crate::NetZoneAddress;
|
||||||
|
|
||||||
/// Data within [`crate::services::AddressBookRequest::SetBan`].
|
/// Data within [`crate::services::AddressBookRequest::SetBan`].
|
||||||
|
@ -24,72 +22,15 @@ pub struct BanState<A: NetZoneAddress> {
|
||||||
pub unban_instant: Option<Instant>,
|
pub unban_instant: Option<Instant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enumeration of address types.
|
|
||||||
///
|
|
||||||
/// Used [`ConnectionInfo::address_type`].
|
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum AddressType {
|
|
||||||
#[default]
|
|
||||||
Invalid,
|
|
||||||
Ipv4,
|
|
||||||
Ipv6,
|
|
||||||
I2p,
|
|
||||||
Tor,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressType {
|
|
||||||
/// Convert [`Self`] to a [`u8`].
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use cuprate_p2p_core::AddressType as A;
|
|
||||||
///
|
|
||||||
/// assert_eq!(A::Invalid.to_u8(), 0);
|
|
||||||
/// assert_eq!(A::Ipv4.to_u8(), 1);
|
|
||||||
/// assert_eq!(A::Ipv6.to_u8(), 2);
|
|
||||||
/// assert_eq!(A::I2p.to_u8(), 3);
|
|
||||||
/// assert_eq!(A::Tor.to_u8(), 4);
|
|
||||||
/// ```
|
|
||||||
pub const fn to_u8(self) -> u8 {
|
|
||||||
self as u8
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert a [`u8`] to a [`Self`].
|
|
||||||
///
|
|
||||||
/// # Errors
|
|
||||||
/// This returns [`None`] if `u > 4`.
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use cuprate_p2p_core::AddressType as A;
|
|
||||||
///
|
|
||||||
/// assert_eq!(A::from_u8(0), Some(A::Invalid));
|
|
||||||
/// assert_eq!(A::from_u8(1), Some(A::Ipv4));
|
|
||||||
/// assert_eq!(A::from_u8(2), Some(A::Ipv6));
|
|
||||||
/// assert_eq!(A::from_u8(3), Some(A::I2p));
|
|
||||||
/// assert_eq!(A::from_u8(4), Some(A::Tor));
|
|
||||||
/// assert_eq!(A::from_u8(5), None);
|
|
||||||
/// ```
|
|
||||||
pub const fn from_u8(u: u8) -> Option<Self> {
|
|
||||||
Some(match u {
|
|
||||||
0 => Self::Invalid,
|
|
||||||
1 => Self::Ipv4,
|
|
||||||
2 => Self::Ipv6,
|
|
||||||
3 => Self::I2p,
|
|
||||||
4 => Self::Tor,
|
|
||||||
_ => return None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: reduce fields and map to RPC type.
|
// TODO: reduce fields and map to RPC type.
|
||||||
//
|
//
|
||||||
/// Data within [`crate::services::AddressBookResponse::ConnectionInfo`].
|
/// Data within [`crate::services::AddressBookResponse::ConnectionInfo`].
|
||||||
pub struct ConnectionInfo<A: NetZoneAddress> {
|
pub struct ConnectionInfo<A: NetZoneAddress> {
|
||||||
pub address: A,
|
pub address: A,
|
||||||
pub address_type: AddressType,
|
pub address_type: u8,
|
||||||
pub avg_download: u64,
|
pub avg_download: u64,
|
||||||
pub avg_upload: u64,
|
pub avg_upload: u64,
|
||||||
pub connection_id: u64, // TODO: boost::uuids::uuid
|
pub connection_id: String,
|
||||||
pub current_download: u64,
|
pub current_download: u64,
|
||||||
pub current_upload: u64,
|
pub current_upload: u64,
|
||||||
pub height: u64,
|
pub height: u64,
|
||||||
|
@ -101,14 +42,14 @@ pub struct ConnectionInfo<A: NetZoneAddress> {
|
||||||
pub local_ip: bool,
|
pub local_ip: bool,
|
||||||
pub peer_id: String,
|
pub peer_id: String,
|
||||||
pub port: String,
|
pub port: String,
|
||||||
pub pruning_seed: PruningSeed,
|
pub pruning_seed: u32,
|
||||||
pub recv_count: u64,
|
pub recv_count: u64,
|
||||||
pub recv_idle_time: u64,
|
pub recv_idle_time: u64,
|
||||||
pub rpc_credits_per_hash: u32,
|
pub rpc_credits_per_hash: u32,
|
||||||
pub rpc_port: u16,
|
pub rpc_port: u16,
|
||||||
pub send_count: u64,
|
pub send_count: u64,
|
||||||
pub send_idle_time: u64,
|
pub send_idle_time: u64,
|
||||||
pub state: String, // TODO: what type is this?
|
pub state: String,
|
||||||
pub support_flags: u32,
|
pub support_flags: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +57,11 @@ pub struct ConnectionInfo<A: NetZoneAddress> {
|
||||||
///
|
///
|
||||||
/// Data within [`crate::services::AddressBookResponse::Spans`].
|
/// Data within [`crate::services::AddressBookResponse::Spans`].
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Span<A: NetZoneAddress> {
|
pub struct Span {
|
||||||
pub connection_id: u64, // TODO: boost::uuids::uuid
|
pub connection_id: String,
|
||||||
pub nblocks: u64,
|
pub nblocks: u64,
|
||||||
pub rate: u32,
|
pub rate: u32,
|
||||||
pub remote_address: A,
|
pub remote_address: String,
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
pub speed: u32,
|
pub speed: u32,
|
||||||
pub start_block_height: u64,
|
pub start_block_height: u64,
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
//! Types of network addresses; used in P2P.
|
|
||||||
|
|
||||||
use cuprate_epee_encoding::Marker;
|
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
use cuprate_epee_encoding::{
|
|
||||||
error,
|
|
||||||
macros::bytes::{Buf, BufMut},
|
|
||||||
EpeeValue,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Used in [`crate::misc::ConnectionInfo::address_type`].
|
|
||||||
#[doc = crate::macros::monero_definition_link!(
|
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
|
||||||
"epee/include/net/enums.h",
|
|
||||||
39..=47
|
|
||||||
)]
|
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[cfg_attr(feature = "serde", serde(untagged))]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum AddressType {
|
|
||||||
#[default]
|
|
||||||
Invalid,
|
|
||||||
Ipv4,
|
|
||||||
Ipv6,
|
|
||||||
I2p,
|
|
||||||
Tor,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressType {
|
|
||||||
/// Convert [`Self`] to a [`u8`].
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use cuprate_rpc_types::misc::AddressType as A;
|
|
||||||
///
|
|
||||||
/// assert_eq!(A::Invalid.to_u8(), 0);
|
|
||||||
/// assert_eq!(A::Ipv4.to_u8(), 1);
|
|
||||||
/// assert_eq!(A::Ipv6.to_u8(), 2);
|
|
||||||
/// assert_eq!(A::I2p.to_u8(), 3);
|
|
||||||
/// assert_eq!(A::Tor.to_u8(), 4);
|
|
||||||
/// ```
|
|
||||||
pub const fn to_u8(self) -> u8 {
|
|
||||||
self as u8
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert a [`u8`] to a [`Self`].
|
|
||||||
///
|
|
||||||
/// # Errors
|
|
||||||
/// This returns [`None`] if `u > 4`.
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use cuprate_rpc_types::misc::AddressType as A;
|
|
||||||
///
|
|
||||||
/// assert_eq!(A::from_u8(0), Some(A::Invalid));
|
|
||||||
/// assert_eq!(A::from_u8(1), Some(A::Ipv4));
|
|
||||||
/// assert_eq!(A::from_u8(2), Some(A::Ipv6));
|
|
||||||
/// assert_eq!(A::from_u8(3), Some(A::I2p));
|
|
||||||
/// assert_eq!(A::from_u8(4), Some(A::Tor));
|
|
||||||
/// assert_eq!(A::from_u8(5), None);
|
|
||||||
/// ```
|
|
||||||
pub const fn from_u8(u: u8) -> Option<Self> {
|
|
||||||
Some(match u {
|
|
||||||
0 => Self::Invalid,
|
|
||||||
1 => Self::Ipv4,
|
|
||||||
2 => Self::Ipv6,
|
|
||||||
3 => Self::I2p,
|
|
||||||
4 => Self::Tor,
|
|
||||||
_ => return None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<AddressType> for u8 {
|
|
||||||
fn from(value: AddressType) -> Self {
|
|
||||||
value.to_u8()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "epee")]
|
|
||||||
impl EpeeValue for AddressType {
|
|
||||||
const MARKER: Marker = u8::MARKER;
|
|
||||||
|
|
||||||
fn read<B: Buf>(r: &mut B, marker: &Marker) -> error::Result<Self> {
|
|
||||||
let u = u8::read(r, marker)?;
|
|
||||||
Self::from_u8(u).ok_or(error::Error::Format("u8 was greater than 4"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write<B: BufMut>(self, w: &mut B) -> error::Result<()> {
|
|
||||||
let u = self.to_u8();
|
|
||||||
u8::write(u, w)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -110,7 +110,7 @@ define_struct_and_impl_epee! {
|
||||||
/// Used in [`crate::json::GetConnectionsResponse`].
|
/// Used in [`crate::json::GetConnectionsResponse`].
|
||||||
ConnectionInfo {
|
ConnectionInfo {
|
||||||
address: String,
|
address: String,
|
||||||
address_type: crate::misc::AddressType,
|
address_type: u8,
|
||||||
avg_download: u64,
|
avg_download: u64,
|
||||||
avg_upload: u64,
|
avg_upload: u64,
|
||||||
connection_id: String,
|
connection_id: String,
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
)]
|
)]
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Mod
|
//---------------------------------------------------------------------------------------------------- Mod
|
||||||
mod address_type;
|
|
||||||
mod binary_string;
|
mod binary_string;
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod key_image_spent_status;
|
mod key_image_spent_status;
|
||||||
|
@ -22,7 +21,6 @@ mod pool_info_extent;
|
||||||
mod status;
|
mod status;
|
||||||
mod tx_entry;
|
mod tx_entry;
|
||||||
|
|
||||||
pub use address_type::AddressType;
|
|
||||||
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;
|
||||||
|
|
|
@ -121,6 +121,7 @@ fn map_request(
|
||||||
R::DatabaseSize => database_size(env),
|
R::DatabaseSize => database_size(env),
|
||||||
R::OutputHistogram(input) => output_histogram(env, input),
|
R::OutputHistogram(input) => output_histogram(env, input),
|
||||||
R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count),
|
R::CoinbaseTxSum { height, count } => coinbase_tx_sum(env, height, count),
|
||||||
|
R::HardForks => hard_forks(env),
|
||||||
R::AltChains => alt_chains(env),
|
R::AltChains => alt_chains(env),
|
||||||
R::AltChainCount => alt_chain_count(env),
|
R::AltChainCount => alt_chain_count(env),
|
||||||
}
|
}
|
||||||
|
@ -651,6 +652,11 @@ fn coinbase_tx_sum(env: &ConcreteEnv, height: usize, count: u64) -> ResponseResu
|
||||||
Ok(BlockchainResponse::CoinbaseTxSum(todo!()))
|
Ok(BlockchainResponse::CoinbaseTxSum(todo!()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`BlockchainReadRequest::HardForks`]
|
||||||
|
fn hard_forks(env: &ConcreteEnv) -> ResponseResult {
|
||||||
|
Ok(BlockchainResponse::HardForks(todo!()))
|
||||||
|
}
|
||||||
|
|
||||||
/// [`BlockchainReadRequest::AltChains`]
|
/// [`BlockchainReadRequest::AltChains`]
|
||||||
fn alt_chains(env: &ConcreteEnv) -> ResponseResult {
|
fn alt_chains(env: &ConcreteEnv) -> ResponseResult {
|
||||||
Ok(BlockchainResponse::AltChains(todo!()))
|
Ok(BlockchainResponse::AltChains(todo!()))
|
||||||
|
|
|
@ -22,16 +22,12 @@ pub enum TxpoolReadRequest {
|
||||||
/// Get information on all transactions in the pool.
|
/// Get information on all transactions in the pool.
|
||||||
Backlog,
|
Backlog,
|
||||||
|
|
||||||
/// Get information on all transactions in
|
/// TODO
|
||||||
/// the pool for block template purposes.
|
|
||||||
///
|
|
||||||
/// This is only slightly different to [`TxpoolReadRequest::Backlog`].
|
|
||||||
BlockTemplateBacklog,
|
BlockTemplateBacklog,
|
||||||
|
|
||||||
/// Get the number of transactions in the pool.
|
/// Get the number of transactions in the pool.
|
||||||
Size {
|
Size {
|
||||||
/// If this is [`true`], the size returned will
|
/// TODO
|
||||||
/// include private transactions in the pool.
|
|
||||||
include_sensitive_txs: bool,
|
include_sensitive_txs: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -51,13 +47,13 @@ pub enum TxpoolReadResponse {
|
||||||
|
|
||||||
/// Response to [`TxpoolReadRequest::Backlog`].
|
/// Response to [`TxpoolReadRequest::Backlog`].
|
||||||
///
|
///
|
||||||
/// The inner [`Vec`] contains information on all
|
/// The inner `Vec` contains information on all
|
||||||
/// the transactions currently in the pool.
|
/// the transactions currently in the pool.
|
||||||
Backlog(Vec<TxEntry>),
|
Backlog(Vec<TxEntry>),
|
||||||
|
|
||||||
/// Response to [`TxpoolReadRequest::BlockTemplateBacklog`].
|
/// Response to [`TxpoolReadRequest::BlockTemplateBacklog`].
|
||||||
///
|
///
|
||||||
/// The inner [`Vec`] contains information on transactions
|
/// TODO
|
||||||
BlockTemplateBacklog(Vec<BlockTemplateTxEntry>),
|
BlockTemplateBacklog(Vec<BlockTemplateTxEntry>),
|
||||||
|
|
||||||
/// Response to [`TxpoolReadRequest::Size`].
|
/// Response to [`TxpoolReadRequest::Size`].
|
||||||
|
|
|
@ -13,16 +13,15 @@ pub struct TxEntry {
|
||||||
pub time_in_pool: std::time::Duration,
|
pub time_in_pool: std::time::Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data about a transaction in the pool
|
/// TODO
|
||||||
/// for use in a block template.
|
|
||||||
///
|
///
|
||||||
/// Used in [`TxpoolReadResponse::BlockTemplateBacklog`](crate::service::interface::TxpoolReadResponse::BlockTemplateBacklog).
|
/// Used in [`TxpoolReadResponse::BlockTemplateBacklog`](crate::service::interface::TxpoolReadResponse::BlockTemplateBacklog).
|
||||||
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
||||||
pub struct BlockTemplateTxEntry {
|
pub struct BlockTemplateTxEntry {
|
||||||
/// The transaction's ID (hash).
|
/// TODO
|
||||||
pub id: [u8; 32],
|
pub id: [u8; 32],
|
||||||
/// The transaction's weight.
|
/// TODO
|
||||||
pub weight: u64,
|
pub weight: u64,
|
||||||
/// The transaction's fee.
|
/// TODO
|
||||||
pub fee: u64,
|
pub fee: u64,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
//! responses are also tested in Cuprate's blockchain database crate.
|
//! responses are also tested in Cuprate's blockchain database crate.
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{BTreeMap, HashMap, HashSet},
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use monero_serai::block::Block;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation},
|
types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation},
|
||||||
AltBlockInformation, ChainId, ChainInfo, CoinbaseTxSum, OutputHistogramEntry,
|
AltBlockInformation, ChainId, ChainInfo, CoinbaseTxSum, HardFork, OutputHistogramEntry,
|
||||||
OutputHistogramInput,
|
OutputHistogramInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,10 +130,13 @@ pub enum BlockchainReadRequest {
|
||||||
/// TODO: document fields after impl.
|
/// TODO: document fields after impl.
|
||||||
CoinbaseTxSum { height: usize, count: u64 },
|
CoinbaseTxSum { height: usize, count: u64 },
|
||||||
|
|
||||||
/// Get information on all alternative chains.
|
/// TODO
|
||||||
|
HardForks,
|
||||||
|
|
||||||
|
/// TODO
|
||||||
AltChains,
|
AltChains,
|
||||||
|
|
||||||
/// Get the amount of alternative chains that exist.
|
/// TODO
|
||||||
AltChainCount,
|
AltChainCount,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +286,13 @@ pub enum BlockchainResponse {
|
||||||
/// Response to [`BlockchainReadRequest::CoinbaseTxSum`].
|
/// Response to [`BlockchainReadRequest::CoinbaseTxSum`].
|
||||||
CoinbaseTxSum(CoinbaseTxSum),
|
CoinbaseTxSum(CoinbaseTxSum),
|
||||||
|
|
||||||
/// Response to [`BlockchainReadRequest::AltChains`].
|
/// Response to [`BlockchainReadRequest::HardForks`].
|
||||||
|
///
|
||||||
|
/// - Key = height at which the hardfork activated
|
||||||
|
/// - Value = hardfork version
|
||||||
|
HardForks(BTreeMap<usize, HardFork>),
|
||||||
|
|
||||||
|
/// TODO
|
||||||
AltChains(Vec<ChainInfo>),
|
AltChains(Vec<ChainInfo>),
|
||||||
|
|
||||||
/// Response to [`BlockchainReadRequest::AltChainCount`].
|
/// Response to [`BlockchainReadRequest::AltChainCount`].
|
||||||
|
|
Loading…
Reference in a new issue