public ChiaPlotsManager( ChiaPlotManagerContextConfiguration chiaPlotManagerContextConfiguration, ChiaPlotProcessRepository processRepo, Func <string, string, string, string, string, ChiaPlotProcessRepository, IChiaPlotProcessChannel> chiaPlotProcessChannelFactory, Action <ICollection <ChiaPlotOutput>, StringBuilder> allOutputsDelegate, Func <string, Task> tempDriveCleanerDelegate ) { this.chiaPlotManagerContextConfiguration = chiaPlotManagerContextConfiguration; this.processRepo = processRepo; this.chiaPlotProcessChannelFactory = chiaPlotProcessChannelFactory; this.allOutputsDelegate = allOutputsDelegate; this.tempDriveCleanerDelegate = tempDriveCleanerDelegate; }
static async Task Main(string[] args) { var testing = false; var repo = new ChiaPlotProcessRepository(); try { var config = new ChiaPlotManagerContextConfiguration(); config.PlotsPerDrive = 2; config.TempPlotDrives = new List <string>() { "/chia/plottemp1", "/chia/plottemp2", "/chia/plottemp3", "/chia/plottemp4" }; config.DestinationPlotDrives = new List <string>() { // "/chia/plots/100", // "/chia/plots/101", // "/chia/plots/102", // "/chia/plots/103", // "/chia/plots/104", // "/chia/plots/105", // "/chia/plots/106", // "/chia/plots/107", // "/chia/plots/108", // "/chia/plots/109" "/chia/plots/200", "/chia/plots/201", // "/chia/plots/202", // "/chia/plots/203", // "/chia/plots/204", "/chia/plots/205", "/chia/plots/206", }; config.KSizes = new List <KSizeMetadata> { new KSizeMetadata { PlotSize = 408000000000, WorkSize = 1000000000, K = "34", Threads = 4, Ram = 8000 }, new KSizeMetadata { PlotSize = 208000000000, WorkSize = 550000000, K = "33", Threads = 4, Ram = 6000 }, new KSizeMetadata { PlotSize = 108000000000, WorkSize = 280000000, K = "32", Threads = 2, Ram = 4000 } }; var manager = new ChiaPlotsManager( config, repo, ( temp, destination, K, Ram, Threads, processRepo ) => { if (!testing) { return(new ChiaPlotProcessChannel(temp, destination, K, Ram, Threads, processRepo)); } else { return(new ChiaPlotProcessChannelMock(temp, destination, K, Ram, Threads, processRepo)); } }, (outputs, staticTextStringBuilder) => { var lmr = new List <ChiaPlotOutput>(); Console.Clear(); Console.WriteLine(DateTime.Now.ToString("T").PadRight(50 * 3, '-')); foreach (var uniqueOutput in outputs.Where(o => o.IsTransferComplete == false)) { lmr.Add(uniqueOutput); if (lmr.Count == 3) { displayOutputs(lmr[0], lmr[1], lmr[2]); lmr.Clear(); } } if (lmr.Count > 0) { while (lmr.Count != 3) { lmr.Add(new ChiaPlotOutput { Id = "..." }); } displayOutputs(lmr[0], lmr[1], lmr[2]); } Console.WriteLine(string.Empty.PadRight(50 * 3, '-'), Color.BlueViolet); var avg = outputs.Where(o => o.IsTransferComplete && o.Duration != default).Select(o => o.Duration); var averageTime = TimeSpan.FromSeconds(avg.Any() ? avg.Average(timespan => timespan.TotalSeconds) : 0); var skippedTempDrive = outputs.Where(o => o.InvalidDrive == o.TempDrive && o.TempDrive != o.DestinationDrive); Console.WriteLine($"Completed: {outputs.Where(o => o.IsTransferComplete).Count()} plots with an average time of {averageTime.Hours}:{averageTime.Minutes}:{averageTime.Seconds}"); Console.WriteLine($"Skipped {skippedTempDrive.Count()} temp drive{(skippedTempDrive.Count() != 1 ? "s" : string.Empty)}."); Console.WriteLine(staticTextStringBuilder.ToString()); }, tempDrive => { try { if (!testing) { if (Directory.Exists(Path.Combine(tempDrive, ".Trash-1000"))) { Directory.Delete(Path.Combine(tempDrive, ".Trash-1000"), true); } } } catch (Exception ex) { // do we care? Console.WriteLine($"Exception"); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } return(Task.CompletedTask); } ); await manager.Process(); }