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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::{ConsensusState, Error};
use consensus_types::{
block_data::BlockData,
timeout::Timeout,
timeout_2chain::{TwoChainTimeout, TwoChainTimeoutCertificate},
vote::Vote,
vote_proposal::MaybeSignedVoteProposal,
};
use diem_crypto::ed25519::Ed25519Signature;
use diem_types::{
epoch_change::EpochChangeProof,
ledger_info::{LedgerInfo, LedgerInfoWithSignatures},
};
pub trait TSafetyRules {
fn consensus_state(&mut self) -> Result<ConsensusState, Error>;
fn initialize(&mut self, proof: &EpochChangeProof) -> Result<(), Error>;
fn construct_and_sign_vote(
&mut self,
vote_proposal: &MaybeSignedVoteProposal,
) -> Result<Vote, Error>;
fn sign_proposal(&mut self, block_data: &BlockData) -> Result<Ed25519Signature, Error>;
fn sign_timeout(&mut self, timeout: &Timeout) -> Result<Ed25519Signature, Error>;
fn sign_timeout_with_qc(
&mut self,
timeout: &TwoChainTimeout,
timeout_cert: Option<&TwoChainTimeoutCertificate>,
) -> Result<Ed25519Signature, Error>;
fn construct_and_sign_vote_two_chain(
&mut self,
vote_proposal: &MaybeSignedVoteProposal,
timeout_cert: Option<&TwoChainTimeoutCertificate>,
) -> Result<Vote, Error>;
fn sign_commit_vote(
&mut self,
ledger_info: LedgerInfoWithSignatures,
new_ledger_info: LedgerInfo,
) -> Result<Ed25519Signature, Error>;
}