ConnectionId

This commit is contained in:
hinto.janai 2024-10-30 20:07:11 -04:00
parent b30b41a4d8
commit ad30b539d1
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
2 changed files with 24 additions and 4 deletions

View file

@ -65,7 +65,7 @@ pub(crate) async fn connection_info<Z: NetworkZone>(
address_type: info.address_type,
avg_download: info.avg_download,
avg_upload: info.avg_upload,
connection_id: String::from(FIELD_NOT_SUPPORTED),
connection_id: String::from(ConnectionId::DEFAULT_STR),
current_download: info.current_download,
current_upload: info.current_upload,
height: info.height,

View file

@ -53,12 +53,32 @@ pub struct ConnectionInfo<A: NetZoneAddress> {
pub support_flags: u32,
// The following fields are slightly different than `monerod`.
//
/// [`None`] if Tor/i2p or unknown.
pub socket_addr: Option<std::net::SocketAddr>,
// This field does not exist for Cuprate:
// <https://github.com/Cuprate/cuprate/pull/320#discussion_r1811335020>
// pub connection_id: u128,
/// This field does not exist for `cuprated`'s RPC, this is just a marker type:
/// - <https://github.com/Cuprate/cuprate/pull/320#discussion_r1811335020>
/// - <https://github.com/Cuprate/cuprate/pull/320#discussion_r1819826080>
///
/// [`ConnectionId::DEFAULT_STR`] is used when mapping to the RPC type.
pub connection_id: ConnectionId,
}
/// Marker type for `monerod`'s connection ID.
///
/// `connection_id` is a 128-bit `uuid` in `monerod`.
/// `cuprated` does not support this field so it returns
/// the default value in the RPC interface, an all 0-bit UUID.
///
/// This default value in string form is [`ConnectionId::DEFAULT_STR`].
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ConnectionId;
impl ConnectionId {
/// [`str`] representation of a default connection ID.
pub const DEFAULT_STR: &str = "00000000000000000000000000000000";
}
/// Used in RPC's `sync_info`.