mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
add more defaults
This commit is contained in:
parent
352ab2015a
commit
4bad15965e
3 changed files with 38 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
//! TODO
|
//! TODO
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TODO
|
//---------------------------------------------------------------------------------------------------- TODO
|
||||||
/// TODO
|
/// TODO
|
||||||
|
@ -9,6 +10,24 @@ pub(crate) const fn default_bool() -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
#[inline]
|
||||||
|
pub(crate) const fn default_cow_str() -> Cow<'static, str> {
|
||||||
|
Cow::Borrowed("")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
#[inline]
|
||||||
|
pub(crate) const fn default_string() -> String {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
#[inline]
|
||||||
|
pub(crate) const fn default_height() -> u64 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use crate::{
|
use crate::{
|
||||||
base::{AccessResponseBase, ResponseBase},
|
base::{AccessResponseBase, ResponseBase},
|
||||||
defaults::default_bool,
|
defaults::{default_bool, default_height, default_string},
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::BlockHeader,
|
misc::{BlockHeader, ConnectionInfo},
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Struct definitions
|
//---------------------------------------------------------------------------------------------------- Struct definitions
|
||||||
|
@ -265,8 +265,10 @@ define_request_and_response! {
|
||||||
// `monerod` has both `hash` and `height` fields.
|
// `monerod` has both `hash` and `height` fields.
|
||||||
// In the RPC handler, if `hash.is_empty()`, it will use it, else, it uses `height`.
|
// In the RPC handler, if `hash.is_empty()`, it will use it, else, it uses `height`.
|
||||||
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2674>
|
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L2674>
|
||||||
hash: String,
|
#[cfg_attr(feature = "serde", serde(default = "default_string"))]
|
||||||
height: u64,
|
hash: String = default_string(),
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_height"))]
|
||||||
|
height: u64 = default_height(),
|
||||||
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
|
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
|
||||||
fill_pow_hash: bool = default_bool(),
|
fill_pow_hash: bool = default_bool(),
|
||||||
},
|
},
|
||||||
|
@ -279,6 +281,18 @@ define_request_and_response! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define_request_and_response! {
|
||||||
|
get_connections,
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
|
core_rpc_server_commands_defs.h => 1734..=1754,
|
||||||
|
GetConnections,
|
||||||
|
Request {},
|
||||||
|
ResponseBase {
|
||||||
|
// TODO: This is a `std::list` in `monerod` because...?
|
||||||
|
connections: Vec<ConnectionInfo>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
|
@ -83,7 +83,7 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- BlockHeader
|
//---------------------------------------------------------------------------------------------------- ConnectionInfo
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
|
Loading…
Reference in a new issue