pub fn retransmit_to(
        obj: &Arc<RwLock<Self>>,
        peers: &[ContactInfo],
        blob: &SharedBlob,
        slot_leader_pubkey: Option<Pubkey>,
        s: &UdpSocket,
        forwarded: bool,
    ) -> Result<()> {
        let (me, orders): (ContactInfo, &[ContactInfo]) = {
            // copy to avoid locking during IO
            let s = obj.read().unwrap();
            (s.my_data().clone(), peers)
        };
        // hold a write lock so no one modifies the blob until we send it
        let mut wblob = blob.write().unwrap();
        let was_forwarded = !wblob.should_forward();
        wblob.set_forwarded(forwarded);
        trace!("retransmit orders {}", orders.len());
        let errs: Vec<_> = orders
            .par_iter()
            .filter(|v| v.id != slot_leader_pubkey.unwrap_or_default())
            .map(|v| {
                debug!(
                    "{}: retransmit blob {} to {} {}",
                    me.id,
                    wblob.index(),
                    v.id,
                    v.tvu,
                );
                //TODO profile this, may need multiple sockets for par_iter
                assert!(wblob.meta.size <= BLOB_SIZE);
                s.send_to(&wblob.data[..wblob.meta.size], &v.tvu)
            })
            .collect();
        // reset the blob to its old state. This avoids us having to copy the blob to modify it
        wblob.set_forwarded(was_forwarded);
        for e in errs {
            if let Err(e) = &e {
                inc_new_counter_error!("cluster_info-retransmit-send_to_error", 1, 1);
                // error!("{}", Error(format!("retransmit result {:?}", e).to_string()));
                println!(
                    "{}",
                    Error(
                        format!("retransmit result {:?}", e).to_string(),
                        module_path!().to_string()
                    )
                );
            }
            e?;
        }
        Ok(())
    }
/// retransmit messages to a list of nodes
/// # Remarks
/// We need to avoid having obj locked while doing any io, such as the `send_to`
retransmit messages to a list of nodes
retransmit messages to a list of nodes
pub fn retransmit_to(
        obj: &Arc<RwLock<Self>>,
        peers: &[ContactInfo],
        blob: &SharedBlob,
        slot_leader_pubkey: Option<Pubkey>,
        s: &UdpSocket,
        forwarded: bool,
    ) -> Result<()> {
        let (me, orders): (ContactInfo, &[ContactInfo]) = {
            // copy to avoid locking during IO
            let s = obj.read().unwrap();
            (s.my_data().clone(), peers)
        };
        // hold a write lock so no one modifies the blob until we send it
        let mut wblob = blob.write().unwrap();
        let was_forwarded = !wblob.should_forward();
        wblob.set_forwarded(forwarded);
        trace!("retransmit orders {}", orders.len());
        let errs: Vec<_> = orders
            .par_iter()
            .filter(|v| v.id != slot_leader_pubkey.unwrap_or_default())
            .map(|v| {
                debug!(
                    "{}: retransmit blob {} to {} {}",
                    me.id,
                    wblob.index(),
                    v.id,
                    v.tvu,
                );
                //TODO profile this, may need multiple sockets for par_iter
                assert!(wblob.meta.size <= BLOB_SIZE);
                s.send_to(&wblob.data[..wblob.meta.size], &v.tvu)
            })
            .collect();
        // reset the blob to its old state. This avoids us having to copy the blob to modify it
        wblob.set_forwarded(was_forwarded);
        for e in errs {
            if let Err(e) = &e {
                inc_new_counter_error!("cluster_info-retransmit-send_to_error", 1, 1);
                // error!("{}", Error(format!("retransmit result {:?}", e).to_string()));
                println!(
                    "{}",
                    Error(
                        format!("retransmit result {:?}", e).to_string(),
                        module_path!().to_string()
                    )
                );
            }
            e?;
        }
        Ok(())
    }
pub fn retransmit_to ( obj : & Arc < RwLock < Self > > , peers : & [ ContactInfo ] , blob : & SharedBlob , slot_leader_pubkey : Option < Pubkey > , s : & UdpSocket , forwarded : bool , ) -> Result < ( ) > { let ( me , orders ) : ( ContactInfo , & [ ContactInfo ] ) = { // copy to avoid locking during IO let s = obj . read ( ) . unwrap ( ) ; ( s . my_data ( ) . clone ( ) , peers ) } ; // hold a write lock so no one modifies the blob until we send it let mut wblob = blob . write ( ) . unwrap ( ) ; let was_forwarded = ! wblob . should_forward ( ) ; wblob . set_forwarded ( forwarded ) ; trace ! ( " " orders len ( ) ) ; let errs : Vec < _ > = orders . par_iter ( ) . filter ( | v | v . id != slot_leader_pubkey . unwrap_or_default ( ) ) . map ( | v | { debug ! ( " " me id wblob index ( ) v id v tvu ) ; //TODO profile this, may need multiple sockets for par_iter assert ! ( wblob meta size BLOB_SIZE ) ; s . send_to ( & wblob . data [ .. wblob . meta . size ] , & v . tvu ) } ) . collect ( ) ; // reset the blob to its old state. This avoids us having to copy the blob to modify it wblob . set_forwarded ( was_forwarded ) ; for e in errs { if let Err ( e ) = & e { inc_new_counter_error ! ( " " 1 1 ) ; // error!("{}", Error(format!("retransmit result {:?}", e).to_string())); println ! ( " " Error ( format ( " " e ) to_string ( ) module_path ( ) to_string ( ) ) ) ; } e ? ; } Ok ( ( ) ) }
retransmit messages to a list of nodes
retransmit messages to a list of nodes
obj
&Arc<RwLock<Self>>
peers
&[ContactInfo]
blob
&SharedBlob
slot_leader_pubkey
Option<Pubkey>
s
&UdpSocket
forwarded
bool
obj
&Arc<RwLock<Self>>
peers
&[ContactInfo]
blob
&SharedBlob
slot_leader_pubkey
Option<Pubkey>
s
&UdpSocket
forwarded
bool
remarks
We need to avoid having obj locked while doing any io, such as the `send_to`
We need to avoid having obj locked while doing any io such as the ` send_to `