fn add_monitor_and_wait_for_sync(&mut self, entropy: &[u8; 32]) -> Result<(), String> {
        // Get account key from entropy
        let mut req = mobilecoind_api::GetAccountKeyRequest::new();
        req.set_entropy(entropy.to_vec());

        let mut resp = self
            .client
            .get_account_key(&req)
            .map_err(|err| format!("Failed getting account key for entropy: {}", err))?;

        let account_key = resp.take_account_key();

        // Add monitor for this account.
        let mut req = mobilecoind_api::AddMonitorRequest::new();
        req.set_account_key(account_key);
        req.set_first_subaddress(0);
        req.set_num_subaddresses(1);
        req.set_first_block(0);

        let resp = self
            .client
            .add_monitor(&req)
            .map_err(|err| format!("Failed adding monitor: {}", err))?;
        self.monitor_id = resp.get_monitor_id().to_vec();

        // Get current number of blocks in ledger.
        let resp = self
            .client
            .get_ledger_info(&mobilecoind_api::Empty::new())
            .map_err(|err| format!("Failed getting number of blocks in ledger: {}", err))?;
        let num_blocks = resp.block_count;

        let pb = ProgressBar::new(num_blocks);
        pb.set_style(
            ProgressStyle::default_bar()
                .template(
                    "Syncing account... {spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})",
                )
                .progress_chars("#>-"),
        );

        let mut blocks_synced = 0;
        while blocks_synced < num_blocks {
            // Get current number of blocks synced.
            let mut req = mobilecoind_api::GetMonitorStatusRequest::new();
            req.set_monitor_id(self.monitor_id.clone());

            let resp = self
                .client
                .get_monitor_status(&req)
                .map_err(|err| format!("Failed getting monitor status: {}", err))?;

            pb.set_position(blocks_synced);
            blocks_synced = resp.get_status().next_block;
        }

        // Done!
        Ok(())
    }
/// Add a monitor and wait for it to catch up.
Add a monitor and wait for it to catch up.
Add a monitor and wait for it to catch up .
fn add_monitor_and_wait_for_sync(&mut self, entropy: &[u8; 32]) -> Result<(), String> {
        // Get account key from entropy
        let mut req = mobilecoind_api::GetAccountKeyRequest::new();
        req.set_entropy(entropy.to_vec());
        let mut resp = self
            .client
            .get_account_key(&req)
            .map_err(|err| format!("Failed getting account key for entropy: {}", err))?;
        let account_key = resp.take_account_key();
        // Add monitor for this account.
        let mut req = mobilecoind_api::AddMonitorRequest::new();
        req.set_account_key(account_key);
        req.set_first_subaddress(0);
        req.set_num_subaddresses(1);
        req.set_first_block(0);
        let resp = self
            .client
            .add_monitor(&req)
            .map_err(|err| format!("Failed adding monitor: {}", err))?;
        self.monitor_id = resp.get_monitor_id().to_vec();
        // Get current number of blocks in ledger.
        let resp = self
            .client
            .get_ledger_info(&mobilecoind_api::Empty::new())
            .map_err(|err| format!("Failed getting number of blocks in ledger: {}", err))?;
        let num_blocks = resp.block_count;
        let pb = ProgressBar::new(num_blocks);
        pb.set_style(
            ProgressStyle::default_bar()
                .template(
                    "Syncing account... {spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})",
                )
                .progress_chars("#>-"),
        );
        let mut blocks_synced = 0;
        while blocks_synced < num_blocks {
            // Get current number of blocks synced.
            let mut req = mobilecoind_api::GetMonitorStatusRequest::new();
            req.set_monitor_id(self.monitor_id.clone());
            let resp = self
                .client
                .get_monitor_status(&req)
                .map_err(|err| format!("Failed getting monitor status: {}", err))?;
            pb.set_position(blocks_synced);
            blocks_synced = resp.get_status().next_block;
        }
        // Done!
        Ok(())
    }
fn add_monitor_and_wait_for_sync ( & mut self , entropy : & [ u8 ; 32 ] ) -> Result < ( ) , String > { // Get account key from entropy let mut req = mobilecoind_api :: GetAccountKeyRequest :: new ( ) ; req . set_entropy ( entropy . to_vec ( ) ) ; let mut resp = self . client . get_account_key ( & req ) . map_err ( | err | format ! ( " " err ) ) ? ; let account_key = resp . take_account_key ( ) ; // Add monitor for this account. let mut req = mobilecoind_api :: AddMonitorRequest :: new ( ) ; req . set_account_key ( account_key ) ; req . set_first_subaddress ( 0 ) ; req . set_num_subaddresses ( 1 ) ; req . set_first_block ( 0 ) ; let resp = self . client . add_monitor ( & req ) . map_err ( | err | format ! ( " " err ) ) ? ; self . monitor_id = resp . get_monitor_id ( ) . to_vec ( ) ; // Get current number of blocks in ledger. let resp = self . client . get_ledger_info ( & mobilecoind_api :: Empty :: new ( ) ) . map_err ( | err | format ! ( " " err ) ) ? ; let num_blocks = resp . block_count ; let pb = ProgressBar :: new ( num_blocks ) ; pb . set_style ( ProgressStyle :: default_bar ( ) . template ( " " , ) . progress_chars ( " " ) , ) ; let mut blocks_synced = 0 ; while blocks_synced < num_blocks { // Get current number of blocks synced. let mut req = mobilecoind_api :: GetMonitorStatusRequest :: new ( ) ; req . set_monitor_id ( self . monitor_id . clone ( ) ) ; let resp = self . client . get_monitor_status ( & req ) . map_err ( | err | format ! ( " " err ) ) ? ; pb . set_position ( blocks_synced ) ; blocks_synced = resp . get_status ( ) . next_block ; } // Done! Ok ( ( ) ) }
Add a monitor and wait for it to catch up.
Add a monitor and wait for it to catch up .
&mut self
entropy
&[u8; 32]
&mut self
entropy
&[u8; 32]