|
1 | | -// src/config/validator.rs |
| 1 | +use std::fmt; |
| 2 | + |
2 | 3 | use serde::{Deserialize, Serialize}; |
3 | 4 | use solana_keypair::Keypair; |
4 | 5 | use solana_pubkey::Pubkey; |
@@ -35,14 +36,47 @@ pub enum ReplicationMode { |
35 | 36 | ReplicaOnly(ReplicationConfig), |
36 | 37 | } |
37 | 38 |
|
38 | | -#[derive(Deserialize, Serialize, Debug, Clone)] |
| 39 | +#[derive(Deserialize, Clone)] |
39 | 40 | #[serde(rename_all = "kebab-case")] |
40 | 41 | pub struct ReplicationConfig { |
41 | 42 | pub url: Url, |
42 | 43 | pub secret: String, |
43 | 44 | pub authority_override: Option<SerdePubkey>, |
44 | 45 | } |
45 | 46 |
|
| 47 | +impl fmt::Debug for ReplicationConfig { |
| 48 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 49 | + f.debug_struct("ReplicationConfig") |
| 50 | + .field("url", &self.url) |
| 51 | + .field("secret", &"<redacted>") |
| 52 | + .field("authority_override", &self.authority_override) |
| 53 | + .finish() |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +impl Serialize for ReplicationConfig { |
| 58 | + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> |
| 59 | + where |
| 60 | + S: serde::Serializer, |
| 61 | + { |
| 62 | + #[derive(Serialize)] |
| 63 | + #[serde(rename_all = "kebab-case")] |
| 64 | + struct Redacted<'a> { |
| 65 | + url: &'a Url, |
| 66 | + secret: &'static str, |
| 67 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 68 | + authority_override: &'a Option<SerdePubkey>, |
| 69 | + } |
| 70 | + |
| 71 | + Redacted { |
| 72 | + url: &self.url, |
| 73 | + secret: "<redacted>", |
| 74 | + authority_override: &self.authority_override, |
| 75 | + } |
| 76 | + .serialize(serializer) |
| 77 | + } |
| 78 | +} |
| 79 | + |
46 | 80 | impl Default for ValidatorConfig { |
47 | 81 | fn default() -> Self { |
48 | 82 | let keypair = |
|
0 commit comments