fn receive_transactionconfimation(&mut self,
                _ctx: &Context<Protocol>,
                _msg: String,
                _sender: Sender) {
        let tx = self.tangle.get(&_msg);
        if tx.is_some() {
            let cpy = tx.unwrap().clone();          
            let timewarp = self.detect_timewarp(&cpy);
            if timewarp.is_some() {
                let tw = timewarp.unwrap();
                if self.last_picked_tw.is_some() {
                    let unwrapped = self.last_picked_tw.as_ref().unwrap();
                    if &unwrapped.last_picked_timewarp.hash == tw.target_hash() {
                        info!("Found connecting timewarp");
                    }
                }
                let known_tip = self.known_timewarp_tips.get(tw.target_hash());
                if known_tip.is_some() {
                    let unwrapped = known_tip.unwrap();
                    //check if we have an active walker ID.
                    //Not having this is default and will result in immediate storage of the ID
                    if unwrapped == "" || !self.known_active_walks.contains_key(unwrapped) {
                    
                        info!("Found a known timewarp Old: {} and new {}", tw.target_hash().to_string(), tw.source_hash.to_string());
                        self.known_timewarp_tips.remove(tw.target_hash());
                        self.known_timewarp_tips.insert(tw.source_hash.to_string(), String::new());

                        let tw_data = self.storage.tw_detection_add_decision_data(tw.clone());
                        let _res = self.storage.tw_detection_add_to_index(get_time_key(&tw.source_timestamp), 
                            vec![
                                (tw.source_hash.to_string(), tw.target_hash().to_string()), 
                                (format!("{}{}", TIMEWARP_ID_PREFIX, tw_data.timewarpid), tw_data.hash.to_string())
                            ]);

                    }else{
                        info!("Caching lagging timewarp. {}", tw.source_hash.to_string());

                        let vec_to_add = self.known_active_walks.get_mut(unwrapped).expect("The key to be there");
                        //Todo how do I fix borrowing issues here?
                        self.known_timewarp_tips.insert(tw.source_hash.to_string(), unwrapped.to_string());
                        self.known_timewarp_tips.remove(tw.target_hash());
                        vec_to_add.push(tw.clone());
                    }
                   
                }else{

                    info!("Found a new timewarp!!!!!, start following ToB {} - {} - {}", tw.trunk_or_branch , tw.source_hash.to_string(), tw.target_hash().to_string());
                    let my_actor3 = _ctx.actor_of(TimewarpWalker::props(self.storage.clone()), &format!("timewarp-walking-{}", tw.source_hash.to_string())).unwrap();

                    let tw_start = StartTimewarpWalking { 
                        source_hash: cpy.hash, 
                        source_branch: cpy.branch_transaction,
                        source_trunk: cpy.trunk_transaction,
                        source_tag: cpy.tag,
                        distance: tw.distance,
                        source_timestamp: cpy.attachment_timestamp, 
                        trunk_or_branch: tw.trunk_or_branch,
                        last_picked_tw_tx: {
                           if self.last_picked_tw.is_some() {
                                let r = &self.last_picked_tw.as_ref().unwrap().last_picked_timewarp.hash;
                                r.to_owned()
                           }else{
                                String::from("")
                           }
                        }};
                    //Insert in caching of active timewarps. So they get added 
                    self.known_timewarp_tips.insert(tw.source_hash.to_string(), tw_start.id());
                    self.known_active_walks.insert(tw_start.id(), Vec::new());

                    my_actor3.tell(Protocol::StartTimewarpWalking(tw_start)
                       , Some(BasicActorRef::from(_ctx.myself())));
                }
            }
        }
        
        //println!("Receiving transaction {}", _msg.tx.id);               
    }
/**
 * Handles receiving a confirmed transaction.
 * It calles detect timewarp and if one is found it will look into it's cache to see
 * if it references a previously found timewarp. If not it will start a timewarp walker
 */
