Exemplo n.º 1
0
        //query drives and get drive info
        private void btn_QueryDrives_Click(object sender, EventArgs e)
        {
            drivesView.Items.Clear();
            ArrayList result;

            result = llda.GetDriveList();
            int i = 0;

            foreach (string x in result)
            {
                ListViewItem item = new ListViewItem();
                item.Text = i.ToString();
                item.Name = i.ToString();
                item.SubItems.Add(x);
                Int64 sectors = llda.GetSectors(x) / 512;
                item.SubItems.Add(sectors.ToString());
                UInt32 sectorsL = llda.BytesPerSector(i);
                item.SubItems.Add(sectorsL.ToString());
                UInt32 sectorsP = llda.GetPhysicalSectors(x);
                item.SubItems.Add(sectorsP > 0 ?  sectorsP.ToString():sectorsL.ToString());
                item.SubItems.Add(llda.GetCaption(i));
                item.SubItems.Add(((decimal)sectors * llda.BytesPerSector(i) / 1024 / 1024 / 1024).ToString("0.00") + " GiB");
                item.SubItems.Add((((long)(sectors - 12 * 8) * llda.BytesPerSector(i) / 4096 / 64 / 64) * 64).ToString());
                //
                if (BFS.IsBFS(x))
                {
                    item.SubItems.Add("Yes");
                }
                else
                {
                    item.SubItems.Add("No");
                }
                drivesView.Items.Add(item);
                i += 1;
            }
            ClearBFSView();
        }
Exemplo n.º 2
0
        //Read BFS Filesystem and fill controls
        private void FillBFSView(string drive)
        {
            //enable buttons
            btn_createEmptyPlotFile.Enabled = true;
            btn_deleteFile.Enabled          = true;
            btn_upload.Enabled   = true;
            btn_download.Enabled = true;

            if (drivesView.SelectedItems.Count > 0)
            {
                BFS.LoadBFSTOC(drive);
                //Get BFS Infos
                tb_version.Text  = Encoding.ASCII.GetString(BFS.bfsTOC.version);
                tb_id.Text       = BFS.bfsTOC.id.ToString();
                capacity.Maximum = (int)(BFS.bfsTOC.diskspace / 64);

                //Clear Files
                bfsView.Items.Clear();
                int  i           = 0;
                uint totalNonces = 0;
                foreach (BFSPlotFile x in BFS.bfsTOC.plotFiles)
                {
                    ListViewItem item = new ListViewItem();
                    item.Text = i.ToString();
                    item.Name = i.ToString();
                    if (x.status == 0)
                    {
                        item.SubItems.Add("Empty Slot");
                    }
                    else
                    {
                        totalNonces += x.nonces;
                        item.SubItems.Add(x.startNonce.ToString());
                        item.SubItems.Add(x.nonces.ToString());
                        item.SubItems.Add(x.startPos.ToString());
                        switch (x.status)
                        {
                        case 1:
                            item.SubItems.Add("OK.");
                            break;

                        case 2:
                            item.SubItems.Add("In Creation. ScoopPairs transferred: " + x.pos.ToString());
                            break;

                        case 3:
                            item.SubItems.Add("In Creation. Nonces plotted: " + x.pos.ToString());
                            break;

                        case 4:
                            item.SubItems.Add("Converting. Scoop Pair Progress: " + x.pos.ToString());
                            break;
                        }
                    }
                    bfsView.Items.Add(item);
                    i += 1;
                }
                capacity.Value = (int)(totalNonces);
                lbl_capa.Text  = ((decimal)((int)(BFS.bfsTOC.diskspace / 64) - (int)(totalNonces)) / 4 / 1024).ToString("0.00") + " GiB free of" + ((decimal)BFS.bfsTOC.diskspace * 4096 / 1024 / 1024 / 1024).ToString("0.00") + " GiB";
                //tb_capa2.Text = ((decimal)BFS.bfsTOC.diskspace / 64).ToString("0");
            }
        }
