/// At random pick a node and try to get updated changes from them
At random pick a node and try to get updated changes from them
At random pick a node and try to get updated changes from them
fn run_gossip(obj: &Arc<RwLock<Self>>) -> Result<()> {
        //TODO we need to keep track of stakes and weight the selection by stake size
        //TODO cache sockets
        // Lock the object only to do this operation and not for any longer
        // especially not when doing the `sock.send_to`
        let (remote_gossip_addr, req) = obj.read().unwrap().gossip_request()?;
        let sock = UdpSocket::bind("0.0.0.0:0")?;
        // TODO this will get chatty, so we need to first ask for number of updates since
        // then only ask for specific data that we dont have
        let r = serialize(&req)?;
        sock.send_to(&r, remote_gossip_addr)?;
        Ok(())
    }
fn run_gossip ( obj : & Arc < RwLock < Self > > ) -> Result < ( ) > { //TODO we need to keep track of stakes and weight the selection by stake size //TODO cache sockets // Lock the object only to do this operation and not for any longer // especially not when doing the `sock.send_to` let ( remote_gossip_addr , req ) = obj . read ( ) . unwrap ( ) . gossip_request ( ) ? ; let sock = UdpSocket :: bind ( " " ) ? ; // TODO this will get chatty, so we need to first ask for number of updates since // then only ask for specific data that we dont have let r = serialize ( & req ) ? ; sock . send_to ( & r , remote_gossip_addr ) ? ; Ok ( ( ) ) }
At random pick a node and try to get updated changes from them
At random pick a node and try to get updated changes from them
obj
&Arc<RwLock<Self>>