Handles receiving a confirmed transaction.
It calles detect timewarp and if one is found it will look into it's cache to see
if it references a previously found timewarp. If not it will start a timewarp walker
Handles receiving a confirmed transaction . It calles detect timewarp and if one is found it will look into it ' s cache to see if it references a previously found timewarp . If not it will start a timewarp walker
fn receive_transactionconfimation(&mut self,
                _ctx: &Context<Protocol>,
                _msg: String,
                _sender: Sender) {
        let tx = self.tangle.get(&_msg);
        if tx.is_some() {
            let cpy = tx.unwrap().clone();          
            let timewarp = self.detect_timewarp(&cpy);
            if timewarp.is_some() {
                let tw = timewarp.unwrap();
                if self.last_picked_tw.is_some() {
                    let unwrapped = self.last_picked_tw.as_ref().unwrap();
                    if &unwrapped.last_picked_timewarp.hash == tw.target_hash() {
                        info!("Found connecting timewarp");
                    }
                }
                let known_tip = self.known_timewarp_tips.get(tw.target_hash());
                if known_tip.is_some() {
                    let unwrapped = known_tip.unwrap();
                    //check if we have an active walker ID.
                    //Not having this is default and will result in immediate storage of the ID
                    if unwrapped == "" || !self.known_active_walks.contains_key(unwrapped) {
                        info!("Found a known timewarp Old: {} and new {}", tw.target_hash().to_string(), tw.source_hash.to_string());
                        self.known_timewarp_tips.remove(tw.target_hash());
                        self.known_timewarp_tips.insert(tw.source_hash.to_string(), String::new());
                        let tw_data = self.storage.tw_detection_add_decision_data(tw.clone());
                        let _res = self.storage.tw_detection_add_to_index(get_time_key(&tw.source_timestamp), 
                            vec![
                                (tw.source_hash.to_string(), tw.target_hash().to_string()), 
                                (format!("{}{}", TIMEWARP_ID_PREFIX, tw_data.timewarpid), tw_data.hash.to_string())
                            ]);
                    }else{
                        info!("Caching lagging timewarp. {}", tw.source_hash.to_string());
                        let vec_to_add = self.known_active_walks.get_mut(unwrapped).expect("The key to be there");
                        //Todo how do I fix borrowing issues here?
                        self.known_timewarp_tips.insert(tw.source_hash.to_string(), unwrapped.to_string());
                        self.known_timewarp_tips.remove(tw.target_hash());
                        vec_to_add.push(tw.clone());
                    }
                }else{
                    info!("Found a new timewarp!!!!!, start following ToB {} - {} - {}", tw.trunk_or_branch , tw.source_hash.to_string(), tw.target_hash().to_string());
                    let my_actor3 = _ctx.actor_of(TimewarpWalker::props(self.storage.clone()), &format!("timewarp-walking-{}", tw.source_hash.to_string())).unwrap();
                    let tw_start = StartTimewarpWalking { 
                        source_hash: cpy.hash, 
                        source_branch: cpy.branch_transaction,
                        source_trunk: cpy.trunk_transaction,
                        source_tag: cpy.tag,
                        distance: tw.distance,
                        source_timestamp: cpy.attachment_timestamp, 
                        trunk_or_branch: tw.trunk_or_branch,
                        last_picked_tw_tx: {
                           if self.last_picked_tw.is_some() {
                                let r = &self.last_picked_tw.as_ref().unwrap().last_picked_timewarp.hash;
                                r.to_owned()
                           }else{
                                String::from("")
                           }
                        }};
                    //Insert in caching of active timewarps. So they get added 
                    self.known_timewarp_tips.insert(tw.source_hash.to_string(), tw_start.id());
                    self.known_active_walks.insert(tw_start.id(), Vec::new());
                    my_actor3.tell(Protocol::StartTimewarpWalking(tw_start)
                       , Some(BasicActorRef::from(_ctx.myself())));
                }
            }
        }
        //println!("Receiving transaction {}", _msg.tx.id);               
    }