Exemplo n.º 3
0
        //upload a file to a BFS formatted drive
        private void btn_upload_Click(object sender, EventArgs e)
        {
            String drive           = drivesView.SelectedItems[0].SubItems[1].Text;
            Int32  PbytesPerSector = (Int32.Parse(drivesView.SelectedItems[0].SubItems[4].Text));

            halt1 = false;
            halt2 = false;
            Boolean  shuffle = false;
            PlotFile temp;
            //Let user select plotfile
            string filter = "PoC2 plot files | " + tb_id.Text + "_*_*.*| PoC1 plot files|" + tb_id.Text + "_*_*_*.*";

            openFileDialog.Filter = filter;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //Parse Flotfilename
                temp = ParsePlotFileName(openFileDialog.FileName);
            }
            else
            {
                return;
            }

            //only support optimized files
            if (temp.stagger > 0 && temp.stagger != temp.nonces)
            {
                return;
            }

            //always convert PoC1 files
            if (temp.stagger == temp.nonces)
            {
                shuffle = true;
            }

            //check ID
            if (temp.id.ToString() != tb_id.Text)
            {
                return;
            }

            //calc startoffset and endoffset for 64 nonces alignment
            UInt64 startNonceR   = temp.startNonce / 64 * 64;
            UInt64 startOffset64 = startNonceR < temp.startNonce ? startNonceR + 64 - temp.startNonce : 0;
            UInt32 endOffset64   = temp.nonces - (UInt32)startOffset64 - (temp.nonces - (UInt32)startOffset64) / 64 * 64;

            //check last file and offer to insert dummy file
            //Todo



            //Create file in bfsTOC
            int file = BFS.AddPlotFile(drive, temp.startNonce + startOffset64, temp.nonces - (UInt32)startOffset64 - endOffset64, 2, 0);

            if (file > -1)
            {
                FillBFSView(drive);
            }
            else
            {
                return;
            }

            //Get offsets
            startOffset = BFS.bfsTOC.plotFiles[file].startPos;
            scoopOffset = BFS.bfsTOC.diskspace / 4096;

            //transfer file
            //open source handle
            ScoopReadWriter reader;

            reader = new ScoopReadWriter(openFileDialog.FileName);
            reader.OpenR(true);

            ScoopReadWriter writer;

            writer = new ScoopReadWriter(drive);
            writer.OpenW();

            //Allocate memory
            int   limit  = 4096 * 4096 / 1024;                             //Write cache, 1MB
            Scoop scoop1 = new Scoop(Math.Min((Int32)temp.nonces, limit)); //space needed for one partial scoop
            Scoop scoop2 = new Scoop(Math.Min((Int32)temp.nonces, limit)); //space needed for one partial scoop
            Scoop scoop3 = new Scoop(Math.Min((Int32)temp.nonces, limit)); //space needed for one partial scoop
            Scoop scoop4 = new Scoop(Math.Min((Int32)temp.nonces, limit)); //space needed for one partial scoop


            //create masterplan
            int loops = (int)Math.Ceiling((double)(temp.nonces) / limit);

            TaskInfo[] masterplan = new TaskInfo[2048 * loops];

            for (int y = 0; y < 2048; y++)
            {
                int zz = 0;
                //loop partial scoop
                for (int z = (int)startOffset64; (ulong)z < temp.nonces - endOffset64; z += limit)
                {
                    masterplan[y * loops + zz]               = new TaskInfo();
                    masterplan[y * loops + zz].reader        = reader;
                    masterplan[y * loops + zz].writer        = writer;
                    masterplan[y * loops + zz].drive         = drive;
                    masterplan[y * loops + zz].file          = file;
                    masterplan[y * loops + zz].y             = y;
                    masterplan[y * loops + zz].z             = z;
                    masterplan[y * loops + zz].x             = y * loops + zz;
                    masterplan[y * loops + zz].limit         = limit;
                    masterplan[y * loops + zz].src           = temp;
                    masterplan[y * loops + zz].tar           = BFS.bfsTOC.plotFiles[file];
                    masterplan[y * loops + zz].scoop1        = scoop1;
                    masterplan[y * loops + zz].scoop2        = scoop2;
                    masterplan[y * loops + zz].scoop3        = scoop3;
                    masterplan[y * loops + zz].scoop4        = scoop4;
                    masterplan[y * loops + zz].shuffle       = shuffle;
                    masterplan[y * loops + zz].end           = masterplan.LongLength;
                    masterplan[y * loops + zz].startOffset64 = (int)startOffset64;
                    masterplan[y * loops + zz].endOffset64   = (int)endOffset64;

                    zz += 1;
                }
            }

            //enable stats
            tbl_x.Visible        = true;
            tbl_status.Visible   = true;
            tbl_progress.Visible = true;
            tbl_progress.Maximum = 2048;
            var task1 = Task.Factory.StartNew(() => Th_copy(masterplan));
        }
