reth_db_models/
client_version.rs
1use alloc::string::String;
4use serde::{Deserialize, Serialize};
5
6#[derive(Clone, Eq, PartialEq, Debug, Default, Serialize, Deserialize)]
8#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
9#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))]
10pub struct ClientVersion {
11 pub version: String,
13 pub git_sha: String,
15 pub build_timestamp: String,
17}
18
19impl ClientVersion {
20 pub fn is_empty(&self) -> bool {
22 self.version.is_empty() && self.git_sha.is_empty() && self.build_timestamp.is_empty()
23 }
24}
25
26#[cfg(feature = "reth-codec")]
27impl reth_codecs::Compact for ClientVersion {
28 fn to_compact<B>(&self, buf: &mut B) -> usize
29 where
30 B: bytes::BufMut + AsMut<[u8]>,
31 {
32 self.version.to_compact(buf);
33 self.git_sha.to_compact(buf);
34 self.build_timestamp.to_compact(buf)
35 }
36
37 fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
38 let (version, buf) = String::from_compact(buf, len);
39 let (git_sha, buf) = String::from_compact(buf, len);
40 let (build_timestamp, buf) = String::from_compact(buf, len);
41 let client_version = Self { version, git_sha, build_timestamp };
42 (client_version, buf)
43 }
44}