pub fn gossip(
        obj: Arc<RwLock<Self>>,
        bank_forks: Option<Arc<RwLock<BankForks>>>,
        blob_sender: BlobSender,
        exit: &Arc<AtomicBool>,
    ) -> JoinHandle<()> {
        let exit = exit.clone();
        Builder::new()
            .name("morgan-gossip".to_string())
            .spawn(move || {
                let mut last_push = timestamp();
                loop {
                    let start = timestamp();
                    let stakes: HashMap<_, _> = match bank_forks {
                        Some(ref bank_forks) => {
                            stakingUtils::staked_nodes(&bank_forks.read().unwrap().working_bank())
                        }
                        None => HashMap::new(),
                    };
                    let _ = Self::run_gossip(&obj, &stakes, &blob_sender);
                    if exit.load(Ordering::Relaxed) {
                        return;
                    }
                    obj.write().unwrap().purge(timestamp());
                    //TODO: possibly tune this parameter
                    //we saw a deadlock passing an obj.read().unwrap().timeout into sleep
                    if start - last_push > CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS / 2 {
                        obj.write().unwrap().push_self(&stakes);
                        last_push = timestamp();
                    }
                    let elapsed = timestamp() - start;
                    if GOSSIP_SLEEP_MILLIS > elapsed {
                        let time_left = GOSSIP_SLEEP_MILLIS - elapsed;
                        sleep(Duration::from_millis(time_left));
                    }
                }
            })
            .unwrap()
    }
/// randomly pick a node and ask them for updates asynchronously
randomly pick a node and ask them for updates asynchronously
randomly pick a node and ask them for updates asynchronously
pub fn gossip(
        obj: Arc<RwLock<Self>>,
        bank_forks: Option<Arc<RwLock<BankForks>>>,
        blob_sender: BlobSender,
        exit: &Arc<AtomicBool>,
    ) -> JoinHandle<()> {
        let exit = exit.clone();
        Builder::new()
            .name("morgan-gossip".to_string())
            .spawn(move || {
                let mut last_push = timestamp();
                loop {
                    let start = timestamp();
                    let stakes: HashMap<_, _> = match bank_forks {
                        Some(ref bank_forks) => {
                            stakingUtils::staked_nodes(&bank_forks.read().unwrap().working_bank())
                        }
                        None => HashMap::new(),
                    };
                    let _ = Self::run_gossip(&obj, &stakes, &blob_sender);
                    if exit.load(Ordering::Relaxed) {
                        return;
                    }
                    obj.write().unwrap().purge(timestamp());
                    //TODO: possibly tune this parameter
                    //we saw a deadlock passing an obj.read().unwrap().timeout into sleep
                    if start - last_push > CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS / 2 {
                        obj.write().unwrap().push_self(&stakes);
                        last_push = timestamp();
                    }
                    let elapsed = timestamp() - start;
                    if GOSSIP_SLEEP_MILLIS > elapsed {
                        let time_left = GOSSIP_SLEEP_MILLIS - elapsed;
                        sleep(Duration::from_millis(time_left));
                    }
                }
            })
            .unwrap()
    }
pub fn gossip ( obj : Arc < RwLock < Self > > , bank_forks : Option < Arc < RwLock < BankForks > > > , blob_sender : BlobSender , exit : & Arc < AtomicBool > , ) -> JoinHandle < ( ) > { let exit = exit . clone ( ) ; Builder :: new ( ) . name ( " " . to_string ( ) ) . spawn ( move | | { let mut last_push = timestamp ( ) ; loop { let start = timestamp ( ) ; let stakes : HashMap < _ , _ > = match bank_forks { Some ( ref bank_forks ) => { stakingUtils :: staked_nodes ( & bank_forks . read ( ) . unwrap ( ) . working_bank ( ) ) } None => HashMap :: new ( ) , } ; let _ = Self :: run_gossip ( & obj , & stakes , & blob_sender ) ; if exit . load ( Ordering :: Relaxed ) { return ; } obj . write ( ) . unwrap ( ) . purge ( timestamp ( ) ) ; //TODO: possibly tune this parameter //we saw a deadlock passing an obj.read().unwrap().timeout into sleep if start - last_push > CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS / 2 { obj . write ( ) . unwrap ( ) . push_self ( & stakes ) ; last_push = timestamp ( ) ; } let elapsed = timestamp ( ) - start ; if GOSSIP_SLEEP_MILLIS > elapsed { let time_left = GOSSIP_SLEEP_MILLIS - elapsed ; sleep ( Duration :: from_millis ( time_left ) ) ; } } } ) . unwrap ( ) }
randomly pick a node and ask them for updates asynchronously
randomly pick a node and ask them for updates asynchronously
obj
Arc<RwLock<Self>>
bank_forks
Option<Arc<RwLock<BankForks>>>
blob_sender
BlobSender
exit
&Arc<AtomicBool>
obj
Arc<RwLock<Self>>
bank_forks
Option<Arc<RwLock<BankForks>>>
blob_sender
BlobSender
exit
&Arc<AtomicBool>