Exemplo n.º 4
0
        public void Th_copy(TaskInfo[] masterplan)
        {
            //execute taskplan in separate thread

            //initialise stats
            DateTime start = DateTime.Now;
            TimeSpan elapsed;
            TimeSpan togo;

            //perform first read
            Th_read(masterplan[0]);

            autoEvents = new AutoResetEvent[]
            {
                new AutoResetEvent(false),
                new AutoResetEvent(false)
            };

            //perform reads and writes parallel
            long x;

            for (x = 1; x < masterplan.LongLength; x++)
            {
                // ThreadPool.QueueUserWorkItem(new WaitCallback(Th_write), masterplan[x - 1]);
                //ThreadPool.QueueUserWorkItem(new WaitCallback(Th_read), masterplan[x]);
                //WaitHandle.WaitAll(autoEvents);

                var task1 = Task.Factory.StartNew(() => Th_write(masterplan[x - 1]));
                var task2 = Task.Factory.StartNew(() => Th_read(masterplan[x]));
                Task.WaitAll(task1, task2);

                if (halt1 || halt2)
                {
                    break;
                }

                //update status
                elapsed = DateTime.Now.Subtract(start);
                togo    = TimeSpan.FromTicks(elapsed.Ticks / (masterplan[x].y + 1) * (2048 - masterplan[x].y - 1));
                string completed = Math.Round((double)(masterplan[x].y + 1) / 2048 * 100).ToString() + "%";
                string speed1    = Math.Round((double)masterplan[x].src.nonces / 4096 * 2 * (masterplan[x].y + 1) * 60 / (elapsed.TotalSeconds + 1)).ToString() + " nonces/m ";
                string speed2    = "(" + (Math.Round((double)masterplan[x].src.nonces / (2 << 12) * (masterplan[x].y + 1) / (elapsed.TotalSeconds + 1))).ToString() + "MB/s)";
                string speed     = speed1 + speed2; lock (statusStrip)
                    setStatus(masterplan[x].y + 1, "Completed: " + completed + ", Elapsed: " + TimeSpanToString(elapsed) + ", Remaining: " + TimeSpanToString(togo) + ", Speed: " + speed);
            }
            //perform last write
            if (!halt1 && !halt2)
            {
                Th_write(masterplan[masterplan.LongLength - 1]);
            }
            // close reader/writer
            masterplan[0].reader.Close();
            masterplan[0].writer.Close();


            if (halt1 || halt2)
            {
                setStatus(masterplan[x].y + 1, "Abort.");
            }


            //mark as finished
            if (!halt1 && !halt2)
            {
                BFS.SetStatus(masterplan[masterplan.LongLength - 1].drive, masterplan[masterplan.LongLength - 1].file, 1);
            }
            if (halt1 || halt2)
            {
                BFS.SetPos(masterplan[masterplan.LongLength - 1].drive, masterplan[masterplan.LongLength - 1].file, (uint)x);
            }
            if (!halt1 && !halt2)
            {
                setStatus(masterplan[masterplan.LongLength - 1].y + 1, "Completed.");
            }
        }
