solana_core/
admin_rpc_post_init.rs1use {
2 crate::{
3 cluster_slots_service::cluster_slots::ClusterSlots,
4 repair::{outstanding_requests::OutstandingRequests, serve_repair::ShredRepairType},
5 },
6 solana_gossip::cluster_info::ClusterInfo,
7 solana_pubkey::Pubkey,
8 solana_quic_definitions::NotifyKeyUpdate,
9 solana_runtime::bank_forks::BankForks,
10 std::{
11 collections::{HashMap, HashSet},
12 net::UdpSocket,
13 sync::{Arc, RwLock},
14 },
15};
16
17#[derive(PartialEq, Eq, Hash, Clone, Debug)]
19pub enum KeyUpdaterType {
20 Tpu,
22 TpuForwards,
24 TpuVote,
26 Forward,
28 RpcService,
30}
31
32#[derive(Default)]
34pub struct KeyUpdaters {
35 updaters: HashMap<KeyUpdaterType, Arc<dyn NotifyKeyUpdate + Sync + Send>>,
36}
37
38impl KeyUpdaters {
39 pub fn add(
41 &mut self,
42 updater_type: KeyUpdaterType,
43 updater: Arc<dyn NotifyKeyUpdate + Sync + Send>,
44 ) {
45 self.updaters.insert(updater_type, updater);
46 }
47
48 pub fn remove(&mut self, updater_type: &KeyUpdaterType) {
50 self.updaters.remove(updater_type);
51 }
52}
53
54impl<'a> IntoIterator for &'a KeyUpdaters {
56 type Item = (
57 &'a KeyUpdaterType,
58 &'a Arc<dyn NotifyKeyUpdate + Sync + Send>,
59 );
60 type IntoIter = std::collections::hash_map::Iter<
61 'a,
62 KeyUpdaterType,
63 Arc<dyn NotifyKeyUpdate + Sync + Send>,
64 >;
65
66 fn into_iter(self) -> Self::IntoIter {
67 self.updaters.iter()
68 }
69}
70
71#[derive(Clone)]
72pub struct AdminRpcRequestMetadataPostInit {
73 pub cluster_info: Arc<ClusterInfo>,
74 pub bank_forks: Arc<RwLock<BankForks>>,
75 pub vote_account: Pubkey,
76 pub repair_whitelist: Arc<RwLock<HashSet<Pubkey>>>,
77 pub notifies: Arc<RwLock<KeyUpdaters>>,
78 pub repair_socket: Arc<UdpSocket>,
79 pub outstanding_repair_requests: Arc<RwLock<OutstandingRequests<ShredRepairType>>>,
80 pub cluster_slots: Arc<ClusterSlots>,
81}