|
3 | 3 | use serde::{Deserialize, Serialize}; |
4 | 4 |
|
5 | 5 | use { |
6 | | - crate::{ |
7 | | - certificate::{Certificate, CertificateType}, |
8 | | - vote::Vote, |
9 | | - }, |
| 6 | + crate::{certificate::Certificate, vote::Vote}, |
10 | 7 | bitvec::prelude::*, |
11 | 8 | solana_bls::Signature as BLSSignature, |
12 | | - solana_hash::Hash, |
13 | | - solana_program::clock::Slot, |
14 | 9 | }; |
15 | 10 |
|
16 | 11 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
17 | 12 | #[derive(Clone, Copy, Debug, PartialEq)] |
18 | | -/// BLS message vote data, we need rank to look up pubkey |
19 | | -pub struct BLSMessageVoteData { |
| 13 | +/// BLS vote message, we need rank to look up pubkey |
| 14 | +pub struct VoteMessage { |
20 | 15 | /// The vote |
21 | 16 | pub vote: Vote, |
| 17 | + /// The signature |
| 18 | + pub signature: BLSSignature, |
22 | 19 | /// The rank of the validator |
23 | 20 | pub rank: u16, |
24 | 21 | } |
25 | 22 |
|
26 | 23 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
27 | 24 | #[derive(Clone, Debug, PartialEq)] |
28 | | -#[allow(clippy::large_enum_variant)] |
29 | | -/// BLS message data in Alpenglow |
30 | | -pub enum BLSMessageData { |
31 | | - /// Vote message, with the vote and the rank of the validator. |
32 | | - Vote(BLSMessageVoteData), |
33 | | - /// Certificate message |
34 | | - Certificate(Certificate), |
| 25 | +/// BLS vote message, we need rank to look up pubkey |
| 26 | +pub struct CertificateMessage { |
| 27 | + /// The certificate |
| 28 | + pub certificate: Certificate, |
| 29 | + /// The signature |
| 30 | + pub signature: BLSSignature, |
| 31 | + /// The bitmap for validators, little endian byte order |
| 32 | + pub bitmap: BitVec<u8, Lsb0>, |
35 | 33 | } |
36 | 34 |
|
37 | 35 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
38 | 36 | #[derive(Clone, Debug, PartialEq)] |
39 | | -/// BLS message to be sent all to all in Alpenglow |
40 | | -pub struct BLSMessage { |
41 | | - /// The message data |
42 | | - pub message_data: BLSMessageData, |
43 | | - /// The signature of the message |
44 | | - pub signature: BLSSignature, |
| 37 | +#[allow(clippy::large_enum_variant)] |
| 38 | +/// BLS message data in Alpenglow |
| 39 | +pub enum BLSMessage { |
| 40 | + /// Vote message, with the vote and the rank of the validator. |
| 41 | + Vote(VoteMessage), |
| 42 | + /// Certificate message |
| 43 | + Certificate(CertificateMessage), |
45 | 44 | } |
46 | 45 |
|
47 | 46 | impl BLSMessage { |
48 | 47 | /// Create a new vote message |
49 | | - pub fn new_vote(vote: Vote, my_rank: u16, signature: BLSSignature) -> Self { |
50 | | - Self { |
51 | | - message_data: BLSMessageData::Vote(BLSMessageVoteData { |
52 | | - vote, |
53 | | - rank: my_rank, |
54 | | - }), |
| 48 | + pub fn new_vote(vote: Vote, signature: BLSSignature, rank: u16) -> Self { |
| 49 | + Self::Vote(VoteMessage { |
| 50 | + vote, |
55 | 51 | signature, |
56 | | - } |
| 52 | + rank, |
| 53 | + }) |
57 | 54 | } |
58 | 55 |
|
59 | 56 | /// Create a new certificate message |
60 | 57 | pub fn new_certificate( |
61 | | - certificate_type: CertificateType, |
62 | | - slot: Slot, |
63 | | - block_id: Option<Hash>, |
64 | | - replayed_bank_hash: Option<Hash>, |
| 58 | + certificate: Certificate, |
65 | 59 | bitmap: BitVec<u8, Lsb0>, |
66 | 60 | signature: BLSSignature, |
67 | 61 | ) -> Self { |
68 | | - Self { |
69 | | - message_data: BLSMessageData::Certificate(Certificate { |
70 | | - certificate_type, |
71 | | - slot, |
72 | | - block_id, |
73 | | - replayed_bank_hash, |
74 | | - bitmap, |
75 | | - }), |
| 62 | + Self::Certificate(CertificateMessage { |
| 63 | + certificate, |
76 | 64 | signature, |
77 | | - } |
| 65 | + bitmap, |
| 66 | + }) |
78 | 67 | } |
79 | 68 |
|
80 | 69 | #[cfg(feature = "serde")] |
|
0 commit comments