Exemplo n.º 5
0
        public static DialogResult ShowInputDialog2(string drive, string message, ref UInt64 input1, ref UInt32 input2)
        {
            //get boundaries
            BFS.LoadBFSTOC(drive);
            UInt32 totalNonces = (UInt32)(BFS.bfsTOC.diskspace / 64);

            //Clear Files
            UInt32 noncesUsed = 0;

            foreach (BFSPlotFile x in BFS.bfsTOC.plotFiles)
            {
                if (x.status != 0)
                {
                    noncesUsed += x.nonces;
                }
            }


            System.Drawing.Size size = new System.Drawing.Size(300, 200);
            Form inputBox            = new Form();

            inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            inputBox.ClientSize      = size;
            inputBox.ControlBox      = false;
            inputBox.StartPosition   = FormStartPosition.CenterScreen;
            inputBox.Text            = message;

            System.Windows.Forms.Label lbl_sn = new Label();
            lbl_sn.Size     = new System.Drawing.Size(70, 23);
            lbl_sn.Location = new System.Drawing.Point(10, 8);
            lbl_sn.Text     = "Start Nonce: ";
            inputBox.Controls.Add(lbl_sn);

            System.Windows.Forms.TextBox textBox = new TextBox();
            textBox.Size      = new System.Drawing.Size(size.Width - 90, 23);
            textBox.Location  = new System.Drawing.Point(80, 5);
            textBox.Text      = "";
            textBox.TextAlign = HorizontalAlignment.Right;
            textBox.MaxLength = 20;
            inputBox.Controls.Add(textBox);

            System.Windows.Forms.Label lbl_sn2 = new Label();
            lbl_sn2.Size     = new System.Drawing.Size(70, 23);
            lbl_sn2.Location = new System.Drawing.Point(10, 37);
            lbl_sn2.Text     = "Nonces: ";
            inputBox.Controls.Add(lbl_sn2);

            System.Windows.Forms.NumericUpDown nonces = new NumericUpDown();
            nonces.Size      = new System.Drawing.Size(size.Width - 90, 23);
            nonces.Location  = new System.Drawing.Point(80, 34);
            nonces.Maximum   = totalNonces - noncesUsed;
            nonces.Value     = totalNonces - noncesUsed;
            nonces.TextAlign = HorizontalAlignment.Right;
            nonces.Increment = 64;
            inputBox.Controls.Add(nonces);

            //Trackbar
            System.Windows.Forms.TrackBar trackbar = new TrackBar();
            trackbar.Size          = new System.Drawing.Size(size.Width - 80, 45);
            trackbar.Location      = new System.Drawing.Point(75, 63);
            trackbar.SmallChange   = 64;
            trackbar.LargeChange   = (int)(totalNonces - noncesUsed) / 64;
            trackbar.TickFrequency = trackbar.LargeChange;
            trackbar.Maximum       = (int)(totalNonces - noncesUsed);
            trackbar.Value         = (int)(totalNonces - noncesUsed);

            trackbar.ValueChanged += new EventHandler(yourMethod);

            void yourMethod(object s, EventArgs e)
            {
                nonces.Value = trackbar.Value;
            }

            inputBox.Controls.Add(trackbar);


            System.Windows.Forms.Label lbl_sn3 = new Label();
            lbl_sn3.Size     = new System.Drawing.Size(70, 23);
            lbl_sn3.Location = new System.Drawing.Point(10, 111);
            lbl_sn3.Text     = "Capacity: ";
            inputBox.Controls.Add(lbl_sn3);

            //progressbar
            System.Windows.Forms.ProgressBar progress = new ProgressBar();
            progress.Size     = new System.Drawing.Size(size.Width - 90, 16);
            progress.Location = new System.Drawing.Point(80, 110);
            inputBox.Controls.Add(progress);

            //lbl_capa.Text = ((decimal)((int)(BFS.bfsTOC.diskspace / 64) - (int)(totalNonces)) / 4 / 1024).ToString("0.00") + " GiB free of" + ((decimal)BFS.bfsTOC.diskspace * 4096 / 1024 / 1024 / 1024).ToString("0.00") + " GiB";

            Button okButton = new Button();

            okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            okButton.Name         = "okButton";
            okButton.Size         = new System.Drawing.Size(75, 23);
            okButton.Text         = "&OK";
            okButton.Location     = new System.Drawing.Point(size.Width - 85 - 80, 150);
            inputBox.Controls.Add(okButton);

            Button cancelButton = new Button();

            cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            cancelButton.Name         = "cancelButton";
            cancelButton.Size         = new System.Drawing.Size(75, 23);
            cancelButton.Text         = "&Cancel";
            cancelButton.Location     = new System.Drawing.Point(size.Width - 85, 150);
            inputBox.Controls.Add(cancelButton);

            inputBox.AcceptButton = okButton;
            inputBox.CancelButton = cancelButton;

            DialogResult result = inputBox.ShowDialog();

            UInt64.TryParse(textBox.Text, out input1);
            input2 = (uint)nonces.Value;

            return(result);
        }