}//end detectOne public CoinUtils detectCoin(CoinUtils cu, int milliSecondsToTimeOut) { cu.generatePan(); var t00 = detectOne(00, cu.cc.nn, cu.cc.sn, cu.cc.an[00], cu.pans[00], cu.getDenomination()); var t01 = detectOne(01, cu.cc.nn, cu.cc.sn, cu.cc.an[01], cu.pans[01], cu.getDenomination()); var t02 = detectOne(02, cu.cc.nn, cu.cc.sn, cu.cc.an[02], cu.pans[02], cu.getDenomination()); var t03 = detectOne(03, cu.cc.nn, cu.cc.sn, cu.cc.an[03], cu.pans[03], cu.getDenomination()); var t04 = detectOne(04, cu.cc.nn, cu.cc.sn, cu.cc.an[04], cu.pans[04], cu.getDenomination()); var t05 = detectOne(05, cu.cc.nn, cu.cc.sn, cu.cc.an[05], cu.pans[05], cu.getDenomination()); var t06 = detectOne(06, cu.cc.nn, cu.cc.sn, cu.cc.an[06], cu.pans[06], cu.getDenomination()); var t07 = detectOne(07, cu.cc.nn, cu.cc.sn, cu.cc.an[07], cu.pans[07], cu.getDenomination()); var t08 = detectOne(08, cu.cc.nn, cu.cc.sn, cu.cc.an[08], cu.pans[08], cu.getDenomination()); var t09 = detectOne(09, cu.cc.nn, cu.cc.sn, cu.cc.an[09], cu.pans[09], cu.getDenomination()); var t10 = detectOne(10, cu.cc.nn, cu.cc.sn, cu.cc.an[10], cu.pans[10], cu.getDenomination()); var t11 = detectOne(11, cu.cc.nn, cu.cc.sn, cu.cc.an[11], cu.pans[11], cu.getDenomination()); var t12 = detectOne(12, cu.cc.nn, cu.cc.sn, cu.cc.an[12], cu.pans[12], cu.getDenomination()); var t13 = detectOne(13, cu.cc.nn, cu.cc.sn, cu.cc.an[13], cu.pans[13], cu.getDenomination()); var t14 = detectOne(14, cu.cc.nn, cu.cc.sn, cu.cc.an[14], cu.pans[14], cu.getDenomination()); var t15 = detectOne(15, cu.cc.nn, cu.cc.sn, cu.cc.an[15], cu.pans[15], cu.getDenomination()); var t16 = detectOne(16, cu.cc.nn, cu.cc.sn, cu.cc.an[16], cu.pans[16], cu.getDenomination()); var t17 = detectOne(17, cu.cc.nn, cu.cc.sn, cu.cc.an[17], cu.pans[17], cu.getDenomination()); var t18 = detectOne(18, cu.cc.nn, cu.cc.sn, cu.cc.an[18], cu.pans[18], cu.getDenomination()); var t19 = detectOne(19, cu.cc.nn, cu.cc.sn, cu.cc.an[19], cu.pans[19], cu.getDenomination()); var t20 = detectOne(20, cu.cc.nn, cu.cc.sn, cu.cc.an[20], cu.pans[20], cu.getDenomination()); var t21 = detectOne(21, cu.cc.nn, cu.cc.sn, cu.cc.an[21], cu.pans[21], cu.getDenomination()); var t22 = detectOne(22, cu.cc.nn, cu.cc.sn, cu.cc.an[22], cu.pans[22], cu.getDenomination()); var t23 = detectOne(23, cu.cc.nn, cu.cc.sn, cu.cc.an[23], cu.pans[23], cu.getDenomination()); var t24 = detectOne(24, cu.cc.nn, cu.cc.sn, cu.cc.an[24], cu.pans[24], cu.getDenomination()); var taskList = new List <Task> { t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24 }; Task.WaitAll(taskList.ToArray(), milliSecondsToTimeOut); //Get data from the detection agents for (int i = 0; i < 25; i++) { if (responseArray[i] != null) { cu.setPastStatus(responseArray[i].outcome, i); CoreLogger.Log(cu.cc.sn + " detect:" + i + " " + responseArray[i].fullResponse); } else { cu.setPastStatus("undetected", i); };// should be pass, fail, error or undetected. }//end for each detection agent cu.setAnsToPansIfPassed(); cu.calculateHP(); // cu.gradeCoin(); // sets the grade and figures out what the file extension should be (bank, fracked, counterfeit, lost cu.calcExpirationDate(); cu.grade(); return(cu); }//end detect coin
}//End Write To public void overWrite(String folder, CloudCoin cc) { CoinUtils cu = new CoinUtils(cc); const string quote = "\""; const string tab = "\t"; String wholeJson = "{" + Environment.NewLine; //{ String json = this.setJSON(cc); wholeJson += tab + quote + "cloudcoin" + quote + ": [" + Environment.NewLine; // "cloudcoin" : [ wholeJson += json; wholeJson += Environment.NewLine + tab + "]" + Environment.NewLine + "}"; File.WriteAllText(folder + cu.fileName + ".stack", wholeJson); }//End Overwrite
}//end importJSON // en d json test public String setJSON(CloudCoin cc) { const string quote = "\""; const string tab = "\t"; String json = (tab + tab + "{ " + Environment.NewLine); // { json += tab + tab + quote + "nn" + quote + ":" + quote + cc.nn + quote + ", " + Environment.NewLine; // "nn":"1", json += tab + tab + quote + "sn" + quote + ":" + quote + cc.sn + quote + ", " + Environment.NewLine; // "sn":"367544", json += tab + tab + quote + "an" + quote + ": [" + quote; // "an": [" for (int i = 0; (i < 25); i++) { json += cc.an[i];// 8551995a45457754aaaa44 if (i == 4 || i == 9 || i == 14 || i == 19) { json += quote + "," + Environment.NewLine + tab + tab + tab + quote; //", } else if (i == 24) { // json += "\""; last one do nothing } else { // end if is line break json += quote + ", " + quote; } // end else }// end for 25 ans json += quote + "]," + Environment.NewLine;//"], // End of ans CoinUtils cu = new CoinUtils(cc); cu.calcExpirationDate(); json += tab + tab + quote + "ed" + quote + ":" + quote + cu.cc.ed + quote + "," + Environment.NewLine; // "ed":"9-2016", if (string.IsNullOrEmpty(cc.pown)) { cc.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; } //Set pown to unknow if it is not set. json += tab + tab + quote + "pown" + quote + ":" + quote + cc.pown + quote + "," + Environment.NewLine; // "pown":"uuupppppffpppppfuuf", json += tab + tab + quote + "aoid" + quote + ": []" + Environment.NewLine; json += tab + tab + "}" + Environment.NewLine; // Keep expiration date when saving (not a truley accurate but good enought ) return(json); }
}//end read all bytes public bool writeTo(String folder, CloudCoin cc) { CoinUtils cu = new CoinUtils(cc); const string quote = "\""; const string tab = "\t"; String wholeJson = "{" + Environment.NewLine; //{ bool alreadyExists = true; String json = this.setJSON(cc); if (!File.Exists(folder + cu.fileName + ".stack")) { wholeJson += tab + quote + "cloudcoin" + quote + ": [" + Environment.NewLine; // "cloudcoin" : [ wholeJson += json; wholeJson += Environment.NewLine + tab + "]" + Environment.NewLine + "}"; File.WriteAllText(folder + cu.fileName + ".stack", wholeJson); } else { if (folder.Contains("Counterfeit") || folder.Contains("Trash")) { //Let the program delete it alreadyExists = false; return(alreadyExists); } else if (folder.Contains("Imported")) { File.Delete(folder + cu.fileName + ".stack"); File.WriteAllText(folder + cu.fileName + ".stack", wholeJson); alreadyExists = false; return(alreadyExists); } else { Console.WriteLine(cu.fileName + ".stack" + " already exists in the folder " + folder); CoreLogger.Log(cu.fileName + ".stack" + " already exists in the folder " + folder); return(alreadyExists); } //end else } //File Exists File.WriteAllText(folder + cu.fileName + ".stack", wholeJson); alreadyExists = false; return(alreadyExists); }//End Write To
// end get JSON /* Writes a JPEG To the Export Folder */ public bool writeJpeg(CloudCoin cc, string tag) { // Console.Out.WriteLine("Writing jpeg " + cc.sn); CoinUtils cu = new CoinUtils(cc); bool fileSavedSuccessfully = true; /* BUILD THE CLOUDCOIN STRING */ String cloudCoinStr = "01C34A46494600010101006000601D05"; //THUMBNAIL HEADER BYTES for (int i = 0; (i < 25); i++) { cloudCoinStr = cloudCoinStr + cc.an[i]; } // end for each an //cloudCoinStr += "204f42455920474f4420262044454645415420545952414e545320";// Hex for " OBEY GOD & DEFEAT TYRANTS " //cloudCoinStr += "20466f756e6465727320372d352d3137";// Founders 7-5-17 cloudCoinStr += "4c6976652046726565204f7220446965"; // Live Free or Die cloudCoinStr += "00000000000000000000000000"; //Set to unknown so program does not export user data // for (int i =0; i < 25; i++) { // switch () { }//end switch pown char // }//end for each pown cloudCoinStr += "00"; // HC: Has comments. 00 = No cu.calcExpirationDate(); cloudCoinStr += cu.edHex; // 01;//Expiration date Sep 2016 (one month after zero month) cloudCoinStr += "01"; // cc.nn;//network number String hexSN = cc.sn.ToString("X6"); String fullHexSN = ""; switch (hexSN.Length) { case 1: fullHexSN = ("00000" + hexSN); break; case 2: fullHexSN = ("0000" + hexSN); break; case 3: fullHexSN = ("000" + hexSN); break; case 4: fullHexSN = ("00" + hexSN); break; case 5: fullHexSN = ("0" + hexSN); break; case 6: fullHexSN = hexSN; break; } cloudCoinStr = (cloudCoinStr + fullHexSN); /* BYTES THAT WILL GO FROM 04 to 454 (Inclusive)*/ byte[] ccArray = this.hexStringToByteArray(cloudCoinStr); /* READ JPEG TEMPLATE*/ byte[] jpegBytes = null; switch (cu.getDenomination()) { case 1: jpegBytes = readAllBytes(this.templateFolder + "jpeg1.jpg"); break; case 5: jpegBytes = readAllBytes(this.templateFolder + "jpeg5.jpg"); break; case 25: jpegBytes = readAllBytes(this.templateFolder + "jpeg25.jpg"); break; case 100: jpegBytes = readAllBytes(this.templateFolder + "jpeg100.jpg"); break; case 250: jpegBytes = readAllBytes(this.templateFolder + "jpeg250.jpg"); break; }// end switch /* WRITE THE SERIAL NUMBER ON THE JPEG */ //Bitmap bitmapimage; SKBitmap bitmapimage; //using (var ms = new MemoryStream(jpegBytes)) { //bitmapimage = new Bitmap(ms); bitmapimage = SKBitmap.Decode(jpegBytes); } SKCanvas canvas = new SKCanvas(bitmapimage); //Graphics graphics = Graphics.FromImage(bitmapimage); //graphics.SmoothingMode = SmoothingMode.AntiAlias; //graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; SKPaint textPaint = new SKPaint() { IsAntialias = true, Color = SKColors.White, TextSize = 14, Typeface = SKTypeface.FromFamilyName("Arial") }; //PointF drawPointAddress = new PointF(30.0F, 25.0F); canvas.DrawText(String.Format("{0:N0}", cc.sn) + " of 16,777,216 on Network: 1", 30, 40, textPaint); //graphics.DrawString(String.Format("{0:N0}", cc.sn) + " of 16,777,216 on Network: 1", new Font("Arial", 10), Brushes.White, drawPointAddress); //ImageConverter converter = new ImageConverter(); //byte[] snBytes = (byte[])converter.ConvertTo(bitmapimage, typeof(byte[])); SKImage image = SKImage.FromBitmap(bitmapimage); SKData data = image.Encode(SKEncodedImageFormat.Jpeg, 100); byte[] snBytes = data.ToArray(); List <byte> b1 = new List <byte>(snBytes); List <byte> b2 = new List <byte>(ccArray); b1.InsertRange(4, b2); if (tag == "random") { Random r = new Random(); int rInt = r.Next(100000, 1000000); //for ints tag = rInt.ToString(); } string fileName = exportFolder + cu.fileName + tag + ".jpg"; File.WriteAllBytes(fileName, b1.ToArray()); Console.Out.WriteLine("Writing to " + fileName); CoreLogger.Log("Writing to " + fileName); return(fileSavedSuccessfully); }//end write JPEG
}// end Detect constructor /* PUBLIC METHODS */ /// <summary> /// /// </summary> /// <returns></returns> public int[] detectAll() { // LOAD THE .suspect COINS ONE AT A TIME AND TEST THEM int[] results = new int[4]; // [0] Coins to bank, [1] Coins to fracked [2] Coins to Counterfeit String[] suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder).GetFiles("*.stack").Select(o => o.Name).ToArray(); //Get all files in suspect folder int totalValueToBank = 0; int totalValueToCounterfeit = 0; int totalValueToFractured = 0; int totalValueToKeptInSuspect = 0; bool coinSupect = false; CloudCoin newCC; for (int j = 0; j < suspectFileNames.Length; j++) { try { if (File.Exists(this.fileUtils.bankFolder + suspectFileNames[j])) {//Coin has already been imported. Delete it from import folder move to trash. Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine("You tried to import a coin that has already been imported."); CoreLogger.Log("You tried to import a coin that has already been imported."); File.Move(this.fileUtils.suspectFolder + suspectFileNames[j], this.fileUtils.trashFolder + suspectFileNames[j]); Console.Out.WriteLine("Suspect CloudCoin was moved to Trash folder."); CoreLogger.Log("Suspect CloudCoin was moved to Trash folder."); Console.ForegroundColor = ConsoleColor.White; } else { newCC = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.suspectFolder + suspectFileNames[j]); CoinUtils cu = new CoinUtils(newCC); Console.Out.WriteLine("Now scanning coin " + (j + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", newCC.sn) + ", Denomination: " + cu.getDenomination()); CoreLogger.Log("Now scanning coin " + (j + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", newCC.sn) + ", Denomination: " + cu.getDenomination()); Console.Out.WriteLine(""); CoinUtils detectedCC = this.raida.detectCoin(cu, detectTime); cu.calcExpirationDate(); if (j == 0) //If we are detecting the first coin, note if the RAIDA are working { for (int i = 0; i < 25; i++) // Checks any servers are down so we don't try to check them again. { if (cu.getPastStatus(i) != "pass" && cu.getPastStatus(i) != "fail") { raida.raidaIsDetecting[i] = false;//Server is not working correctly, don't try it agian } } }//end if it is the first coin we are detecting cu.consoleReport(); bool alreadyExists = false;//Does the file already been imported? switch (cu.getFolder().ToLower()) { case "bank": totalValueToBank++; alreadyExists = this.fileUtils.writeTo(this.fileUtils.bankFolder, detectedCC.cc); break; case "fracked": totalValueToFractured++; alreadyExists = this.fileUtils.writeTo(this.fileUtils.frackedFolder, detectedCC.cc); break; case "counterfeit": totalValueToCounterfeit++; alreadyExists = this.fileUtils.writeTo(this.fileUtils.counterfeitFolder, detectedCC.cc); break; case "suspect": totalValueToKeptInSuspect++; coinSupect = true; //Coin will remain in suspect folder break; }//end switch // end switch on the place the coin will go if (!coinSupect) //Leave coin in the suspect folder if RAIDA is down { File.Delete(this.fileUtils.suspectFolder + suspectFileNames[j]); //Take the coin out of the suspect folder } else { this.fileUtils.writeTo(this.fileUtils.suspectFolder, detectedCC.cc); Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine("Not enough RAIDA were contacted to determine if the coin is authentic."); Console.Out.WriteLine("Try again later."); CoreLogger.Log("Not enough RAIDA were contacted to determine if the coin is authentic. Try again later."); Console.ForegroundColor = ConsoleColor.White; } //end if else } //end if file exists } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); CoreLogger.Log(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); } // end try catch } // end for each coin to import results[0] = totalValueToBank; results[1] = totalValueToCounterfeit; results[2] = totalValueToFractured; results[3] = totalValueToKeptInSuspect; return(results); }//Detect All
}// end Detect constructor /* PUBLIC METHODS */ public int[] gradeAll(int msToFixDangerousFracked, int msToRedetectDangerous) { String[] detectedFileNames = new DirectoryInfo(this.fileUtils.detectedFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder int totalValueToBank = 0; int totalValueToCounterfeit = 0; int totalValueToFractured = 0; int totalValueToKeptInSuspect = 0; int totalValueToLost = 0; CloudCoin newCC; for (int j = 0; j < detectedFileNames.Length; j++)//for every coins in the detected folder { try { if (File.Exists(this.fileUtils.bankFolder + detectedFileNames[j]) || File.Exists(this.fileUtils.frackedFolder + detectedFileNames[j])) {//Coin has already been imported. Delete it from import folder move to trash. //THIS SHOULD NOT HAPPEN - THE COIN SHOULD HAVE BEEN CHECKED DURING IMPORT BEFORE DETECTION TO SEE IF IT WAS IN THE BANK FOLDER Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine("You tried to import a coin that has already been imported."); CoreLogger.Log("You tried to import a coin that has already been imported."); updateLog("You tried to import a coin that has already been imported."); if (File.Exists(this.fileUtils.trashFolder + detectedFileNames[j])) { File.Delete(this.fileUtils.trashFolder + detectedFileNames[j]); } File.Move(this.fileUtils.detectedFolder + detectedFileNames[j], this.fileUtils.trashFolder + detectedFileNames[j]); Console.Out.WriteLine("Suspect CloudCoin was moved to Trash folder."); CoreLogger.Log("Suspect CloudCoin was moved to Trash folder."); updateLog("Suspect CloudCoin was moved to Trash folder."); Console.ForegroundColor = ConsoleColor.White; } else { newCC = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.detectedFolder + detectedFileNames[j]); CoinUtils cu = new CoinUtils(newCC); //CoinUtils detectedCC = cu; //cu.sortToFolder();//Tells the Coin Utils to set what folder the coins should go to. cu.consoleReport(); //Suspect, Counterfeit, Fracked, Bank, Trash, Detected, Lost, Dangerous switch (cu.getFolder().ToLower()) { case "bank": totalValueToBank++; fileUtils.writeTo(this.fileUtils.bankFolder, cu.cc); break; case "fracked": totalValueToFractured++; fileUtils.writeTo(this.fileUtils.frackedFolder, cu.cc); break; case "counterfeit": totalValueToCounterfeit++; fileUtils.writeTo(this.fileUtils.counterfeitFolder, cu.cc); break; case "lost": totalValueToLost++; fileUtils.writeTo(this.fileUtils.lostFolder, cu.cc); break; case "suspect": totalValueToKeptInSuspect++; fileUtils.writeTo(this.fileUtils.suspectFolder, cu.cc); Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(" Not enough RAIDA were contacted to determine if the coin is authentic."); Console.Out.WriteLine(" Try again later."); CoreLogger.Log(" Not enough RAIDA were contacted to determine if the coin is authentic. Try again later."); Console.ForegroundColor = ConsoleColor.White; break; case "dangerous": Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" WARNING: Strings may be attached to this coins"); Console.ForegroundColor = ConsoleColor.White; Console.Out.WriteLine(" Now fixing fracked for " + (j + 1) + " of " + detectedFileNames.Length + " . SN " + string.Format("{0:n0}", newCC.sn) + ", Denomination: " + cu.getDenomination()); CoreLogger.Log(" Now fixing fracked for " + (j + 1) + " of " + detectedFileNames.Length + " . SN " + string.Format("{0:n0}", newCC.sn) + ", Denomination: " + cu.getDenomination()); updateLog("Some of your CloudCoins are still being processed. This should take just a moment."); Frack_Fixer ff = new Frack_Fixer(fileUtils, msToFixDangerousFracked); ff.txtLogs = txtLogs; RAIDA raida = new RAIDA(); Console.WriteLine("folder is " + cu.getFolder().ToLower()); while (cu.getFolder().ToLower() == "dangerous") { // keep fracking fixing until all fixed or no more improvments possible. Console.WriteLine(" calling fix Coin"); cu = ff.fixCoin(cu.cc, msToFixDangerousFracked).Result; Console.WriteLine(" sorting after fixing"); cu.sortFoldersAfterFixingDangerous(); } //while folder still dangerous for (int i = 0; i < 25; i++) { cu.pans[i] = cu.generatePan(); } // end for each pan cu = raida.detectCoin(cu, msToRedetectDangerous); //Detect again to make sure it is powned cu.consoleReport(); cu.sortToFolder(); //Tells the Coin Utils to set what folder the coins should go to. switch (cu.getFolder().ToLower()) { case "bank": totalValueToBank++; fileUtils.writeTo(this.fileUtils.bankFolder, cu.cc); break; case "fracked": totalValueToFractured++; fileUtils.writeTo(this.fileUtils.frackedFolder, cu.cc); break; default: totalValueToCounterfeit++; fileUtils.writeTo(this.fileUtils.counterfeitFolder, cu.cc); break; } //end switch break; }//end switch File.Delete(this.fileUtils.detectedFolder + detectedFileNames[j]);//Take the coin out of the detected folder }//end if file exists } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); CoreLogger.Log(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); } // end try catch } // end for each coin to import results[0] = totalValueToBank; results[1] = totalValueToFractured; results[2] = totalValueToCounterfeit; results[3] = totalValueToKeptInSuspect; results[4] = totalValueToLost; return(results); }//Detect All
}//end detect coin public CoinUtils partialDetectCoin(CoinUtils cu, int milliSecondsToTimeOut) { cu.generatePan(); int[] echoes = (int[])RAIDA_Status.echoTime.Clone(); int[] raidas = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; Array.Sort(echoes, raidas); Console.WriteLine("fastest raida: " + raidas[0] + "," + raidas[1] + "," + raidas[2] + "," + raidas[3] + "," + raidas[4] + "," + raidas[5] + "," + raidas[6] + "," + raidas[7] + "," + raidas[8] + "," + raidas[9] + "," + raidas[10] + "," + raidas[11] + "," + raidas[12] + "," + raidas[13] + "," + raidas[14] + "," + raidas[15]); var t00 = detectOne(raidas[00], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[00]], cu.pans[raidas[00]], cu.getDenomination()); var t01 = detectOne(raidas[01], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[01]], cu.pans[raidas[01]], cu.getDenomination()); var t02 = detectOne(raidas[02], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[02]], cu.pans[raidas[02]], cu.getDenomination()); var t03 = detectOne(raidas[03], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[03]], cu.pans[raidas[03]], cu.getDenomination()); var t04 = detectOne(raidas[04], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[04]], cu.pans[raidas[04]], cu.getDenomination()); var t05 = detectOne(raidas[05], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[05]], cu.pans[raidas[05]], cu.getDenomination()); var t06 = detectOne(raidas[06], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[06]], cu.pans[raidas[06]], cu.getDenomination()); var t07 = detectOne(raidas[07], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[07]], cu.pans[raidas[07]], cu.getDenomination()); var t08 = detectOne(raidas[08], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[08]], cu.pans[raidas[08]], cu.getDenomination()); var t09 = detectOne(raidas[09], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[09]], cu.pans[raidas[09]], cu.getDenomination()); var t10 = detectOne(raidas[10], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[10]], cu.pans[raidas[10]], cu.getDenomination()); var t11 = detectOne(raidas[11], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[11]], cu.pans[raidas[11]], cu.getDenomination()); var t12 = detectOne(raidas[12], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[12]], cu.pans[raidas[12]], cu.getDenomination()); var t13 = detectOne(raidas[13], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[13]], cu.pans[raidas[13]], cu.getDenomination()); var t14 = detectOne(raidas[14], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[14]], cu.pans[raidas[14]], cu.getDenomination()); var t15 = detectOne(raidas[15], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[15]], cu.pans[raidas[15]], cu.getDenomination()); //var t16 = Task.Run(() => detectOne(raidas[16], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[16]], cu.pans[raidas[16]], cu.getDenomination())); var taskList = new List <Task> { t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15 }; Task.WaitAll(taskList.ToArray(), milliSecondsToTimeOut); //Get data from the detection agents //nt k = 0; //for(int j =0; j<16;j++) //{ // if(responseArray[raidas[j]] != null && responseArray[raidas[j]].outcome == "error" && k < 9) // { // detectOne(raidas[16+k], cu.cc.nn, cu.cc.sn, cu.cc.an[raidas[16+k]], cu.pans[raidas[16+k]], cu.getDenomination()); // k++; // } //} for (int i = 0; i < 25; i++) { if (responseArray[i] != null) { cu.setPastStatus(responseArray[i].outcome, i); CoreLogger.Log(cu.cc.sn + " detect:" + i + " " + responseArray[i].fullResponse); } else { cu.setPastStatus("undetected", i); };// should be pass, fail, error or undetected. }//end for each detection agent cu.setAnsToPansIfPassed(true); cu.calculateHP(); // cu.gradeCoin(); // sets the grade and figures out what the file extension should be (bank, fracked, counterfeit, lost cu.calcExpirationDate(); cu.grade(); return(cu); }//end detect coin
}//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
}// end Detect constructor public int detectMulti(int detectTime) { bool stillHaveSuspect = true; int coinNames = 0; while (stillHaveSuspect) { // LOAD ALL SUSPECT COIN NAMES IN AN ARRAY OF NAMES String[] suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder //CHECK TO SEE IF ANY OF THE FILES ARE ALREADY IN BANK. DELETE IF SO for (int i = 0; i < suspectFileNames.Length; i++)//for up to 200 coins in the suspect folder { try { if (File.Exists(this.fileUtils.bankFolder + suspectFileNames[i]) || File.Exists(this.fileUtils.detectedFolder + suspectFileNames[i])) {//Coin has already been imported. Delete it from import folder move to trash. coinExists(suspectFileNames[i]); } } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); CoreLogger.Log(ex.ToString()); //updateLog(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); //updateLog(ioex.ToString()); } // end try catch } // end for each coin to see if in bank //DUPLICATES HAVE BEEN DELETED, NOW DETECT suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder). GetFiles().Select(o => o.Name).ToArray(); //Get all files in suspect folder //HOW MANY COINS WILL WE DETECT? LIMIT IT TO 200 if (suspectFileNames.Length > 200) { coinNames = 200;//do not detect more than 200 coins. } else { coinNames = suspectFileNames.Length; stillHaveSuspect = false;// No need to get more names } //BUILD AN ARRAY OF COINS FROM THE FILE NAMES - UPTO 200 CloudCoin[] cloudCoin = new CloudCoin[coinNames]; CoinUtils[] cu = new CoinUtils[coinNames]; //Receipt receipt = createReceipt(coinNames, receiptFile); //raida.txtLogs = txtLogs; totalImported = 0; for (int i = 0; i < coinNames; i++)//for up to 200 coins in the suspect folder { try { cloudCoin[i] = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.suspectFolder + suspectFileNames[i]); cu[i] = new CoinUtils(cloudCoin[i]); Console.Out.WriteLine(" Now scanning coin " + (i + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination()); //CoreLogger.Log(" Now scanning coin " + (i + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination()); ReceitDetail detail = new ReceitDetail(); detail.sn = cloudCoin[i].sn; detail.nn = cloudCoin[i].nn; detail.status = "suspect"; detail.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; detail.note = "Waiting"; // receipt.rd[i] = detail; //updateLog(" Now scanning coin " + (i + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination()); Device.BeginInvokeOnMainThread(() => { importBar.Progress = (i * 100 / coinNames); }); updateLog("Authenticating a " + cu[i].getDenomination() + " CoinCoin note (" + cloudCoin[i].sn + "): " + (i + 1) + " of " + coinNames); } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); //CoreLogger.Log(ex.ToString()); updateLog(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); //CoreLogger.Log(ioex.ToString()); updateLog(ioex.ToString()); } // end try catch } // end for each coin to import //ALL COINS IN THE ARRAY, NOW DETECT CoinUtils[] detectedCC = raida.detectMultiCoin(cu, detectTime); var bankCoins = detectedCC.Where(o => o.folder == CoinUtils.Folder.Bank); var frackedCoins = detectedCC.Where(o => o.folder == CoinUtils.Folder.Fracked); var counterfeitCoins = detectedCC.Where(o => o.folder == CoinUtils.Folder.Counterfeit); totalImported = 0; foreach (CoinUtils ccc in bankCoins) { fileUtils.writeTo(fileUtils.bankFolder, ccc.cc); totalImported++; } foreach (CoinUtils ccf in frackedCoins) { fileUtils.writeTo(fileUtils.frackedFolder, ccf.cc); totalImported++; } //Write the coins to the detected folder delete from the suspect for (int c = 0; c < detectedCC.Length; c++) { //detectedCC[c].txtLogs = txtLogs; fileUtils.writeTo(fileUtils.detectedFolder, detectedCC[c].cc); File.Delete(fileUtils.suspectFolder + suspectFileNames[c]);//Delete the coin out of the suspect folder } //Console.WriteLine("Total Imported Coins - " + totalImported); //Console.WriteLine("Total Counterfeit detected - " + counterfeitCoins.ToArray().Length); updateLog("Total Imported Coins - " + totalImported); updateLog("Total Counterfeit detected - " + counterfeitCoins.ToArray().Length); } //end while still have suspect return(coinNames); } //End detectMulti All
}//end delete coin public CoinUtils fixCoin(CloudCoin brokeCoin, int millisecondsToTimeout) { CoinUtils cu = new CoinUtils(brokeCoin); /*0. RESET TICKETS IN RAIDA STATUS TO EMPTY*/ RAIDA_Status.resetTickets(); /*0. RESET THE DETECTION to TRUE if it is a new COIN */ RAIDA_Status.newCoin(); cu.setAnsToPans();// Make sure we set the RAIDA to the cc ans and not new pans. DateTime before = DateTime.Now; String fix_result = ""; FixitHelper fixer; /*START*/ /*1. PICK THE CORNER TO USE TO TRY TO FIX */ int corner = 1; // For every guid, check to see if it is fractured for (int raida_ID = 0; raida_ID < 25; raida_ID++) { //Check to see if the coin has been marked counterfeit and should be moved to trash // Console.Out.WriteLine("The folder is " + cu.getFolder().ToLower()); if (cu.cc.pown == "fffffffffffffffffffffffff") { cu.setFolder("counterfeit"); return(cu); } // Console.WriteLine("Past Status for " + raida_ID + ", " + brokeCoin.pastStatus[raida_ID]); if (cu.getPastStatus(raida_ID).ToLower() != "pass") //will try to fix everything that is not perfect pass. { cu.cc.an[raida_ID] = cu.generatePan(); //Assign the AN a new PAN for security. Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(" Attempting to fix RAIDA " + raida_ID + " "); CoreLogger.Log(" Attempting to fix RAIDA " + raida_ID); Console.ForegroundColor = ConsoleColor.White; fixer = new FixitHelper(raida_ID, brokeCoin.an.ToArray()); //trustedServerAns = new String[] { brokeCoin.ans[fixer.currentTriad[0]], brokeCoin.ans[fixer.currentTriad[1]], brokeCoin.ans[fixer.currentTriad[2]] }; corner = 1; while (!fixer.finnished) { Console.Write(" Using corner " + corner + " "); CoreLogger.Log(" Using corner " + corner + " "); fix_result = fixOneGuidCorner(raida_ID, brokeCoin, corner, fixer.currentTriad, millisecondsToTimeout); // Console.WriteLine(" fix_result: " + fix_result + " for corner " + corner); if (fix_result.Contains("success")) { //Fixed. Do the fixed stuff cu.setPastStatus("pass", raida_ID); fixer.finnished = true; corner = 1; } else if (fix_result.Contains("counterfeit")) { for (int j = 0; j < 25; j++) { cu.setPastStatus("fail", j); } //Set all status to fail so the coin will be moved to counterfeit. cu.setFolder("counterfeit"); fixer.finnished = true; return(cu); } else { //Still broken, do the broken stuff. corner++; fixer.setCornerToCheck(corner); } } //End whild fixer not finnished } //end if RAIDA past status is passed and does not need to be fixed } //end for each AN for (int raida_ID = 24; raida_ID > -1; raida_ID--) { // Console.WriteLine("Past Status for " + raida_ID + ", " + brokeCoin.pastStatus[raida_ID]); // Console.WriteLine("Pown is " + cu.cc.pown); if (cu.getPastStatus(raida_ID).ToLower() != "pass") //will try to fix everything that is not perfect pass. { cu.cc.an[raida_ID] = cu.generatePan(); //Assign the AN a new PAN for security. Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(" Attempting to fix RAIDA " + raida_ID + " "); CoreLogger.Log(" Attempting to fix RAIDA " + raida_ID); Console.ForegroundColor = ConsoleColor.White; fixer = new FixitHelper(raida_ID, brokeCoin.an.ToArray()); //trustedServerAns = new String[] { brokeCoin.ans[fixer.currentTriad[0]], brokeCoin.ans[fixer.currentTriad[1]], brokeCoin.ans[fixer.currentTriad[2]] }; corner = 1; while (!fixer.finnished) { Console.Write(" Using corner " + corner + " "); CoreLogger.Log(" Using corner " + corner + " "); fix_result = fixOneGuidCorner(raida_ID, brokeCoin, corner, fixer.currentTriad, millisecondsToTimeout); // Console.WriteLine(" fix_result: " + fix_result + " for corner " + corner); if (fix_result.Contains("success")) { //Fixed. Do the fixed stuff cu.setPastStatus("pass", raida_ID); fixer.finnished = true; corner = 1; } else if (fix_result.Contains("counterfeit")) { for (int j = 0; j < 25; j++) { cu.setPastStatus("fail", j); } //Set all status to fail so the coin will be moved to counterfeit. cu.setFolder("counterfeit"); fixer.finnished = true; return(cu); } else { //Still broken, do the broken stuff. corner++; fixer.setCornerToCheck(corner); } } //End whild fixer not finnished } //end if RAIDA past status is passed and does not need to be fixed } //end for each AN DateTime after = DateTime.Now; TimeSpan ts = after.Subtract(before); Console.WriteLine(" Time spent fixing RAIDA in milliseconds: " + ts.Milliseconds); CoreLogger.Log(" Time spent fixing RAIDA in milliseconds: " + ts.Milliseconds); cu.calculateHP(); //how many fails did it get // cu.gradeCoin();// sets the grade and figures out what the file extension should be (bank, fracked, counterfeit, lost cu.grade(); cu.calcExpirationDate(); return(cu); } // end fix coin
} //end fix one /* PUBLIC METHODS */ public int[] fixAll(int millisecondsToFixOne) { int[] results = new int[3]; String[] frackedFileNames = new DirectoryInfo(this.fileUtils.frackedFolder).GetFiles().Select(o => o.Name).ToArray(); CloudCoin frackedCC; //CoinUtils cu = new CoinUtils(frackedCC); if (frackedFileNames.Length < 0) { Console.ForegroundColor = ConsoleColor.Green; Console.Out.WriteLine("You have no fracked coins."); CoreLogger.Log("You have no fracked coins."); Console.ForegroundColor = ConsoleColor.White; }//no coins to unfrack for (int i = 0; i < frackedFileNames.Length; i++) { Console.WriteLine("UnFracking coin " + (i + 1) + " of " + frackedFileNames.Length); CoreLogger.Log("UnFracking coin " + (i + 1) + " of " + frackedFileNames.Length); try { frackedCC = fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.frackedFolder + frackedFileNames[i]); CoinUtils cu = new CoinUtils(frackedCC); String value = frackedCC.pown; // Console.WriteLine("Fracked Coin: "); cu.consoleReport(); CoinUtils fixedCC = fixCoin(frackedCC, millisecondsToFixOne); // Will attempt to unfrack the coin. cu.consoleReport(); switch (fixedCC.getFolder().ToLower()) { case "bank": this.totalValueToBank++; this.fileUtils.overWrite(this.fileUtils.bankFolder, fixedCC.cc); this.deleteCoin(this.fileUtils.frackedFolder + frackedFileNames[i]); Console.WriteLine("CloudCoin was moved to Bank."); CoreLogger.Log("CloudCoin was moved to Bank."); break; case "counterfeit": this.totalValueToCounterfeit++; this.fileUtils.overWrite(this.fileUtils.counterfeitFolder, fixedCC.cc); this.deleteCoin(this.fileUtils.frackedFolder + frackedFileNames[i]); Console.WriteLine("CloudCoin was moved to Trash."); CoreLogger.Log("CloudCoin was moved to Trash."); break; default: //Move back to fracked folder this.totalValueToFractured++; this.deleteCoin(this.fileUtils.frackedFolder + frackedFileNames[i]); this.fileUtils.overWrite(this.fileUtils.frackedFolder, fixedCC.cc); Console.WriteLine("CloudCoin was moved back to Fraked folder."); CoreLogger.Log("CloudCoin was moved back to Fraked folder."); break; } // end switch on the place the coin will go Console.WriteLine("..................................."); Console.WriteLine(""); } catch (FileNotFoundException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex); CoreLogger.Log(ex.ToString()); Console.ForegroundColor = ConsoleColor.White; } catch (IOException ioex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); Console.ForegroundColor = ConsoleColor.White; } // end try catch } // end for each file name that is fracked results[0] = this.totalValueToBank; results[1] = this.totalValueToCounterfeit; // System.out.println("Counterfeit and Moved to trash: "+totalValueToCounterfeit); results[2] = this.totalValueToFractured; // System.out.println("Fracked and Moved to Fracked: "+ totalValueToFractured); return(results); }// end fix all
}//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
} //end dump all /* Write JSON to .stack File */ public bool dumpSome(int m1, int m5, int m25, int m100, int m250) { bool jsonExported = true; int totalSaved = m1 + (m5 * 5) + (m25 * 25) + (m100 * 100) + (m250 * 250); // Track the total coins int coinCount = m1 + m5 + m25 + m100 + m250; String[] coinsToDelete = new String[coinCount]; String[] bankedFileNames = new DirectoryInfo(this.fileUtils.bankFolder).GetFiles().Select(o => o.Name).ToArray();//Get all names in bank folder String[] frackedFileNames = new DirectoryInfo(this.fileUtils.frackedFolder).GetFiles().Select(o => o.Name).ToArray();; String[] partialFileNames = new DirectoryInfo(this.fileUtils.partialFolder).GetFiles().Select(o => o.Name).ToArray(); // Add the two arrays together var list = new List <String>(); list.AddRange(bankedFileNames); list.AddRange(frackedFileNames); list.AddRange(partialFileNames); // Program will spend fracked files like perfect files bankedFileNames = list.ToArray(); // Check to see the denomination by looking at the file start int c = 0; // c= counter String json = ""; String start = "{" + Environment.NewLine; start = start + "\t\"cloudcoin\": [" + Environment.NewLine; String end = "\t]" + Environment.NewLine + "}"; String bankFileName; String frackedFileName; String partialFileName; string denomination; // Put all the JSON together and add header and footer String filename = ""; for (int i = 0; (i < bankedFileNames.Length); i++) { denomination = bankedFileNames[i].Split('.')[0]; bankFileName = this.fileUtils.bankFolder + bankedFileNames[i]; //File name in bank folder frackedFileName = this.fileUtils.frackedFolder + bankedFileNames[i]; //File name in fracked folder partialFileName = this.fileUtils.partialFolder + bankedFileNames[i]; if (denomination == "1" && m1 > 0) { if (c != 0)//This is the json seperator between each coin. It is not needed on the first coin { json += ",\n"; } if (File.Exists(bankFileName)) // Is it a bank file { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(bankFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else if (File.Exists(partialFileName)) // Is it a partial file { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(partialFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(frackedFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null; coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = frackedFileName; c++; } m1--; // Get the clean JSON of the coin }// end if coin is a 1 if (denomination == "5" && m5 > 0) { if ((c != 0)) { json += ",\n"; } if (File.Exists(bankFileName)) { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(bankFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else if (File.Exists(partialFileName)) // Is it a partial file { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(partialFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(frackedFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null; coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = frackedFileName; c++; } m5--; } // end if coin is a 5 if (denomination == "25" && m25 > 0) { if ((c != 0)) { json += ",\n"; } if (File.Exists(bankFileName)) { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(bankFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else if (File.Exists(partialFileName)) // Is it a partial file { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(partialFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(frackedFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null; coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = frackedFileName; c++; } m25--; }// end if coin is a 25 if (denomination == "100" && m100 > 0) { if ((c != 0)) { json += ",\n"; } if (File.Exists(bankFileName)) { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(bankFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else if (File.Exists(partialFileName)) // Is it a partial file { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(partialFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(frackedFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null; coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = frackedFileName; c++; } m100--; } // end if coin is a 100 if (denomination == "250" && m250 > 0) { if ((c != 0)) { json += ",\n"; } if (File.Exists(bankFileName)) { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(bankFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else if (File.Exists(partialFileName)) // Is it a partial file { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(partialFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null;//Clear all owner data coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = bankFileName; c++; } else { CloudCoin coinNote = this.fileUtils.loadOneCloudCoinFromJsonFile(frackedFileName); CoinUtils cu = new CoinUtils(coinNote); coinNote.aoid = null; coinNote.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; json = start + this.fileUtils.setJSON(coinNote) + end; filename = this.fileUtils.exportFolder + Path.DirectorySeparatorChar + cu.getDenomination() + ".CloudCoins." + random.Next(100000, 10000000) + ".stack"; File.WriteAllText(filename, json); Console.Out.WriteLine("Writing to " + filename); CoreLogger.Log("Writing to " + filename); coinsToDelete[c] = frackedFileName; c++; } m250--; }// end if coin is a 250 if (m1 == 0 && m5 == 0 && m25 == 0 && m100 == 0 && m250 == 0) { break; } // Break if all the coins have been called for. } // end for each coin needed /*DELETE FILES THAT HAVE BEEN EXPORTED*/ for (int cc = 0; cc < coinsToDelete.Length; cc++) { // Console.Out.WriteLine("Deleting " + coinsToDelete[cc]); if (coinsToDelete[cc] != null) { File.Delete(coinsToDelete[cc]); } }//end for all coins to delete // end if write was good return(jsonExported); } //end write json to file
}// end Detect constructor public int detectMulti(int detectTime) { bool stillHaveSuspect = true; int coinNames = 0; int total = 0; int loops = 0; //totalImported = 0; while (stillHaveSuspect) { // LOAD ALL SUSPECT COIN NAMES IN AN ARRAY OF NAMES String[] suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder if (suspectFileNames.Length > total) { total = suspectFileNames.Length; } //CHECK TO SEE IF ANY OF THE FILES ARE ALREADY IN BANK. DELETE IF SO for (int i = 0; i < suspectFileNames.Length; i++)//for up to 200 coins in the suspect folder { try { if (File.Exists(this.fileUtils.bankFolder + suspectFileNames[i]) || File.Exists(this.fileUtils.frackedFolder + suspectFileNames[i]) || File.Exists(this.fileUtils.detectedFolder + suspectFileNames[i])) {//Coin has already been imported. Delete it from import folder move to trash. coinExists(suspectFileNames[i]); } } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); CoreLogger.Log(ex.ToString()); //updateLog(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); //updateLog(ioex.ToString()); } // end try catch } // end for each coin to see if in bank //DUPLICATES HAVE BEEN DELETED, NOW DETECT //suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder var ext = new List <string> { ".jpg", ".stack", ".jpeg" }; var fnamesRaw = Directory.GetFiles(this.fileUtils.suspectFolder, "*.*", SearchOption.TopDirectoryOnly).Where(s => ext.Contains(Path.GetExtension(s))); suspectFileNames = new string[fnamesRaw.Count()]; for (int i = 0; i < fnamesRaw.Count(); i++) { suspectFileNames[i] = Path.GetFileName(fnamesRaw.ElementAt(i)); } ; //HOW MANY COINS WILL WE DETECT? LIMIT IT TO 200 if (suspectFileNames.Length > 200) { coinNames = 200;//do not detect more than 200 coins. } else { coinNames = suspectFileNames.Length; stillHaveSuspect = false;// No need to get more names } //BUILD AN ARRAY OF COINS FROM THE FILE NAMES - UPTO 200 CloudCoin[] cloudCoin = new CloudCoin[coinNames]; CoinUtils[] cu = new CoinUtils[coinNames]; //Receipt receipt = createReceipt(coinNames, receiptFile); raida.txtLogs = txtLogs; //totalImported = 0; for (int i = 0; i < coinNames; i++)//for up to 200 coins in the suspect folder { try { cloudCoin[i] = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.suspectFolder + suspectFileNames[i]); cu[i] = new CoinUtils(cloudCoin[i]); Console.Out.WriteLine(" Now scanning coin " + (i + 1 + loops * 200) + " of " + total + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination()); CoreLogger.Log(" Now scanning coin " + (i + 1 + loops * 200) + " of " + total + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination()); ReceitDetail detail = new ReceitDetail(); detail.sn = cloudCoin[i].sn; detail.nn = cloudCoin[i].nn; detail.status = "suspect"; detail.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu"; detail.note = "Waiting"; // receipt.rd[i] = detail; //updateLog(" Now scanning coin " + (i + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination()); updateLog("Authenticating a " + cu[i].getDenomination() + " CloudCoin note (" + cloudCoin[i].sn + "): " + (i + 1 + loops * 200) + " of " + total); } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); CoreLogger.Log(ex.ToString()); updateLog(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); updateLog(ioex.ToString()); } // end try catch } // end for each coin to import //ALL COINS IN THE ARRAY, NOW DETECT CoinUtils[] detectedCC = raida.detectMultiCoin(cu, detectTime); var bankCoins = detectedCC.Where(o => o.folder == CoinUtils.Folder.Bank); var frackedCoins = detectedCC.Where(o => o.folder == CoinUtils.Folder.Fracked); var counterfeitCoins = detectedCC.Where(o => o.folder == CoinUtils.Folder.Counterfeit); //totalImported = 0; foreach (CoinUtils ccc in bankCoins) { //fileUtils.writeTo(fileUtils.bankFolder, ccc.cc); totalImported++; } foreach (CoinUtils ccf in frackedCoins) { //fileUtils.writeTo(fileUtils.frackedFolder, ccf.cc); totalImported++; } foreach (CoinUtils cccf in counterfeitCoins) { totalCounterfeit++; } //Write the coins to the detected folder delete from the suspect for (int c = 0; c < detectedCC.Length; c++) { detectedCC[c].txtLogs = txtLogs; fileUtils.writeTo(fileUtils.detectedFolder, detectedCC[c].cc); File.Delete(fileUtils.suspectFolder + suspectFileNames[c]); //Delete the coin out of the suspect folder } updateLog("Total Imported Coins : " + totalImported); updateLog("Total Counterfeits : " + totalCounterfeit); updateLog("Coins still being processed : " + detectedCC.Where(o => o.folder == CoinUtils.Folder.Dangerous).ToArray().Length); loops++; } //end while still have suspect return(coinNames); } //End detectMulti All