pub fn submit_txns(
        &mut self,
        txn_req_chunks: Chunks<SubmitTransactionRequest>,
    ) -> (usize, u128) {
        let init_storage_cntr = self.get_committed_txns_counter();
        let now = time::Instant::now();
        // Zip txn_req_chunks with clients: when first iter returns none,
        // zip will short-circuit and next will not be called on the second iter.
        let children: Vec<thread::JoinHandle<Vec<ProtoSubmitTransactionResponse>>> = txn_req_chunks
            .zip(self.clients.iter().cycle())
            .map(|(chunk, client)| {
                let local_chunk = Vec::from(chunk);
                let local_client = Arc::clone(client);
                info!(
                    "Dispatch a chunk of {} requests to client.",
                    local_chunk.len()
                );
                // Spawn threads with corresponding client.
                thread::spawn(
                    // Submit a chunk of TXN requests async, wait and check the AC status,
                    // return the list of responses that are accepted by AC.
                    // Ignore (but count) both failed submissions and AC-rejected TXNs.
                    move || -> Vec<ProtoSubmitTransactionResponse> {
                        submit_and_wait_txn_requests(&local_client, &local_chunk)
                    },
                )
            })
            .collect();
        // Wait for threads and gather reponses.
        // TODO: Group response by error type and report staticstics.
        let mut txn_resps: Vec<ProtoSubmitTransactionResponse> = vec![];
        for child in children {
            let txn_resp_chunk = child.join().expect("failed to join a request thread");
            txn_resps.extend(txn_resp_chunk.into_iter());
        }
        let request_duration_ms = now.elapsed().as_millis();
        let comitted_during_submit = self.get_committed_txns_counter() - init_storage_cntr;
        info!(
            "Submitted and accepted {} TXNs within {} ms, during which {} already committed",
            txn_resps.len(),
            request_duration_ms,
            comitted_during_submit
        );
        (txn_resps.len(), request_duration_ms)
    }
/// Send requests to AC async, wait for responses from AC.
/// Return #accepted TXNs and submission duration.
Send requests to AC async, wait for responses from AC.
Return #accepted TXNs and submission duration.
Send requests to AC async wait for responses from AC . Return #accepted TXNs and submission duration .
pub fn submit_txns(
        &mut self,
        txn_req_chunks: Chunks<SubmitTransactionRequest>,
    ) -> (usize, u128) {
        let init_storage_cntr = self.get_committed_txns_counter();
        let now = time::Instant::now();
        // Zip txn_req_chunks with clients: when first iter returns none,
        // zip will short-circuit and next will not be called on the second iter.
        let children: Vec<thread::JoinHandle<Vec<ProtoSubmitTransactionResponse>>> = txn_req_chunks
            .zip(self.clients.iter().cycle())
            .map(|(chunk, client)| {
                let local_chunk = Vec::from(chunk);
                let local_client = Arc::clone(client);
                info!(
                    "Dispatch a chunk of {} requests to client.",
                    local_chunk.len()
                );
                // Spawn threads with corresponding client.
                thread::spawn(
                    // Submit a chunk of TXN requests async, wait and check the AC status,
                    // return the list of responses that are accepted by AC.
                    // Ignore (but count) both failed submissions and AC-rejected TXNs.
                    move || -> Vec<ProtoSubmitTransactionResponse> {
                        submit_and_wait_txn_requests(&local_client, &local_chunk)
                    },
                )
            })
            .collect();
        // Wait for threads and gather reponses.
        // TODO: Group response by error type and report staticstics.
        let mut txn_resps: Vec<ProtoSubmitTransactionResponse> = vec![];
        for child in children {
            let txn_resp_chunk = child.join().expect("failed to join a request thread");
            txn_resps.extend(txn_resp_chunk.into_iter());
        }
        let request_duration_ms = now.elapsed().as_millis();
        let comitted_during_submit = self.get_committed_txns_counter() - init_storage_cntr;
        info!(
            "Submitted and accepted {} TXNs within {} ms, during which {} already committed",
            txn_resps.len(),
            request_duration_ms,
            comitted_during_submit
        );
        (txn_resps.len(), request_duration_ms)
    }
pub fn submit_txns ( & mut self , txn_req_chunks : Chunks < SubmitTransactionRequest > , ) -> ( usize , u128 ) { let init_storage_cntr = self . get_committed_txns_counter ( ) ; let now = time :: Instant :: now ( ) ; // Zip txn_req_chunks with clients: when first iter returns none, // zip will short-circuit and next will not be called on the second iter. let children : Vec < thread :: JoinHandle < Vec < ProtoSubmitTransactionResponse > > > = txn_req_chunks . zip ( self . clients . iter ( ) . cycle ( ) ) . map ( | ( chunk , client ) | { let local_chunk = Vec :: from ( chunk ) ; let local_client = Arc :: clone ( client ) ; info ! ( " " local_chunk len ( ) ) ; // Spawn threads with corresponding client. thread :: spawn ( // Submit a chunk of TXN requests async, wait and check the AC status, // return the list of responses that are accepted by AC. // Ignore (but count) both failed submissions and AC-rejected TXNs. move | | -> Vec < ProtoSubmitTransactionResponse > { submit_and_wait_txn_requests ( & local_client , & local_chunk ) } , ) } ) . collect ( ) ; // Wait for threads and gather reponses. // TODO: Group response by error type and report staticstics. let mut txn_resps : Vec < ProtoSubmitTransactionResponse > = vec ! [ ] ; for child in children { let txn_resp_chunk = child . join ( ) . expect ( " " ) ; txn_resps . extend ( txn_resp_chunk . into_iter ( ) ) ; } let request_duration_ms = now . elapsed ( ) . as_millis ( ) ; let comitted_during_submit = self . get_committed_txns_counter ( ) - init_storage_cntr ; info ! ( " " txn_resps len ( ) request_duration_ms comitted_during_submit ) ; ( txn_resps . len ( ) , request_duration_ms ) }
Send requests to AC async, wait for responses from AC.
Send requests to AC async wait for responses from AC .
&mut self
txn_req_chunks
Chunks<SubmitTransactionRequest>