|
1 | 1 | #[cfg(feature = "serde")] |
2 | | -use serde_derive::{Deserialize, Serialize}; |
| 2 | +use { |
| 3 | + serde_derive::{Deserialize, Serialize}, |
| 4 | + serde_with::serde_as, |
| 5 | +}; |
3 | 6 | #[cfg(feature = "frozen-abi")] |
4 | 7 | use solana_frozen_abi_macro::{frozen_abi, AbiExample}; |
5 | 8 | use { |
@@ -203,56 +206,56 @@ pub struct VoteInit { |
203 | 206 | pub commission: u8, |
204 | 207 | } |
205 | 208 |
|
| 209 | +#[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)] |
206 | 210 | #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
207 | 211 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
208 | | -pub struct BLSPubkeyCompressed( |
209 | | - #[cfg_attr(feature = "serde", serde(with = "serde_bytes"))] |
210 | | - [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], |
211 | | -); |
212 | | - |
213 | | -impl Default for BLSPubkeyCompressed { |
214 | | - fn default() -> Self { |
215 | | - Self([0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE]) |
216 | | - } |
217 | | -} |
218 | | - |
219 | | -impl From<BLSPubkeyCompressed> for [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE] { |
220 | | - fn from(wrapper: BLSPubkeyCompressed) -> Self { |
221 | | - wrapper.0 |
222 | | - } |
223 | | -} |
224 | | - |
225 | | -#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
226 | | -#[derive(Debug, PartialEq, Eq, Clone, Copy)] |
227 | | -pub struct BLSSignatureCompressed( |
228 | | - #[cfg_attr(feature = "serde", serde(with = "serde_bytes"))] [u8; BLS_SIGNATURE_COMPRESSED_SIZE], |
229 | | -); |
230 | | - |
231 | | -impl Default for BLSSignatureCompressed { |
232 | | - fn default() -> Self { |
233 | | - Self([0u8; BLS_SIGNATURE_COMPRESSED_SIZE]) |
234 | | - } |
235 | | -} |
236 | | - |
237 | | -#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
238 | | -#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] |
239 | 212 | pub struct VoteInitV2 { |
240 | 213 | pub node_pubkey: Pubkey, |
241 | 214 | pub authorized_voter: Pubkey, |
242 | | - pub authorized_voter_bls_pubkey: BLSPubkeyCompressed, |
243 | | - pub authorized_voter_bls_proof_of_possession: BLSSignatureCompressed, |
| 215 | + #[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_PUBLIC_KEY_COMPRESSED_SIZE]"))] |
| 216 | + pub authorized_voter_bls_pubkey: [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], |
| 217 | + #[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_SIGNATURE_COMPRESSED_SIZE]"))] |
| 218 | + pub authorized_voter_bls_proof_of_possession: [u8; BLS_SIGNATURE_COMPRESSED_SIZE], |
244 | 219 | pub authorized_withdrawer: Pubkey, |
245 | 220 | pub inflation_rewards_commission_bps: u16, |
246 | 221 | pub inflation_rewards_collector: Pubkey, |
247 | 222 | pub block_revenue_commission_bps: u16, |
248 | 223 | pub block_revenue_collector: Pubkey, |
249 | 224 | } |
250 | 225 |
|
| 226 | +impl Default for VoteInitV2 { |
| 227 | + fn default() -> Self { |
| 228 | + Self { |
| 229 | + node_pubkey: Pubkey::default(), |
| 230 | + authorized_voter: Pubkey::default(), |
| 231 | + authorized_voter_bls_pubkey: [0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], |
| 232 | + authorized_voter_bls_proof_of_possession: [0u8; BLS_SIGNATURE_COMPRESSED_SIZE], |
| 233 | + authorized_withdrawer: Pubkey::default(), |
| 234 | + inflation_rewards_commission_bps: 0, |
| 235 | + inflation_rewards_collector: Pubkey::default(), |
| 236 | + block_revenue_commission_bps: 0, |
| 237 | + block_revenue_collector: Pubkey::default(), |
| 238 | + } |
| 239 | + } |
| 240 | +} |
| 241 | + |
| 242 | +#[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)] |
251 | 243 | #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
252 | | -#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] |
| 244 | +#[derive(Debug, PartialEq, Eq, Clone, Copy)] |
253 | 245 | pub struct VoterWithBLSArgs { |
254 | | - bls_pub_key: BLSPubkeyCompressed, |
255 | | - bls_proof_of_possession: BLSSignatureCompressed, |
| 246 | + #[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_PUBLIC_KEY_COMPRESSED_SIZE]"))] |
| 247 | + pub bls_pub_key: [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], |
| 248 | + #[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_SIGNATURE_COMPRESSED_SIZE]"))] |
| 249 | + pub bls_proof_of_possession: [u8; BLS_SIGNATURE_COMPRESSED_SIZE], |
| 250 | +} |
| 251 | + |
| 252 | +impl Default for VoterWithBLSArgs { |
| 253 | + fn default() -> Self { |
| 254 | + Self { |
| 255 | + bls_pub_key: [0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], |
| 256 | + bls_proof_of_possession: [0u8; BLS_SIGNATURE_COMPRESSED_SIZE], |
| 257 | + } |
| 258 | + } |
256 | 259 | } |
257 | 260 |
|
258 | 261 | #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
|
0 commit comments