fn receive_transactionconfimation ( & mut self , _ctx : & Context < Protocol > , _msg : String , _sender : Sender ) { let tx = self . tangle . get ( & _msg ) ; if tx . is_some ( ) { let cpy = tx . unwrap ( ) . clone ( ) ; let timewarp = self . detect_timewarp ( & cpy ) ; if timewarp . is_some ( ) { let tw = timewarp . unwrap ( ) ; if self . last_picked_tw . is_some ( ) { let unwrapped = self . last_picked_tw . as_ref ( ) . unwrap ( ) ; if & unwrapped . last_picked_timewarp . hash == tw . target_hash ( ) { info ! ( " " ) ; } } let known_tip = self . known_timewarp_tips . get ( tw . target_hash ( ) ) ; if known_tip . is_some ( ) { let unwrapped = known_tip . unwrap ( ) ; //check if we have an active walker ID. //Not having this is default and will result in immediate storage of the ID if unwrapped == " " || ! self . known_active_walks . contains_key ( unwrapped ) { info ! ( " " tw target_hash ( ) to_string ( ) tw source_hash to_string ( ) ) ; self . known_timewarp_tips . remove ( tw . target_hash ( ) ) ; self . known_timewarp_tips . insert ( tw . source_hash . to_string ( ) , String :: new ( ) ) ; let tw_data = self . storage . tw_detection_add_decision_data ( tw . clone ( ) ) ; let _res = self . storage . tw_detection_add_to_index ( get_time_key ( & tw . source_timestamp ) , vec ! [ ( tw source_hash to_string ( ) tw target_hash ( ) to_string ( ) ) ( format ( " " TIMEWARP_ID_PREFIX tw_data timewarpid ) tw_data hash to_string ( ) ) ] ) ; } else { info ! ( " " tw source_hash to_string ( ) ) ; let vec_to_add = self . known_active_walks . get_mut ( unwrapped ) . expect ( " " ) ; //Todo how do I fix borrowing issues here? self . known_timewarp_tips . insert ( tw . source_hash . to_string ( ) , unwrapped . to_string ( ) ) ; self . known_timewarp_tips . remove ( tw . target_hash ( ) ) ; vec_to_add . push ( tw . clone ( ) ) ; } } else { info ! ( " " tw trunk_or_branch tw source_hash to_string ( ) tw target_hash ( ) to_string ( ) ) ; let my_actor3 = _ctx . actor_of ( TimewarpWalker :: props ( self . storage . clone ( ) ) , & format ! ( " " tw source_hash to_string ( ) ) ) . unwrap ( ) ; let tw_start = StartTimewarpWalking { source_hash : cpy . hash , source_branch : cpy . branch_transaction , source_trunk : cpy . trunk_transaction , source_tag : cpy . tag , distance : tw . distance , source_timestamp : cpy . attachment_timestamp , trunk_or_branch : tw . trunk_or_branch , last_picked_tw_tx : { if self . last_picked_tw . is_some ( ) { let r = & self . last_picked_tw . as_ref ( ) . unwrap ( ) . last_picked_timewarp . hash ; r . to_owned ( ) } else { String :: from ( " " ) } } } ; //Insert in caching of active timewarps. So they get added  self . known_timewarp_tips . insert ( tw . source_hash . to_string ( ) , tw_start . id ( ) ) ; self . known_active_walks . insert ( tw_start . id ( ) , Vec :: new ( ) ) ; my_actor3 . tell ( Protocol :: StartTimewarpWalking ( tw_start ) , Some ( BasicActorRef :: from ( _ctx . myself ( ) ) ) ) ; } } } //println!("Receiving transaction {}", _msg.tx.id);                }
Handles receiving a confirmed transaction.
Handles receiving a confirmed transaction .
&mut self
_ctx
&Context<Protocol>
_msg
String
_sender
Sender
&mut self
_ctx
&Context<Protocol>
_msg
String
_sender
Sender