private void btn_CreateEmptyPlotFile_Click(object sender, EventArgs e) { String drive = drivesView.SelectedItems[0].SubItems[1].Text; UInt64 sn = 0; UInt32 nonces = 0; //show dialog if (Dialogs.ShowInputDialog2(drive, "Create new plot file...", ref sn, ref nonces) == DialogResult.OK) { //create file if (BFS.AddPlotFile(drive, sn, nonces, 3, 0) > -1) { FillBFSView(drive); } else { MessageBox.Show("File Creation failed.\t\t\t", "Create file on" + drive, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
//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)); }