1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::common::Round;
use diem_crypto::ed25519::Ed25519Signature;
use diem_crypto_derive::{BCSCryptoHash, CryptoHasher};
use diem_types::validator_signer::ValidatorSigner;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, CryptoHasher, BCSCryptoHash)]
pub struct Timeout {
epoch: u64,
round: Round,
}
impl Timeout {
pub fn new(epoch: u64, round: Round) -> Self {
Self { epoch, round }
}
pub fn epoch(&self) -> u64 {
self.epoch
}
pub fn round(&self) -> Round {
self.round
}
pub fn sign(&self, signer: &ValidatorSigner) -> Ed25519Signature {
signer.sign(self)
}
}
impl Display for Timeout {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "Timeout: [epoch: {}, round: {}]", self.epoch, self.round,)
}
}