async fn collect_funds(&mut self) -> Result<(), failure::Error> {
        log::info!("Starting collecting funds back to the main account");

        let mut signed_transfers = Vec::with_capacity(self.n_accounts);

        for from_id in 0..self.n_accounts {
            let from_acc = &self.accounts[from_id];
            let to_acc = &self.main_account.zk_acc;

            let fee = self.transfer_fee(&to_acc).await;

            let comitted_account_state = self
                .rpc_client
                .account_state_info(from_acc.address)
                .await?
                .committed;
            let account_balance = comitted_account_state.balances["ETH"].0.clone();
            let transfer_amount = &account_balance - &fee;
            let transfer_amount = closest_packable_token_amount(&transfer_amount);
            let transfer = self.sign_transfer(from_acc, to_acc, transfer_amount, fee);

            signed_transfers.push(transfer);
        }

        log::info!("Signed transfers, sending");

        // Send txs by batches that can fit in one block.
        let to_verify = signed_transfers.len();
        let mut verified = 0;
        let txs_chunks = DynamicChunks::new(signed_transfers, &self.block_sizes);
        for tx_batch in txs_chunks {
            let mut sent_txs = SentTransactions::new();
            // Send each tx.
            for (tx, eth_sign) in tx_batch {
                let tx_hash = self
                    .rpc_client
                    .send_tx(tx.clone(), eth_sign.clone())
                    .await?;
                sent_txs.add_tx_hash(tx_hash);
            }

            let sent_txs_amount = sent_txs.len();
            verified += sent_txs_amount;

            // Wait until all the transactions are verified.
            wait_for_verify(sent_txs, self.verify_timeout, &self.rpc_client).await?;

            log::info!(
                "Sent and verified {}/{} txs ({} on this iteration)",
                verified,
                to_verify,
                sent_txs_amount
            );
        }

        log::info!("Collecting funds completed");
        Ok(())
    }
/// Transfers all the money from the intermediate accounts back to the main account.
Transfers all the money from the intermediate accounts back to the main account.
Transfers all the money from the intermediate accounts back to the main account .
async fn collect_funds(&mut self) -> Result<(), failure::Error> {
        log::info!("Starting collecting funds back to the main account");
        let mut signed_transfers = Vec::with_capacity(self.n_accounts);
        for from_id in 0..self.n_accounts {
            let from_acc = &self.accounts[from_id];
            let to_acc = &self.main_account.zk_acc;
            let fee = self.transfer_fee(&to_acc).await;
            let comitted_account_state = self
                .rpc_client
                .account_state_info(from_acc.address)
                .await?
                .committed;
            let account_balance = comitted_account_state.balances["ETH"].0.clone();
            let transfer_amount = &account_balance - &fee;
            let transfer_amount = closest_packable_token_amount(&transfer_amount);
            let transfer = self.sign_transfer(from_acc, to_acc, transfer_amount, fee);
            signed_transfers.push(transfer);
        }
        log::info!("Signed transfers, sending");
        // Send txs by batches that can fit in one block.
        let to_verify = signed_transfers.len();
        let mut verified = 0;
        let txs_chunks = DynamicChunks::new(signed_transfers, &self.block_sizes);
        for tx_batch in txs_chunks {
            let mut sent_txs = SentTransactions::new();
            // Send each tx.
            for (tx, eth_sign) in tx_batch {
                let tx_hash = self
                    .rpc_client
                    .send_tx(tx.clone(), eth_sign.clone())
                    .await?;
                sent_txs.add_tx_hash(tx_hash);
            }
            let sent_txs_amount = sent_txs.len();
            verified += sent_txs_amount;
            // Wait until all the transactions are verified.
            wait_for_verify(sent_txs, self.verify_timeout, &self.rpc_client).await?;
            log::info!(
                "Sent and verified {}/{} txs ({} on this iteration)",
                verified,
                to_verify,
                sent_txs_amount
            );
        }
        log::info!("Collecting funds completed");
        Ok(())
    }
async fn collect_funds ( & mut self ) -> Result < ( ) , failure :: Error > { log :: info ! ( " " ) ; let mut signed_transfers = Vec :: with_capacity ( self . n_accounts ) ; for from_id in 0 .. self . n_accounts { let from_acc = & self . accounts [ from_id ] ; let to_acc = & self . main_account . zk_acc ; let fee = self . transfer_fee ( & to_acc ) . await ; let comitted_account_state = self . rpc_client . account_state_info ( from_acc . address ) . await ? . committed ; let account_balance = comitted_account_state . balances [ " " ] . 0 . clone ( ) ; let transfer_amount = & account_balance - & fee ; let transfer_amount = closest_packable_token_amount ( & transfer_amount ) ; let transfer = self . sign_transfer ( from_acc , to_acc , transfer_amount , fee ) ; signed_transfers . push ( transfer ) ; } log :: info ! ( " " ) ; // Send txs by batches that can fit in one block. let to_verify = signed_transfers . len ( ) ; let mut verified = 0 ; let txs_chunks = DynamicChunks :: new ( signed_transfers , & self . block_sizes ) ; for tx_batch in txs_chunks { let mut sent_txs = SentTransactions :: new ( ) ; // Send each tx. for ( tx , eth_sign ) in tx_batch { let tx_hash = self . rpc_client . send_tx ( tx . clone ( ) , eth_sign . clone ( ) ) . await ? ; sent_txs . add_tx_hash ( tx_hash ) ; } let sent_txs_amount = sent_txs . len ( ) ; verified += sent_txs_amount ; // Wait until all the transactions are verified. wait_for_verify ( sent_txs , self . verify_timeout , & self . rpc_client ) . await ? ; log :: info ! ( " " verified to_verify sent_txs_amount ) ; } log :: info ! ( " " ) ; Ok ( ( ) ) }
Transfers all the money from the intermediate accounts back to the main account.
Transfers all the money from the intermediate accounts back to the main account .
&mut self