pub struct NodeStats {
pub peer_id: PeerIdString,
pub status: NodeStatus,
pub total_bandwidth_bytes: Bytes,
pub total_earnings: Points,
pub uptime_seconds: u64,
pub pinned_content_count: u64,
pub pinned_storage_bytes: Bytes,
pub last_seen_at: DateTime<Utc>,
}Expand description
Node statistics.
§Examples
use chie_shared::{NodeStats, NodeStatus};
let stats = NodeStats {
peer_id: "12D3KooWExample".to_string(),
status: NodeStatus::Online,
total_bandwidth_bytes: 1024 * 1024 * 1024 * 50, // 50 GB
total_earnings: 5000,
uptime_seconds: 86400 * 30, // 30 days
pinned_content_count: 100,
pinned_storage_bytes: 1024 * 1024 * 1024 * 10, // 10 GB
last_seen_at: chrono::Utc::now(),
};
// Convert to display-friendly units
assert_eq!(stats.bandwidth_gb() as u64, 50);
assert_eq!(stats.storage_gb() as u64, 10);
assert_eq!(stats.uptime_days() as u64, 30);
// Check node status
assert!(stats.is_online());
assert!(stats.is_recently_active());Fields§
§peer_id: PeerIdString§status: NodeStatus§total_bandwidth_bytes: Bytes§total_earnings: Points§uptime_seconds: u64§pinned_content_count: u64§pinned_storage_bytes: Bytes§last_seen_at: DateTime<Utc>Implementations§
Source§impl NodeStats
impl NodeStats
Sourcepub fn bandwidth_gb(&self) -> f64
pub fn bandwidth_gb(&self) -> f64
Get total bandwidth in gigabytes.
Sourcepub fn bandwidth_tb(&self) -> f64
pub fn bandwidth_tb(&self) -> f64
Get total bandwidth in terabytes.
Sourcepub fn storage_gb(&self) -> f64
pub fn storage_gb(&self) -> f64
Get pinned storage in gigabytes.
Sourcepub fn uptime_days(&self) -> f64
pub fn uptime_days(&self) -> f64
Get uptime in days.
Sourcepub fn is_recently_active(&self) -> bool
pub fn is_recently_active(&self) -> bool
Check if the node has been seen recently (within 5 minutes).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodeStats
impl<'de> Deserialize<'de> for NodeStats
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&NodeStats> for CreateNodeInput
impl From<&NodeStats> for CreateNodeInput
Auto Trait Implementations§
impl Freeze for NodeStats
impl RefUnwindSafe for NodeStats
impl Send for NodeStats
impl Sync for NodeStats
impl Unpin for NodeStats
impl UnwindSafe for NodeStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more