iuna

iuna - experimental devnet protocol
git clone https://iuna.jhx.app/git/iuna.git
Log | Files | Refs | README | LICENSE

peer_status.rs (1423B)


      1 use crate::app::now_ms;
      2 
      3 #[derive(Clone, Debug, Eq, PartialEq)]
      4 pub(super) struct PeerStatus {
      5     pub(super) height: u64,
      6     pub(super) tip_hash: String,
      7     pub(super) time_ms: u64,
      8     pub(super) request_snapshot: bool,
      9     pub(super) push_snapshot: bool,
     10 }
     11 
     12 impl PeerStatus {
     13     pub(super) fn new(height: u64, tip_hash: String) -> Self {
     14         Self::with_time(height, tip_hash, now_ms())
     15     }
     16 
     17     pub(super) fn with_time(height: u64, tip_hash: String, time_ms: u64) -> Self {
     18         Self {
     19             height,
     20             tip_hash,
     21             time_ms,
     22             request_snapshot: false,
     23             push_snapshot: false,
     24         }
     25     }
     26 
     27     pub(super) fn from_envelope(height: u64, tip_hash: String, time_ms: u64) -> Self {
     28         Self {
     29             height,
     30             tip_hash,
     31             time_ms,
     32             request_snapshot: false,
     33             push_snapshot: false,
     34         }
     35     }
     36 
     37     pub(super) fn with_snapshot_request(height: u64, tip_hash: String, time_ms: u64) -> Self {
     38         Self {
     39             height,
     40             tip_hash,
     41             time_ms,
     42             request_snapshot: true,
     43             push_snapshot: false,
     44         }
     45     }
     46 
     47     pub(super) fn with_snapshot_push(height: u64, tip_hash: String, time_ms: u64) -> Self {
     48         Self {
     49             height,
     50             tip_hash,
     51             time_ms,
     52             request_snapshot: false,
     53             push_snapshot: true,
     54         }
     55     }
     56 }