}//constructor public string fixOneGuidCorner(int raida_ID, CloudCoin cc, int corner, int[] trustedTriad, int millisecondsToTimeout) { CoinUtils cu = new CoinUtils(cc); /*1. WILL THE BROKEN RAIDA FIX? check to see if it has problems echo, detect, or fix. */ if (RAIDA_Status.failsFix[raida_ID] || RAIDA_Status.failsEcho[raida_ID] || RAIDA_Status.failsEcho[raida_ID]) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" RAIDA Fails Echo or Fix. Try again when RAIDA online."); CoreLogger.Log(" RAIDA Fails Echo or Fix. Try again when RAIDA online."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA Fails Echo or Fix. Try again when RAIDA online."); } else { /*2. ARE ALL TRUSTED RAIDA IN THE CORNER READY TO HELP?*/ Console.WriteLine("Pown is " + cc.pown); char[] pown_chars = cc.pown.ToCharArray(); //See if First Trusted RAIDA can help if (!pown_chars[trustedTriad[0]].Equals('p')) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" RAIDA " + trustedTriad[0] + " can't help RAIDA " + raida_ID + " fix corner " + corner); CoreLogger.Log(" RAIDA " + trustedTriad[0] + " can't help RAIDA " + raida_ID + " fix corner " + corner); CoreLogger.Log(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA " + trustedTriad[0] + " can't help RAIDA " + raida_ID + " fix corner " + corner); } //See if Second Trusted RAIDA can help if (!pown_chars[trustedTriad[1]].Equals('p')) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" RAIDA " + trustedTriad[1] + " can't help RAIDA " + raida_ID + " fix corner " + corner); CoreLogger.Log(" RAIDA " + trustedTriad[1] + " can't help RAIDA " + raida_ID + " fix corner " + corner); CoreLogger.Log(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA " + trustedTriad[1] + " can't help RAIDA " + raida_ID + " fix corner " + corner); } //See if Third Trusted RAIDA can help if (!pown_chars[trustedTriad[2]].Equals('p')) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" RAIDA " + trustedTriad[2] + " can't help RAIDA " + raida_ID + " fix corner " + corner); CoreLogger.Log(" RAIDA " + trustedTriad[2] + " can't help RAIDA " + raida_ID + " fix corner " + corner); CoreLogger.Log(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA " + trustedTriad[2] + " can't help RAIDA " + raida_ID + " fix corner " + corner); } if (!RAIDA_Status.failsEcho[trustedTriad[0]] || !RAIDA_Status.failsDetect[trustedTriad[0]] || !RAIDA_Status.failsEcho[trustedTriad[1]] || !RAIDA_Status.failsDetect[trustedTriad[1]] || !RAIDA_Status.failsEcho[trustedTriad[2]] || !RAIDA_Status.failsDetect[trustedTriad[2]]) { /*3. GET TICKETS AND UPDATE RAIDA STATUS TICKETS*/ string[] ans = { cc.an[trustedTriad[0]], cc.an[trustedTriad[1]], cc.an[trustedTriad[2]] }; raida.get_Tickets(trustedTriad, ans, cc.nn, cc.sn, cu.getDenomination(), 3000); //Check to see if the coin actully is counterfeits and all the so called "p"s are actually "f"s. if (raida.responseArray[trustedTriad[0]].fullResponse.Contains("fail") && raida.responseArray[trustedTriad[1]].fullResponse.Contains("fail") && raida.responseArray[trustedTriad[2]].fullResponse.Contains("fail") ) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine("The coin is actually counterfeit. RAIDA marked 'passed' turned out to be fails."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("counterfeit " + corner); }//end if p's are actully fs. /*4. ARE ALL TICKETS GOOD?*/ if (RAIDA_Status.hasTicket[trustedTriad[0]] && RAIDA_Status.hasTicket[trustedTriad[1]] && RAIDA_Status.hasTicket[trustedTriad[2]]) { /*5.T YES, so REQUEST FIX*/ DetectionAgent da = new DetectionAgent(raida_ID); Response fixResponse = da.fix(trustedTriad, RAIDA_Status.tickets[trustedTriad[0]], RAIDA_Status.tickets[trustedTriad[1]], RAIDA_Status.tickets[trustedTriad[2]], cc.an[raida_ID]).Result; /*6. DID THE FIX WORK?*/ if (fixResponse.success) { Console.ForegroundColor = ConsoleColor.Green; Console.Out.WriteLine(""); Console.Out.WriteLine(" RAIDA" + raida_ID + " unfracked successfully."); CoreLogger.Log(" RAIDA" + raida_ID + " unfracked successfully."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA" + raida_ID + " unfracked successfully."); } else { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" RAIDA " + raida_ID + " failed to accept tickets on corner " + corner); CoreLogger.Log(" RAIDA failed to accept tickets on corner " + corner); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA failed to accept tickets on corner " + corner); }//end if fix respons was success or fail } else { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" Trusted servers failed to provide tickets for corner " + corner); Console.Out.WriteLine("RAIDa" + trustedTriad[0] + " " + RAIDA_Status.tickets[trustedTriad[0]] + ", RAIDa" + trustedTriad[1] + " " + RAIDA_Status.tickets[trustedTriad[1]] + ", RAIDa" + trustedTriad[2] + " " + RAIDA_Status.tickets[trustedTriad[2]]); CoreLogger.Log(" Trusted servers failed to provide tickets for corner " + corner); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return(" Trusted servers failed to provide tickets for corner " + corner);//no three good tickets }//end if all good }//end if trused triad will echo and detect (Detect is used to get ticket) Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine(" One or more of the trusted triad will not echo and detect.So not trying."); CoreLogger.Log(" One or more of the trusted triad will not echo and detect.So not trying."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return(" One or more of the trusted triad will not echo and detect. So not trying."); } //end if RAIDA fails to fix. } //end fix one
}//constructor public string fixOneGuidCorner(int raida_ID, CloudCoin cc, int corner, int[] trustedTriad) { CoinUtils cu = new CoinUtils(cc); /*1. WILL THE BROKEN RAIDA FIX? check to see if it has problems echo, detect, or fix. */ if (RAIDA_Status.failsFix[raida_ID] || RAIDA_Status.failsEcho[raida_ID] || RAIDA_Status.failsEcho[raida_ID]) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine("RAIDA Fails Echo or Fix. Try again when RAIDA online."); CoreLogger.Log("RAIDA Fails Echo or Fix. Try again when RAIDA online."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA Fails Echo or Fix. Try again when RAIDA online."); } else { /*2. ARE ALL TRUSTED RAIDA IN THE CORNER READY TO HELP?*/ // Console.Out.WriteLine("Fails echo 0 " + RAIDA_Status.failsEcho[trustedTriad[0]]); // Console.Out.WriteLine("Fails echo 1 " + RAIDA_Status.failsEcho[trustedTriad[1]]); // Console.Out.WriteLine("Fails echo 2 " + RAIDA_Status.failsEcho[trustedTriad[2]]); // Console.Out.WriteLine("Fails failsDetect 0 " + RAIDA_Status.failsDetect[trustedTriad[0]]); // Console.Out.WriteLine("Fails failsDetect 1 " + RAIDA_Status.failsDetect[trustedTriad[1]]); // Console.Out.WriteLine("Fails failsDetect 2 " + RAIDA_Status.failsDetect[trustedTriad[2]]); if (!RAIDA_Status.failsEcho[trustedTriad[0]] || !RAIDA_Status.failsDetect[trustedTriad[0]] || !RAIDA_Status.failsEcho[trustedTriad[1]] || !RAIDA_Status.failsDetect[trustedTriad[1]] || !RAIDA_Status.failsEcho[trustedTriad[2]] || !RAIDA_Status.failsDetect[trustedTriad[2]]) { /*3. GET TICKETS AND UPDATE RAIDA STATUS TICKETS*/ string[] ans = { cc.an[trustedTriad[0]], cc.an[trustedTriad[1]], cc.an[trustedTriad[2]] }; raida.get_Tickets(trustedTriad, ans, cc.nn, cc.sn, cu.getDenomination(), 3000); /*4. ARE ALL TICKETS GOOD?*/ if (RAIDA_Status.hasTicket[trustedTriad[0]] && RAIDA_Status.hasTicket[trustedTriad[0]] && RAIDA_Status.hasTicket[trustedTriad[0]]) { /*5.T YES, so REQUEST FIX*/ DetectionAgent da = new DetectionAgent(raida_ID, 5000); Response fixResponse = da.fix(trustedTriad, RAIDA_Status.tickets[trustedTriad[0]], RAIDA_Status.tickets[trustedTriad[1]], RAIDA_Status.tickets[trustedTriad[2]], cc.an[raida_ID]).Result; /*6. DID THE FIX WORK?*/ if (fixResponse.success) { Console.ForegroundColor = ConsoleColor.Green; Console.Out.WriteLine(""); Console.Out.WriteLine("RAIDA" + raida_ID + " unfracked successfully."); CoreLogger.Log("RAIDA" + raida_ID + " unfracked successfully."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA" + raida_ID + " unfracked successfully."); } else { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine("RAIDA failed to accept tickets on corner " + corner); CoreLogger.Log("RAIDA failed to accept tickets on corner " + corner); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("RAIDA failed to accept tickets on corner " + corner); }//end if fix respons was success or fail } else { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine("Trusted servers failed to provide tickets for corner " + corner); CoreLogger.Log("Trusted servers failed to provide tickets for corner " + corner); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("Trusted servers failed to provide tickets for corner " + corner);//no three good tickets }//end if all good }//end if trused triad will echo and detect (Detect is used to get ticket) Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(""); Console.Out.WriteLine("One or more of the trusted triad will not echo and detect.So not trying."); CoreLogger.Log("One or more of the trusted triad will not echo and detect.So not trying."); Console.Out.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; return("One or more of the trusted triad will not echo and detect. So not trying."); } //end if RAIDA fails to fix. } //end fix one