-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Самсонов Олег
authored and
Самсонов Олег
committed
Dec 15, 2017
1 parent
1b22e9a
commit 5f420f9
Showing
38 changed files
with
2,880 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/ | ||
stats/ | ||
*.config.txt | ||
config.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<# | ||
MindMiner Copyright (C) 2017 Oleg Samsonov aka Quake4/Quake3 | ||
https://github.com/Quake4/MindMiner | ||
License GPL-3.0 | ||
#> | ||
|
||
class AlgoInfo { | ||
[bool] $Enabled | ||
[string] $Algorithm | ||
|
||
[string] ToString() { | ||
return $this | Select-Object Enabled, Algorithm | ||
} | ||
} | ||
|
||
class AlgoInfoEx : AlgoInfo { | ||
[string] $ExtraArgs | ||
[int] $BenchmarkSeconds | ||
|
||
[string] ToString() { | ||
return $this | Select-Object Enabled, Algorithm, ExtraArgs, BenchmarkSeconds | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<# | ||
MindMiner Copyright (C) 2017 Oleg Samsonov aka Quake4/Quake3 | ||
https://github.com/Quake4/MindMiner | ||
License GPL-3.0 | ||
#> | ||
|
||
# read/write/store base confirguration | ||
class BaseConfig { | ||
static [string] $Filename = ".config.txt" | ||
|
||
# save config file | ||
[void] Save([string] $fn) { | ||
$this | ConvertTo-Json | Out-File -FilePath $fn -Force | ||
} | ||
|
||
# check exists file and really parsed | ||
static [bool] Exists([string] $fn) { | ||
try { | ||
$hash = [BaseConfig]::Read($fn) | ||
if ($hash -is [Collections.Hashtable] -and $hash.Count -gt 0) { | ||
return $true | ||
} | ||
} | ||
catch { } | ||
return $false | ||
} | ||
|
||
# read json config | ||
static [Collections.Hashtable] Read([string] $fn) { | ||
$temp = Get-Content -Path $fn | ConvertFrom-Json | ||
|
||
if ($temp) { | ||
$hash = @{} | ||
$temp | Get-Member -MemberType NoteProperty | ForEach-Object { $hash.Add($_.Name, $temp."$($_.Name)") } | ||
if ($hash.Count -gt 0) { | ||
return $hash | ||
} | ||
} | ||
|
||
return $null | ||
} | ||
|
||
# read or create config | ||
static [Collections.Hashtable] ReadOrCreate([string] $fn, [Collections.Hashtable] $hash) { | ||
try { | ||
$temp = Get-Content -Path $fn | ConvertFrom-Json | ||
} | ||
catch { | ||
$temp = $null | ||
} | ||
|
||
if ($temp) { | ||
$hash = @{} | ||
$temp | Get-Member -MemberType NoteProperty | ForEach-Object { $hash.Add($_.Name, $temp."$($_.Name)") } | ||
return $hash | ||
} | ||
else { | ||
$hash | ConvertTo-Json | Out-File -FilePath $fn -Force | ||
return $hash | ||
} | ||
} | ||
|
||
# read or create config | ||
static [Object[]] ReadOrCreate([string] $fn, [Object[]] $array) { | ||
try { | ||
$temp = Get-Content -Path $fn | ConvertFrom-Json | ||
} | ||
catch { | ||
$temp = $null | ||
} | ||
|
||
if ($temp) { | ||
return $temp | ||
} | ||
else { | ||
$array | ConvertTo-Json | Out-File -FilePath $fn -Force | ||
return $array | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<# | ||
MindMiner Copyright (C) 2017 Oleg Samsonov aka Quake4/Quake3 | ||
https://github.com/Quake4/MindMiner | ||
License GPL-3.0 | ||
#> | ||
|
||
. .\Code\BaseConfig.ps1 | ||
. .\Code\MinerInfo.ps1 | ||
. .\Code\Get-ManagementObject.ps1 | ||
|
||
enum eRegion { | ||
Europe | ||
Usa | ||
China | ||
Japan | ||
Other | ||
} | ||
|
||
# read/write/validate/store confirguration | ||
class Config : BaseConfig { | ||
# replace [BaseConfig]::Filename | ||
static [string] $Filename = "config.txt" | ||
|
||
[string] $Region = [eRegion]::Europe | ||
[bool] $SSL = $true | ||
$Wallet = @{ BTC = "" } | ||
[string] $WorkerName = "MindMiner" | ||
[string] $Login | ||
[string] $Password = "x" | ||
[int] $CheckTimeout = 5 | ||
[int] $LoopTimeout = 60 | ||
[int] $NoHashTimeout = 7 | ||
[int] $AverageCurrentHashSpeed = 180 | ||
[string] $AverageHashSpeed = "1 day" | ||
[string[]] $AllowedTypes = @("CPU", "nVidia", "AMD", "Intel") | ||
|
||
static [bool] $Is64Bit = [Environment]::Is64BitOperatingSystem | ||
static [int] $Processors = 0 | ||
static [int] $Cores = 0 | ||
static [int] $Threads = 0 | ||
static [string] $Version = "v0.1" | ||
static [string] $BinLocation = "Bin" | ||
static [eMinerType[]] $ActiveTypes = @([eMinerType]::CPU) | ||
static [string[]] $CPUFeatures | ||
static [timespan] $RateTimeout | ||
|
||
static Config() { | ||
Get-ManagementObject "select * from Win32_Processor" { | ||
Param([Management.ManagementObjectCollection] $items) | ||
foreach ($each in $items) { | ||
[Config]::Processors += 1 | ||
foreach ($item in $each.Properties) { | ||
if ($item.Name -eq "NumberOfCores") { | ||
[Config]::Cores += [int]::Parse($item.Value) | ||
} | ||
elseif ($item.Name -eq "NumberOfLogicalProcessors") { | ||
[Config]::Threads += [int]::Parse($item.Value) | ||
} | ||
} | ||
} | ||
} | ||
$result = [Collections.Generic.List[string]]::new() | ||
$result.Add([eMinerType]::CPU) | ||
Get-ManagementObject "select * from Win32_VideoController" { | ||
Param([Management.ManagementObjectCollection] $items) | ||
foreach ($each in $items) { | ||
# Write-Host $each | ||
foreach ($item in $each.Properties) { | ||
# Write-Host $item.Name, $item.Value | ||
if ($item.Name -eq "AdapterCompatibility" -or $item.Name -eq "Caption" -or $item.Name -eq "Description" -or | ||
$item.Name -eq "Name" -or $item.Name -eq "VideoProcessor") { | ||
if (![string]::IsNullOrWhiteSpace($item.Value)) { | ||
[Enum]::GetNames([eMinerType]) | ForEach-Object { | ||
if (!$result.Contains($_) -and "$($item.Value)".IndexOf($_, [StringComparison]::InvariantCultureIgnoreCase) -ge 0) { | ||
$result.Add($_) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
[Config]::ActiveTypes = $result.ToArray() | ||
} | ||
|
||
# save config file | ||
[void] Save() { | ||
$this.Save([Config]::Filename) | ||
} | ||
|
||
# validate readed config file | ||
[string] Validate() { | ||
$result = [Collections.ArrayList]::new() | ||
if ([string]::IsNullOrWhiteSpace($this.Wallet) -or [string]::IsNullOrWhiteSpace($this.Wallet.BTC)) { | ||
$result.Add("Wallet.BTC") | ||
} | ||
if ([string]::IsNullOrWhiteSpace($this.WorkerName)) { | ||
$result.Add("WorkerName") | ||
} | ||
if (!(($this.Region -as [eRegion]) -is [eRegion])) { | ||
$result.Add("Region") | ||
} | ||
else { | ||
$this.Region = $this.Region -as [eRegion] | ||
} | ||
if ($this.CheckTimeout -lt 3) { | ||
$this.CheckTimeout = 3 | ||
} | ||
if ($this.LoopTimeout -lt 30) { | ||
$this.LoopTimeout = 30 | ||
} | ||
if ($this.NoHashTimeout -lt 5) { | ||
$this.NoHashTimeout = 5 | ||
} | ||
return [string]::Join(", ", $result.ToArray()) | ||
} | ||
|
||
[string] ToString() { | ||
$pattern2 = "{0,15}: {1}$([Environment]::NewLine)" | ||
$pattern3 = "{0,15}: {1}{2}$([Environment]::NewLine)" | ||
$result = $pattern2 -f "Worker Name", $this.WorkerName + | ||
$pattern2 -f "Login:Password", ("{0}:{1}" -f $this.Login, $this.Password) | ||
$this.Wallet | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name | ForEach-Object { | ||
$result += $pattern2 -f "Wallet $_", $this.Wallet."$_" | ||
} | ||
$result += $pattern3 -f "Loop Timeout", $this.LoopTimeout, " sec" + | ||
$pattern3 -f "Check Timeout", $this.CheckTimeout, " sec" + | ||
$pattern3 -f "No Hash Timeout", $this.NoHashTimeout, " min" + | ||
$pattern2 -f "AVE Hash Speed", $this.AverageHashSpeed + | ||
$pattern3 -f "AVE Current HS", $this.AverageCurrentHashSpeed, " sec" + | ||
$pattern2 -f "OS 64Bit", [Config]::Is64Bit + | ||
$pattern2 -f "CPU & Features", ("{0}/{1}/{2} Processors/Cores/Threads & {3}" -f [Config]::Processors, [Config]::Cores, [Config]::Threads, | ||
[string]::Join(", ", [Config]::CPUFeatures)) + | ||
$pattern3 -f "Active Miners", [string]::Join(", ", [Config]::ActiveTypes), " <= Allowed: $([string]::Join(", ", $this.AllowedTypes))" + | ||
$pattern2 -f "Region", $this.Region + | ||
$pattern2 -f "Version", [Config]::Version | ||
return $result | ||
} | ||
|
||
static [bool] Exists() { | ||
return [Config]::Exists([Config]::Filename) | ||
} | ||
|
||
static [Config] Read() { | ||
$hash = [Config]::Read([Config]::Filename) | ||
if ($hash) { | ||
return [Config] $hash | ||
} | ||
return $null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<# | ||
MindMiner Copyright (C) 2017 Oleg Samsonov aka Quake4/Quake3 | ||
https://github.com/Quake4/MindMiner | ||
License GPL-3.0 | ||
#> | ||
|
||
$Download = $args | ||
|
||
$Download | ForEach-Object { | ||
$URI = $_.URI | ||
$Path = $_.Path | ||
$Dir = Split-Path -Path $Path | ||
$FN = Split-Path -Leaf $URI | ||
$Archive = [IO.Path]::Combine($Dir, $FN) | ||
|
||
# "'$URI' '$Path' '$Dir' '$FN' '$Archive' " | Out-File "$FN.txt" | ||
|
||
if (![string]::IsNullOrWhiteSpace($Dir) -and !(Test-Path $Dir)) { | ||
New-Item -ItemType Directory $Dir | Out-Null | ||
} | ||
|
||
if (!(Test-Path $Path)) { | ||
try { | ||
$req = Invoke-WebRequest $URI -OutFile $Archive -PassThru -ErrorAction Stop -UseBasicParsing | ||
# names not match - upack | ||
if ((Split-Path -Leaf $Path) -ne $FN) { | ||
if ([string]::IsNullOrWhiteSpace($Dir)) { | ||
Start-Process "7z" "x $Archive -y -spe" -Wait -WindowStyle Minimized | ||
} | ||
else { | ||
Start-Process "7z" "x $Archive -o$Dir -y -spe" -Wait -WindowStyle Minimized | ||
} | ||
# remove archive | ||
Remove-Item $Archive -Force | ||
# if has one subfolder - delete him | ||
Get-ChildItem $Dir | Where-Object PSIsContainer -EQ $true | ForEach-Object { | ||
$parent = "$Dir\$_" | ||
Get-ChildItem "$parent" | ForEach-Object { Move-Item "$parent\$_" "$Dir" -Force } | ||
Remove-Item $parent -Force | ||
} | ||
} | ||
} | ||
catch { } | ||
finally { | ||
if ($req -is [IDisposable]) { | ||
$req.Dispose() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<# | ||
MindMiner Copyright (C) 2017 Oleg Samsonov aka Quake4/Quake3 | ||
https://github.com/Quake4/MindMiner | ||
License GPL-3.0 | ||
#> | ||
|
||
function Get-CPUFeatures([Parameter(Mandatory)][string] $bin) { | ||
$fn = [IO.Path]::Combine($bin, "FeatureDetector.exe") | ||
[Diagnostics.Process] $process = $null | ||
try { | ||
$pi = [Diagnostics.ProcessStartInfo]::new($fn) | ||
$pi.UseShellExecute = $false | ||
$pi.RedirectStandardOutput = $true | ||
[Diagnostics.Process] $process = [Diagnostics.Process]::Start($pi) | ||
$process.StandardOutput.ReadLine().Split(@("Features", " ", ":", ","), [StringSplitOptions]::RemoveEmptyEntries) | ||
Remove-Variable pi | ||
} | ||
catch { | ||
Write-Host "Cannot detect CPU features: $_" -ForegroundColor Red | ||
} | ||
finally { | ||
if ($process) { | ||
$process.Dispose() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<# | ||
MindMiner Copyright (C) 2017 Oleg Samsonov aka Quake4/Quake3 | ||
https://github.com/Quake4/MindMiner | ||
License GPL-3.0 | ||
#> | ||
|
||
function Get-CPUMask { | ||
[Collections.Generic.List[string]] $result = [Collections.Generic.List[string]]::new() | ||
if ([Config]::Cores -eq [Config]::Threads) { | ||
# simplify if cores equals threads: 0001 0011 0111 1111 | ||
for ($i = 1; $i -le ([Config]::Cores / [Config]::Processors); $i++) { | ||
$mask = [string]::Empty | ||
for ($j = 1; $j -le [Config]::Processors; $j ++) { | ||
$mask += [string]::new('1', $i).PadLeft([Config]::Cores / [Config]::Processors, "0") | ||
} | ||
$result.Add($mask) | ||
} | ||
} | ||
<# else { | ||
# need simplify: 24 thread equal 16 777 216 variations | ||
for ($i = 1; $i -lt [Math]::Pow(2, [Config]::Threads); $i++) { | ||
$val = [Convert]::ToString($i, 2).PadLeft([Config]::Threads, "0") | ||
$reverce = $val.ToCharArray() | ||
[array]::Reverse($reverce) | ||
if (!$result.Contains([string]::new($reverce))) { | ||
$result.Add($val) | ||
} | ||
} | ||
}#> | ||
$result | ||
} |
Oops, something went wrong.