Plumb BankForks into GossipService
This commit is contained in:
		| @@ -12,6 +12,7 @@ | ||||
| //! * layer 2 - Everyone else, if layer 1 is `2^10`, layer 2 should be able to fit `2^20` number of nodes. | ||||
| //! | ||||
| //! Bank needs to provide an interface for us to query the stake weight | ||||
| use crate::bank_forks::BankForks; | ||||
| use crate::blocktree::Blocktree; | ||||
| use crate::contact_info::ContactInfo; | ||||
| use crate::crds_gossip::CrdsGossip; | ||||
| @@ -31,7 +32,6 @@ use rayon::prelude::*; | ||||
| use solana_metrics::counter::Counter; | ||||
| use solana_metrics::{influxdb, submit}; | ||||
| use solana_netutil::{bind_in_range, bind_to, find_available_port_in_range, multi_bind_in_range}; | ||||
| use solana_runtime::bank::Bank; | ||||
| use solana_runtime::bloom::Bloom; | ||||
| use solana_sdk::hash::Hash; | ||||
| use solana_sdk::pubkey::Pubkey; | ||||
| @@ -860,7 +860,7 @@ impl ClusterInfo { | ||||
|     /// randomly pick a node and ask them for updates asynchronously | ||||
|     pub fn gossip( | ||||
|         obj: Arc<RwLock<Self>>, | ||||
|         bank: Option<Arc<Bank>>, | ||||
|         bank_forks: Option<Arc<RwLock<BankForks>>>, | ||||
|         blob_sender: BlobSender, | ||||
|         exit: Arc<AtomicBool>, | ||||
|     ) -> JoinHandle<()> { | ||||
| @@ -870,8 +870,10 @@ impl ClusterInfo { | ||||
|                 let mut last_push = timestamp(); | ||||
|                 loop { | ||||
|                     let start = timestamp(); | ||||
|                     let stakes: HashMap<_, _> = match bank { | ||||
|                         Some(ref bank) => bank.staked_nodes(), | ||||
|                     let stakes: HashMap<_, _> = match bank_forks { | ||||
|                         Some(ref bank_forks) => { | ||||
|                             bank_forks.read().unwrap().working_bank().staked_nodes() | ||||
|                         } | ||||
|                         None => HashMap::new(), | ||||
|                     }; | ||||
|                     let _ = Self::run_gossip(&obj, &stakes, &blob_sender); | ||||
|   | ||||
| @@ -192,7 +192,7 @@ impl Fullnode { | ||||
|         let gossip_service = GossipService::new( | ||||
|             &cluster_info, | ||||
|             Some(blocktree.clone()), | ||||
|             Some(bank.clone()), | ||||
|             Some(bank_forks.clone()), | ||||
|             node.sockets.gossip, | ||||
|             exit.clone(), | ||||
|         ); | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| //! The `gossip_service` module implements the network control plane. | ||||
|  | ||||
| use crate::bank_forks::BankForks; | ||||
| use crate::blocktree::Blocktree; | ||||
| use crate::cluster_info::{ClusterInfo, Node, NodeInfo}; | ||||
| use crate::service::Service; | ||||
| use crate::streamer; | ||||
| use solana_runtime::bank::Bank; | ||||
| use solana_sdk::pubkey::Pubkey; | ||||
| use solana_sdk::signature::{Keypair, KeypairUtil}; | ||||
| use std::net::UdpSocket; | ||||
| @@ -24,7 +24,7 @@ impl GossipService { | ||||
|     pub fn new( | ||||
|         cluster_info: &Arc<RwLock<ClusterInfo>>, | ||||
|         blocktree: Option<Arc<Blocktree>>, | ||||
|         bank: Option<Arc<Bank>>, | ||||
|         bank_forks: Option<Arc<RwLock<BankForks>>>, | ||||
|         gossip_socket: UdpSocket, | ||||
|         exit: Arc<AtomicBool>, | ||||
|     ) -> Self { | ||||
| @@ -46,8 +46,12 @@ impl GossipService { | ||||
|             response_sender.clone(), | ||||
|             exit.clone(), | ||||
|         ); | ||||
|         let t_gossip = | ||||
|             ClusterInfo::gossip(cluster_info.clone(), bank, response_sender, exit.clone()); | ||||
|         let t_gossip = ClusterInfo::gossip( | ||||
|             cluster_info.clone(), | ||||
|             bank_forks, | ||||
|             response_sender, | ||||
|             exit.clone(), | ||||
|         ); | ||||
|         let thread_hdls = vec![t_receiver, t_responder, t_listen, t_gossip]; | ||||
|         Self { exit, thread_hdls } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user