Skip to content

Commit

Permalink
Update core
Browse files Browse the repository at this point in the history
- bump version to v4.7.3.1
- update MiniZ API
- add Fastlane for Benchmark (issue #1651), new parameters in config.txt:
  - "EnableFastlaneBenchmark": set to 1 if you want to skip all benchmarks and dowload (very inaccurate) hashrate and powerdraw values from rbminer.net instead [default=0]
  - "FastlaneBenchmarkTypeCPU" = if EnableFastlaneBenchmark="1": choose the value-set for CPU miners (avg, min or max) [default=avg]
  - "FastlaneBenchmarkTypeGPU" = if EnableFastlaneBenchmark="1": choose the value-set for GPU miners (avg, min or max) [default=avg]
  - "EnableFastlaneBenchmarkMissing" = if EnableFastlaneBenchmark="1": set to 1 if you want to benchmark all device/miners/algos not found on rbminer.net [default=0]
  • Loading branch information
RainbowMiner committed Jul 26, 2021
1 parent a945dce commit b2514bb
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 9 deletions.
77 changes: 75 additions & 2 deletions Modules/Core.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,8 @@ function Invoke-Core {
$Session.Config.PoolStatAverage = Get-StatAverage $Session.Config.PoolStatAverage
$Session.Config.PoolStatAverageStable = Get-StatAverage $Session.Config.PoolStatAverageStable -Default "Week"
$Session.Config.MaxTimeSinceLastBlock = ConvertFrom-Time $Session.Config.MaxTimeSinceLastBlock
$Session.Config.FastlaneBenchmarkTypeCPU = if ($Session.Config.FastlaneBenchmarkTypeCPU -in @("avg","min","max")) {$Session.Config.FastlaneBenchmarkTypeCPU} else {"avg"}
$Session.Config.FastlaneBenchmarkTypeCPU = if ($Session.Config.FastlaneBenchmarkTypeCPU -in @("avg","min","max")) {$Session.Config.FastlaneBenchmarkTypeCPU} else {"avg"}
if ($Session.Config.BenchmarkInterval -lt 60) {$Session.Config.BenchmarkInterval = 60}
if (-not $Session.Config.APIport) {$Session.Config | Add-Member APIport 4000 -Force}
Set-ContentJson -PathToFile ".\Data\localapiport.json" -Data @{LocalAPIport = $Session.Config.APIport} > $null
Expand Down Expand Up @@ -2044,8 +2046,6 @@ function Invoke-Core {
}
if ($MinersNeedSdk -ne $null) {Remove-Variable "MinersNeedSdk"}

if ($Session.RoundCounter -eq 0) {Write-Host "Selecting best miners .."}

if ($Session.Config.MiningMode -eq "combo") {
if ($AllMiners.Where({$_.HashRates.PSObject.Properties.Value -contains $null -and $_.DeviceModel -notmatch '-'})) {
#Benchmarking is still ongoing - remove device combos from miners and make sure no combo stat is left over
Expand Down Expand Up @@ -2090,6 +2090,75 @@ function Invoke-Core {

if ($ComboAlgos -ne $null) {Remove-Variable "ComboAlgos"}

#Handle fastlane benchmarks
if ($Session.Config.EnableFastlaneBenchmark) {
$SkipBenchmarksData = [PSCustomObject]@{}
$SkipBenchmarksCount = 0
$AllMiners.Where({$_.HashRates.PSObject.Properties.Value -contains $null -and $_.HashRates.PSObject.Properties.Name.Count -eq 1}).ForEach({
$Miner = $_
$Miner.DeviceModel -split "-" | Foreach-Object {
if (-not [bool]$SkipBenchmarksData.PSObject.Properties[$_]) {$SkipBenchmarksData | Add-Member $_ @() -Force}
if (-not ($SkipBenchmarksData.$_.Where({$_.name -eq $Miner.BaseName -and $_.ver -eq $Miner.Version}) | Measure-Object).Count) {
$SkipBenchmarksData.$_ += [PSCustomObject]@{
name = $Miner.BaseName
ver = $Miner.Version
}
$SkipBenchmarksCount++
}
}
})

if ($SkipBenchmarksCount) {
if ($Session.RoundCounter -eq 0) {Write-Host "Downloading fastlane benchmarks .." -NoNewline}
$Response = [PSCustomObject]@{}
$Fastlane_Success = 0
$Fastlane_Failed = 0
try {
$Request = ConvertTo-Json @($SkipBenchmarksData.PSObject.Properties | Foreach-Object {
[PSCustomObject]@{
device = "$(if ($_.Name -eq "CPU") {$Global:DeviceCache.DevicesByTypes.CPU.Model_Name | Select-Object -Unique} else {$_.Name})"
isgpu = $_.Name -ne "CPU"
type = if ($_.Name -eq "CPU") {$Session.Config.FastlaneBenchmarkTypeCPU} else {$Session.Config.FastlaneBenchmarkTypeGPU}
miners = @($_.Value | Select-Object)
}
} | Select-Object) -Compress -Depth 10
$Response = Invoke-GetUrl "https://rbminer.net/api/qbench.php" -body @{q=$Request} -timeout 10
if ($Response.status) {
$Miner_Models = @{}
$Global:DeviceCache.Devices.ForEach({$Miner_Models[$_.Name] = $_.Model})
$AllMiners.Where({$_.HashRates.PSObject.Properties.Value -contains $null -and $_.HashRates.PSObject.Properties.Name.Count -eq 1}).ForEach({
$Miner_Name = $_.Name
$Miner_Algo = $_.HashRates.PSObject.Properties.Name -replace '\-.*$'
$Miner_HR = ($DeviceName | Foreach-Object {$Response.data."$($Miner_Models[$_])".$Miner_Name.$Miner_Algo.hr} | Measure-Object -Sum).Sum

if ($Miner_HR -gt 0 -or -not $Session.Config.EnableFastlaneBenchmarkMissing) {
$_.HashRates."$($_.HashRates.PSObject.Properties.Name)" = $Miner_HR
$_.PowerDraw = ($DeviceName | Foreach-Object {$Response.data."$($Miner_Models[$_])".$Miner_Name.$Miner_Algo.pd} | Measure-Object -Sum).Sum
Set-Stat -Name "$($_.Name)_$($Miner_Algo)_HashRate" -Value $Miner_HR -Duration (New-TimeSpan -Seconds 10) -FaultDetection $false -PowerDraw $_.PowerDraw -Sub $Global:DeviceCache.DevicesToVendors[$_.DeviceModel] -Quiet > $null
}
if ($Miner_HR -gt 0) {$Fastlane_Success++} else {$Fastlane_Failed++}
})
}
} catch {
if ($Error.Count){$Error.RemoveAt(0)}
}
if ($Response.status) {
Write-Log -Level Info "Fastlane benchmarks: $Fastlane_Success x success, $Fastlane_Failed x failed"
Write-Host "ok ($Fastlane_Success x success, $Fastlane_Failed x failed)" -ForegroundColor Green
} else {
Write-Log -Level Info "Failed to get fastlane benchmark results from rbminer.net"
Write-Host "failed" -ForegroundColor Red
}

if ($Response -ne $null) {Remove-Variable "Response"}
if ($Request -ne $null) {Remove-Variable "Request"}
}

Remove-Variable "SkipBenchmarksData"
}

if ($Session.RoundCounter -eq 0) {Write-Host "Selecting best miners .."}

#Remove all miners, that need benchmarks during donation run
if ($Session.IsDonationRun -or $Session.IsServerDonationRun) {
$AllMiners = $AllMiners.Where({$_.HashRates.PSObject.Properties.Value -notcontains $null})
Expand Down Expand Up @@ -3850,6 +3919,10 @@ function Set-MinerStats {
$Miner_Failed = $true
}
}

#Update pool statistics
Set-ContentJson -PathToFile ".\Stats\Pools\$($Miner.Pool[$Miner_Index])_Poolstats.txt" -Data ([PSCustomObject]@{Updated=(Get-Date).ToUniversalTime()}) > $null

$Miner_PowerDraw = 0
$Miner_Index++
}
Expand Down
6 changes: 5 additions & 1 deletion Modules/Include.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,8 @@ function Get-Stat {
[Parameter(Mandatory = $false)]
[Switch]$Balances = $false,
[Parameter(Mandatory = $false)]
[Switch]$Poolstats = $false,
[Parameter(Mandatory = $false)]
[Switch]$All = $false,
[Parameter(Mandatory = $false)]
[Switch]$Quiet = $false
Expand All @@ -1356,6 +1358,7 @@ function Get-Stat {
elseif ($Name -match '_Hashrate$') {$Path = "Stats\Miners"; $Cached = $true}
elseif ($Name -match '_(Total|TotalAvg)$') {$Path = "Stats\Totals"}
elseif ($Name -match '_Balance$') {$Path = "Stats\Balances"}
elseif ($Name -match '_Poolstats$') {$Path = "Stats\Pools"}
else {$Path = "Stats"}

if (-not (Test-Path $Path)) {New-Item $Path -ItemType "directory" > $null}
Expand All @@ -1373,14 +1376,15 @@ function Get-Stat {

if (($Miners -or $All) -and -not (Test-Path "Stats\Miners")) {New-Item "Stats\Miners" -ItemType "directory" > $null}
if (($Disabled -or $All) -and -not (Test-Path "Stats\Disabled")) {New-Item "Stats\Disabled" -ItemType "directory" > $null}
if (($Pools -or $All) -and -not (Test-Path "Stats\Pools")) {New-Item "Stats\Pools" -ItemType "directory" > $null}
if (($Pools -or $Poolstats -or $All) -and -not (Test-Path "Stats\Pools")) {New-Item "Stats\Pools" -ItemType "directory" > $null}
if (($Totals -or $TotalAvgs -or $All) -and -not (Test-Path "Stats\Totals")) {New-Item "Stats\Totals" -ItemType "directory" > $null}
if (($Balances -or $All) -and -not (Test-Path "Stats\Balances")) {New-Item "Stats\Balances" -ItemType "directory" > $null}

[System.Collections.Generic.List[string]]$MatchArray = @()
if ($Miners) {$MatchArray.Add("Hashrate") > $null;$Path = "Stats\Miners";$Cached = $true}
if ($Disabled) {$MatchArray.Add("Hashrate|Profit") > $null;$Path = "Stats\Disabled"}
if ($Pools) {$MatchArray.Add("Profit") > $null;$Path = "Stats\Pools"; $Cached = $true}
if ($Poolstats) {$MatchArray.Add("Poolstats") > $null;$Path = "Stats\Pools"}
if ($Totals) {$MatchArray.Add("Total") > $null;$Path = "Stats\Totals"}
if ($TotalAvgs) {$MatchArray.Add("TotalAvg") > $null;$Path = "Stats\Totals"}
if ($Balances) {$MatchArray.Add("Balance") > $null;$Path = "Stats\Balances"}
Expand Down
2 changes: 1 addition & 1 deletion Modules/MinerAPIs.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ class MiniZ : Miner {

try {
$Response = Invoke-TcpRequest $Server $this.Port $Request -Timeout $Timeout -ErrorAction Stop -Quiet -ReadToEnd
$Data = "$($Response -replace "(?smi)^.*?{","{")" | ConvertFrom-Json -ErrorAction Stop
$Data = $Response | ConvertFrom-Json -ErrorAction Stop
}
catch {
if ($Error.Count){$Error.RemoveAt(0)}
Expand Down

0 comments on commit b2514bb

Please sign in to comment.