mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-23 12:09:57 +00:00
add GetHeight
This commit is contained in:
parent
af70416736
commit
a4ad660daa
4 changed files with 23 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
||||||
//! Misc data structures within other types.
|
//! Data structures that appear in other types.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
//! <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/daemon_messages.h>.
|
//! <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/daemon_messages.h>.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use crate::{macros::define_monero_rpc_type_struct, misc::Status};
|
use crate::{macros::define_monero_rpc_struct, misc::Status};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Struct definitions
|
//---------------------------------------------------------------------------------------------------- Struct definitions
|
||||||
define_monero_rpc_type_struct! {
|
define_monero_rpc_struct! {
|
||||||
// The markdown tag for Monero RPC documentation. Not necessarily the endpoint.
|
// The markdown tag for Monero RPC documentation. Not necessarily the endpoint.
|
||||||
get_block_count,
|
get_block_count,
|
||||||
// The `$file.$extension` in which this type is defined in the Monero
|
// The `$file.$extension` in which this type is defined in the Monero
|
||||||
|
@ -36,6 +36,19 @@ define_monero_rpc_type_struct! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define_monero_rpc_struct! {
|
||||||
|
on_get_block_hash,
|
||||||
|
core_rpc_server_commands_defs.h => 919..=933,
|
||||||
|
OnGetBlockHash { height: [123] } =>
|
||||||
|
r#"[123]"#,
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
|
OnGetBlockHash {
|
||||||
|
/// A block's height.
|
||||||
|
height: [u64; 1],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/// generate which docs.
|
/// generate which docs.
|
||||||
///
|
///
|
||||||
/// See [`crate::json::GetHeight`] for example usage.
|
/// See [`crate::json::GetHeight`] for example usage.
|
||||||
macro_rules! define_monero_rpc_type_struct {
|
macro_rules! define_monero_rpc_struct {
|
||||||
(
|
(
|
||||||
// The markdown tag for Monero RPC documentation. Not necessarily the endpoint.
|
// The markdown tag for Monero RPC documentation. Not necessarily the endpoint.
|
||||||
$monero_daemon_rpc_doc_link:ident,
|
$monero_daemon_rpc_doc_link:ident,
|
||||||
|
@ -34,10 +34,9 @@ macro_rules! define_monero_rpc_type_struct {
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
$( #[$type_attr:meta] )*
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
///
|
$( #[$type_attr] )*
|
||||||
#[doc = concat!(
|
#[doc = concat!(
|
||||||
"",
|
"",
|
||||||
"Definition: [`",
|
"Definition: [`",
|
||||||
|
@ -83,6 +82,6 @@ macro_rules! define_monero_rpc_type_struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
pub(crate) use define_monero_rpc_type_struct;
|
pub(crate) use define_monero_rpc_struct;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Documentation macros
|
//---------------------------------------------------------------------------------------------------- Documentation macros
|
||||||
|
|
|
@ -3,30 +3,15 @@
|
||||||
//! <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/daemon_messages.h>.
|
//! <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/daemon_messages.h>.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use crate::macros::define_monero_rpc_type_struct;
|
use crate::macros::define_monero_rpc_struct;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TODO
|
//---------------------------------------------------------------------------------------------------- TODO
|
||||||
define_monero_rpc_type_struct! {
|
define_monero_rpc_struct! {
|
||||||
// The markdown tag for Monero RPC documentation. Not necessarily the endpoint.
|
|
||||||
get_height,
|
get_height,
|
||||||
// The `$file.$extension` in which this type is defined in the Monero
|
|
||||||
// codebase in the `rpc/` directory, followed by the specific lines.
|
|
||||||
daemon_messages.h => 81..=87,
|
daemon_messages.h => 81..=87,
|
||||||
// The type and its compacted JSON string form, used in example doc-test.
|
|
||||||
GetHeight { height: 123 } => r#"{"height":123}"#,
|
GetHeight { height: 123 } => r#"{"height":123}"#,
|
||||||
// The actual type definitions.
|
GetHeight {
|
||||||
// If there are any additional attributes (`/// docs` or `#[derive]`s)
|
/// A block's height.
|
||||||
// for the struct, they go here, e.g.:
|
|
||||||
// #[derive(MyCustomDerive)]
|
|
||||||
GetHeight /* <- The type name */ {
|
|
||||||
// Within the `{}` is an infinite matching pattern of:
|
|
||||||
// ```
|
|
||||||
// $ATTRIBUTES
|
|
||||||
// $FIELD_NAME: $FIELD_TYPE,
|
|
||||||
// ```
|
|
||||||
// The struct generated and all fields are `pub`.
|
|
||||||
|
|
||||||
/// A block height.
|
|
||||||
height: u64,
|
height: u64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue