pub fn spawn<S: Storage + 'static, C: Client + 'static, O: TransactionObfuscation + 'static>(
        &mut self,
        config: ObfuscationSyncerConfig<S, C, O>,
    ) {
        log::info!("Spawning polling synchronizer");
        let wallets = self.wallets.clone();
        let progress = self.progress.clone();

        let (sender, receiver) = channel();
        thread::spawn(move || loop {
            let wallets_to_synchronize = wallets
                .lock()
                .expect("Unable to acquire lock on wallets to synchronize in polling synchronizer")
                .clone();

            for (name, passphrase) in wallets_to_synchronize.iter() {
                let result = WalletSyncer::with_obfuscation_config(
                    config.clone(),
                    Some(sender.clone()),
                    name.clone(),
                    passphrase.clone(),
                )
                .and_then(|syncer| syncer.sync());
                if let Err(e) = result {
                    log::error!("Error while synchronizing wallet [{}]: {:?}", name, e);
                }
            }

            thread::sleep(time::Duration::from_millis(100));
        });

        thread::spawn(move || {
            for progress_report in receiver.iter() {
                match progress_report {
                    ProgressReport::Init {
                        finish_block_height,
                        ..
                    } => {
                        log::trace!(
                            "Polling synchronizer: Current block height: {}",
                            finish_block_height
                        );

                        let mut current_progress = progress
                            .lock()
                            .expect("Unable to acquire lock on polling synchronizer's progress");

                        (*current_progress).last_block_height = finish_block_height;
                    }
                    ProgressReport::Update {
                        wallet_name,
                        current_block_height,
                    } => {
                        log::trace!(
                            "Polling synchronizer: Synchronized block [{}] for wallet: {}",
                            current_block_height,
                            wallet_name
                        );

                        let mut current_progress = progress
                            .lock()
                            .expect("Unable to acquire lock on polling synchronizer's progress");

                        (*current_progress)
                            .synchronization_progress
                            .insert(wallet_name, current_block_height);
                    }
                }
            }
        });
    }
/// Spawns polling synchronizer in a thread
Spawns polling synchronizer in a thread
Spawns polling synchronizer in a thread
pub fn spawn<S: Storage + 'static, C: Client + 'static, O: TransactionObfuscation + 'static>(
        &mut self,
        config: ObfuscationSyncerConfig<S, C, O>,
    ) {
        log::info!("Spawning polling synchronizer");
        let wallets = self.wallets.clone();
        let progress = self.progress.clone();
        let (sender, receiver) = channel();
        thread::spawn(move || loop {
            let wallets_to_synchronize = wallets
                .lock()
                .expect("Unable to acquire lock on wallets to synchronize in polling synchronizer")
                .clone();
            for (name, passphrase) in wallets_to_synchronize.iter() {
                let result = WalletSyncer::with_obfuscation_config(
                    config.clone(),
                    Some(sender.clone()),
                    name.clone(),
                    passphrase.clone(),
                )
                .and_then(|syncer| syncer.sync());
                if let Err(e) = result {
                    log::error!("Error while synchronizing wallet [{}]: {:?}", name, e);
                }
            }
            thread::sleep(time::Duration::from_millis(100));
        });
        thread::spawn(move || {
            for progress_report in receiver.iter() {
                match progress_report {
                    ProgressReport::Init {
                        finish_block_height,
                        ..
                    } => {
                        log::trace!(
                            "Polling synchronizer: Current block height: {}",
                            finish_block_height
                        );
                        let mut current_progress = progress
                            .lock()
                            .expect("Unable to acquire lock on polling synchronizer's progress");
                        (*current_progress).last_block_height = finish_block_height;
                    }
                    ProgressReport::Update {
                        wallet_name,
                        current_block_height,
                    } => {
                        log::trace!(
                            "Polling synchronizer: Synchronized block [{}] for wallet: {}",
                            current_block_height,
                            wallet_name
                        );
                        let mut current_progress = progress
                            .lock()
                            .expect("Unable to acquire lock on polling synchronizer's progress");
                        (*current_progress)
                            .synchronization_progress
                            .insert(wallet_name, current_block_height);
                    }
                }
            }
        });
    }
pub fn spawn < S : Storage + ' static , C : Client + ' static , O : TransactionObfuscation + ' static > ( & mut self , config : ObfuscationSyncerConfig < S , C , O > , ) { log :: info ! ( " " ) ; let wallets = self . wallets . clone ( ) ; let progress = self . progress . clone ( ) ; let ( sender , receiver ) = channel ( ) ; thread :: spawn ( move | | loop { let wallets_to_synchronize = wallets . lock ( ) . expect ( " " ) . clone ( ) ; for ( name , passphrase ) in wallets_to_synchronize . iter ( ) { let result = WalletSyncer :: with_obfuscation_config ( config . clone ( ) , Some ( sender . clone ( ) ) , name . clone ( ) , passphrase . clone ( ) , ) . and_then ( | syncer | syncer . sync ( ) ) ; if let Err ( e ) = result { log :: error ! ( " " name e ) ; } } thread :: sleep ( time :: Duration :: from_millis ( 100 ) ) ; } ) ; thread :: spawn ( move | | { for progress_report in receiver . iter ( ) { match progress_report { ProgressReport :: Init { finish_block_height , .. } => { log :: trace ! ( " " finish_block_height ) ; let mut current_progress = progress . lock ( ) . expect ( " " ) ; ( * current_progress ) . last_block_height = finish_block_height ; } ProgressReport :: Update { wallet_name , current_block_height , } => { log :: trace ! ( " " current_block_height wallet_name ) ; let mut current_progress = progress . lock ( ) . expect ( " " ) ; ( * current_progress ) . synchronization_progress . insert ( wallet_name , current_block_height ) ; } } } } ) ; }
Spawns polling synchronizer in a thread
Spawns polling synchronizer in a thread
&mut self
config
ObfuscationSyncerConfig<S, C, O>