Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyFFM committed Jun 3, 2018
1 parent e598aa6 commit 7dd4772
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
35 changes: 25 additions & 10 deletions plotMerge/plotMerge/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ namespace plotMerge
class Program
{
static AutoResetEvent[] autoEvents;
static ScoopReadWriter scoopReadWriter1;
static ScoopReadWriter scoopReadWriter2;

static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
//no arguments provided
if (args.Length < 2)
{
Expand Down Expand Up @@ -149,11 +153,9 @@ static void Main(string[] args)
Scoop scoop4 = new Scoop(Math.Min(src.nonces, limit)); //space needed for one partial scoop

//Create and open Reader/Writer
ScoopReadWriter scoopReadWriter1;
scoopReadWriter1 = new ScoopReadWriter(source);
scoopReadWriter1.OpenR();

ScoopReadWriter scoopReadWriter2;
scoopReadWriter2 = new ScoopReadWriter(target);
scoopReadWriter2.OpenW();

Expand All @@ -170,19 +172,19 @@ static void Main(string[] args)
int loops = (int)Math.Ceiling((double)(src.nonces) / limit);
TaskInfo[] masterplan = new TaskInfo[2048*loops];

//create masterplan
//create masterplan
for (int y = 0; y < 2048; y++)
{
//loop partial scoop
int zz = 0;
//loop partial scoop
for (int z = 0; z < src.nonces; z += limit)
{
masterplan[y*loops+zz] = new TaskInfo();
masterplan[y*loops+zz].reader = scoopReadWriter1;
masterplan[y*loops+zz].writer = scoopReadWriter2;
masterplan[y*loops+zz].y = y;
masterplan[y*loops+zz].z = z;
masterplan[y*loops+zz].x = y * loops + zz;
masterplan[y*loops+zz].x = y*loops+zz;
masterplan[y*loops+zz].limit = limit;
masterplan[y*loops+zz].src = src;
masterplan[y*loops+zz].tar = tar;
Expand All @@ -191,13 +193,11 @@ static void Main(string[] args)
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].end = masterplan.LongLength;
zz += 1;
}
}



//work masterplan
//perform first read
Th_read(masterplan[0]);
Expand Down Expand Up @@ -229,6 +229,7 @@ static void Main(string[] args)
// close reader/writer
scoopReadWriter1.Close();
scoopReadWriter2.Close();
Console.Write("File closed!");
}

public static void Th_read(object stateInfo)
Expand Down Expand Up @@ -265,9 +266,14 @@ public static void Th_write(object stateInfo)
ti.writer.WriteScoop(4095 - ti.y, ti.tar.nonces, ti.z + ti.src.start - ti.tar.start, ti.scoop4, Math.Min(ti.src.nonces - ti.z, ti.limit));
ti.writer.WriteScoop(ti.y, ti.tar.nonces, ti.z + ti.src.start - ti.tar.start, ti.scoop3, Math.Min(ti.src.nonces - ti.z, ti.limit));
}
//Thread.Sleep(2000);
if (ti.x != (ti.end -1))
if (ti.x != (ti.end - 1))
{
autoEvents[1].Set();
}
else
{
Console.Write("All done!");
}
}

struct TaskInfo
Expand Down Expand Up @@ -352,5 +358,14 @@ struct plotfile
public int nonces;
public int stagger;
}

static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{
//Cleanup
if (scoopReadWriter1 != null) scoopReadWriter1.Close();
if (scoopReadWriter2 != null) scoopReadWriter2.Close();
Console.WriteLine("End.");
}

}
}
12 changes: 10 additions & 2 deletions plotMerge/plotMerge/ScoopReadWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void OpenW()
{
//assert priviliges
if (!Privileges.HasAdminPrivileges) Console.WriteLine("INFO: Missing Priviledge, File creation will take a while...");
_fs = new FileStream(_FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 1048576, FileFlagNoBuffering);
_fs = new FileStream(_FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 1048576, FileOptions.WriteThrough);
_lPosition = 0;
_lLength = _fs.Length;
_bOpen = true;
Expand All @@ -61,7 +61,15 @@ public void WriteScoop(int scoop, long totalNonces, long startNonce, Scoop sourc
{
_lPosition = scoop * (64 * totalNonces) + startNonce * 64;
_fs.Seek(_lPosition, SeekOrigin.Begin);
_fs.Write(source.byteArrayField, 0, limit * 64);
try
{
_fs.Write(source.byteArrayField, 0, limit * 64);
}
catch (IOException e)
{
Console.WriteLine("ERR:" + e.Message);
_fs.Close();
}
_lPosition += limit * 64;
}

Expand Down
22 changes: 22 additions & 0 deletions plotMerge/plotMerge/plotMerge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
<AssemblyName>plotMerge</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -47,5 +62,12 @@
<ItemGroup>
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 7dd4772

Please sign in to comment.