Skip to content

Commit

Permalink
v6.2.8
Browse files Browse the repository at this point in the history
Fixes:
- Core: Includes.psm1 / Restarting core loop when internet connection is lost
- Core / Includes.psm1: Not stopping running miners when exiting UG-Miner

Improvements:
- Core: Suspend balances tracker und brains when internet connection is lost

Miner changes:
- BzMiner-v21.2.0
- JayddeeCpu-v24.3
- OneZeroMiner-v1.3.4
- Rigel-v1.17.4
- SRBMinerMulti-v2.5.6
- TeamBlackMiner-v2.25
- TeamRedMiner-v0.10.21
- TTMiner-v2024.2.0
  • Loading branch information
UselessGuru committed Jun 8, 2024
1 parent 9d1ad91 commit e73c3dd
Show file tree
Hide file tree
Showing 120 changed files with 1,984 additions and 1,287 deletions.
4 changes: 2 additions & 2 deletions Balances/HashCryptos.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\HashCryptos.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/HiveON.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\Hiveon.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/MiningDutch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\MiningDutch.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/MiningPoolHub.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\MiningPoolHub.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/NiceHash External.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\NiceHash Internal.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/NiceHash Internal.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\NiceHash Internal.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/ProHashing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\ProHashing.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/ZergPool.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\ZergPool.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/Zpool.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\Zpool.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
8 changes: 4 additions & 4 deletions Brains/HashCryptos.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Brains\MiningDutch.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

using module ..\Includes\Include.psm1
Expand Down Expand Up @@ -61,7 +61,7 @@ While ($PoolConfig = $Config.PoolsConfig.$BrainName) {
If ($APICallFails -lt $PoolConfig.PoolAPIAllowedFailureCount) { $APICallFails ++ }
Start-Sleep -Seconds ([Math]::max(60, ($APICallFails * 5 + $PoolConfig.PoolAPIRetryInterval)))
}
} While ($AlgoData.PSObject.Properties.Name.Count -lt 2)
} While ($AlgoData.PSObject.Properties.Name.Count -lt 2 -and $APICallFails -lt 3)

$Timestamp = [DateTime]::Now.ToUniversalTime()

Expand Down Expand Up @@ -149,7 +149,7 @@ While ($PoolConfig = $Config.PoolsConfig.$BrainName) {

Write-Message -Level Debug "Brain '$BrainName': End loop (Duration $Duration sec. / Avg. loop duration: $DurationsAvg sec.); Price history $($PoolObjects.Count) objects; found $($Variables.BrainData.$BrainName.PSObject.Properties.Name.Count) valid pools."

While ($Timestamp -ge $Variables.PoolDataCollectedTimeStamp -or ($Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime().AddSeconds($DurationsAvg + 3) -le $Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime() -lt $Variables.EndCycleTime)) {
While (-not $Variables.MyIP -or $Timestamp -ge $Variables.PoolDataCollectedTimeStamp -or ($Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime().AddSeconds($DurationsAvg + 3) -le $Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime() -lt $Variables.EndCycleTime)) {
Start-Sleep -Seconds 1
}

Expand Down
112 changes: 57 additions & 55 deletions Brains/MiningDutch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Brains\MiningDutch.ps1
Version: 6.2.7
Version date: 2024/04/18
Version: 6.2.8
Version date: 2024/06/08
#>

using module ..\Includes\Include.psm1
Expand Down Expand Up @@ -65,68 +65,70 @@ While ($PoolConfig = $Config.PoolsConfig.$BrainName) {
If ($APICallFails -lt $PoolConfig.PoolAPIAllowedFailureCount) { $APICallFails ++ }
Start-Sleep -Seconds ([Math]::max(60, ($APICallFails * 5 + $PoolConfig.PoolAPIRetryInterval)))
}
} While (-not $AlgoData -or $AlgoData.message)
} While ((-not $AlgoData -or $AlgoData.message) -and $APICallFails -lt 3)

$Timestamp = [DateTime]::Now.ToUniversalTime()

ForEach ($Algo in $AlgoData.PSObject.Properties.Name) {
$Algorithm_Norm = Get-Algorithm $Algo
$BasePrice = If ($AlgoData.$Algo.actual_last24h) { $AlgoData.$Algo.actual_last24h } Else { $AlgoData.$Algo.estimate_last24h }
If ($AlgoData) {
ForEach ($Algo in $AlgoData.PSObject.Properties.Name) {
$Algorithm_Norm = Get-Algorithm $Algo
$BasePrice = If ($AlgoData.$Algo.actual_last24h) { $AlgoData.$Algo.actual_last24h } Else { $AlgoData.$Algo.estimate_last24h }

$AlgoData.$Algo | Add-Member Updated $Timestamp -Force
$AlgoData.$Algo | Add-Member Updated $Timestamp -Force

If ($PoolVariant) {
# Reset history when stat file got removed
$StatName = "$($PoolVariant)_$($Algorithm_Norm)_Profit"
If (-not (Get-Stat -Name $StatName)) {
$PoolObjects = $PoolObjects.Where({ $_.Name -ne $PoolName })
Write-Message -Level Debug "Pool brain '$BrainName': PlusPrice history cleared for $($StatName -replace '_Profit')"
If ($PoolVariant) {
# Reset history when stat file got removed
$StatName = "$($PoolVariant)_$($Algorithm_Norm)_Profit"
If (-not (Get-Stat -Name $StatName)) {
$PoolObjects = $PoolObjects.Where({ $_.Name -ne $PoolName })
Write-Message -Level Debug "Pool brain '$BrainName': PlusPrice history cleared for $($StatName -replace '_Profit')"
}
}
}

$PoolObjects += [PSCustomObject]@{
actual_last24h = $BasePrice
Date = $Timestamp
estimate_current = $AlgoData.$Algo.estimate_current
estimate_last24h = $AlgoData.$Algo.estimate_last24h
Last24hDrift = $AlgoData.$Algo.estimate_current - $BasePrice
Last24hDriftPercent = If ($BasePrice -gt 0) { ($AlgoData.$Algo.estimate_current - $BasePrice) / $BasePrice } Else { 0 }
Last24hDriftSign = If ($AlgoData.$Algo.estimate_current -ge $BasePrice) { "Up" } Else { "Down" }
Name = $Algo
$PoolObjects += [PSCustomObject]@{
actual_last24h = $BasePrice
Date = $Timestamp
estimate_current = $AlgoData.$Algo.estimate_current
estimate_last24h = $AlgoData.$Algo.estimate_last24h
Last24hDrift = $AlgoData.$Algo.estimate_current - $BasePrice
Last24hDriftPercent = If ($BasePrice -gt 0) { ($AlgoData.$Algo.estimate_current - $BasePrice) / $BasePrice } Else { 0 }
Last24hDriftSign = If ($AlgoData.$Algo.estimate_current -ge $BasePrice) { "Up" } Else { "Down" }
Name = $Algo
}
}
}
Remove-Variable Algo, Algorithm_Norm, BasePrice, StatName -ErrorAction Ignore

# Created here for performance optimization, minimize # of lookups
$CurPoolObjects = $PoolObjects.Where({ $_.Date -eq $Timestamp })
$SampleSizets = New-TimeSpan -Minutes $PoolConfig.BrainConfig.SampleSizeMinutes
$SampleSizeHalfts = New-TimeSpan -Minutes ($PoolConfig.BrainConfig.SampleSizeMinutes / 2)
$GroupAvgSampleSize = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizets) }) | Group-Object Name, Last24hDriftSign | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupMedSampleSize = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizets) }) | Group-Object Name | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupAvgSampleSizeHalf = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizeHalfts) }) | Group-Object Name, Last24hDriftSign | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupMedSampleSizeHalf = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizeHalfts) }) | Group-Object Name | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupMedSampleSizeNoPercent = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizets) }) | Group-Object Name | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDrift } }

ForEach ($PoolName in ($PoolObjects.Name | Select-Object -Unique).Where({ $_ -in $AlgoData.PSObject.Properties.Name })) {
$PenaltySampleSizeHalf = ((($GroupAvgSampleSizeHalf | Where-Object { $_.Name -eq $PoolName + ", Up" }).Count - ($GroupAvgSampleSizeHalf | Where-Object { $_.Name -eq $Name + ", Down" }).Count) / (($GroupMedSampleSizeHalf | Where-Object { $_.Name -eq $PoolName }).Count)) * [Math]::abs(($GroupMedSampleSizeHalf | Where-Object { $_.Name -eq $PoolName }).Median)
$PenaltySampleSizeNoPercent = ((($GroupAvgSampleSize | Where-Object { $_.Name -eq $PoolName + ", Up" }).Count - ($GroupAvgSampleSize | Where-Object { $_.Name -eq $Name + ", Down" }).Count) / (($GroupMedSampleSize | Where-Object { $_.Name -eq $PoolName }).Count)) * [Math]::abs(($GroupMedSampleSizeNoPercent | Where-Object { $_.Name -eq $PoolName }).Median)
$Penalty = ($PenaltySampleSizeHalf * $PoolConfig.BrainConfig.SampleHalfPower + $PenaltySampleSizeNoPercent) / ($PoolConfig.BrainConfig.SampleHalfPower + 1)
$LastPrice = [Double]$CurPoolObjects.Where({ $_.Name -eq $PoolName }).actual_last24h
$PlusPrice = [Math]::max(0, [Double]($LastPrice + $Penalty))

# Reset history if PlusPrice is not within +/- 1000% of LastPrice
If ($LastPrice -gt 0 -and ($PlusPrice -lt $LastPrice * 0.1 -or $PlustPrice -gt $LastPrice * 10)) {
Remove-Stat -Name "$($PoolVariant)_$($Algorithm_Norm)_Profit"
$PoolObjects = $PoolObjects.Where({ $_.Name -ne $PoolName })
$PlusPrice = $LastPrice
Write-Message -Level Debug "Pool brain '$BrainName': PlusPrice history cleared for $Poolname (LastPrice: $LastPrice vs. PlusPrice: $PlusPrice)"
Remove-Variable Algo, Algorithm_Norm, BasePrice, StatName -ErrorAction Ignore

# Created here for performance optimization, minimize # of lookups
$CurPoolObjects = $PoolObjects.Where({ $_.Date -eq $Timestamp })
$SampleSizets = New-TimeSpan -Minutes $PoolConfig.BrainConfig.SampleSizeMinutes
$SampleSizeHalfts = New-TimeSpan -Minutes ($PoolConfig.BrainConfig.SampleSizeMinutes / 2)
$GroupAvgSampleSize = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizets) }) | Group-Object Name, Last24hDriftSign | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupMedSampleSize = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizets) }) | Group-Object Name | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupAvgSampleSizeHalf = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizeHalfts) }) | Group-Object Name, Last24hDriftSign | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupMedSampleSizeHalf = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizeHalfts) }) | Group-Object Name | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDriftPercent } }
$GroupMedSampleSizeNoPercent = $PoolObjects.Where({ $_.Date -ge ($Timestamp - $SampleSizets) }) | Group-Object Name | Select-Object Name, Count, @{ Name = "Avg"; Expression = { ($_.Group.Last24hDriftPercent | Measure-Object -Average | Select-Object -ExpandProperty Average) } }, @{ Name = "Median"; Expression = { Get-Median $_.Group.Last24hDrift } }

ForEach ($PoolName in ($PoolObjects.Name | Select-Object -Unique).Where({ $_ -in $AlgoData.PSObject.Properties.Name })) {
$PenaltySampleSizeHalf = ((($GroupAvgSampleSizeHalf | Where-Object { $_.Name -eq $PoolName + ", Up" }).Count - ($GroupAvgSampleSizeHalf | Where-Object { $_.Name -eq $Name + ", Down" }).Count) / (($GroupMedSampleSizeHalf | Where-Object { $_.Name -eq $PoolName }).Count)) * [Math]::abs(($GroupMedSampleSizeHalf | Where-Object { $_.Name -eq $PoolName }).Median)
$PenaltySampleSizeNoPercent = ((($GroupAvgSampleSize | Where-Object { $_.Name -eq $PoolName + ", Up" }).Count - ($GroupAvgSampleSize | Where-Object { $_.Name -eq $Name + ", Down" }).Count) / (($GroupMedSampleSize | Where-Object { $_.Name -eq $PoolName }).Count)) * [Math]::abs(($GroupMedSampleSizeNoPercent | Where-Object { $_.Name -eq $PoolName }).Median)
$Penalty = ($PenaltySampleSizeHalf * $PoolConfig.BrainConfig.SampleHalfPower + $PenaltySampleSizeNoPercent) / ($PoolConfig.BrainConfig.SampleHalfPower + 1)
$LastPrice = [Double]$CurPoolObjects.Where({ $_.Name -eq $PoolName }).actual_last24h
$PlusPrice = [Math]::max(0, [Double]($LastPrice + $Penalty))

# Reset history if PlusPrice is not within +/- 1000% of LastPrice
If ($LastPrice -gt 0 -and ($PlusPrice -lt $LastPrice * 0.1 -or $PlustPrice -gt $LastPrice * 10)) {
Remove-Stat -Name "$($PoolVariant)_$($Algorithm_Norm)_Profit"
$PoolObjects = $PoolObjects.Where({ $_.Name -ne $PoolName })
$PlusPrice = $LastPrice
Write-Message -Level Debug "Pool brain '$BrainName': PlusPrice history cleared for $Poolname (LastPrice: $LastPrice vs. PlusPrice: $PlusPrice)"
}
$AlgoData.$PoolName | Add-Member PlusPrice $PlusPrice -Force
}
$AlgoData.$PoolName | Add-Member PlusPrice $PlusPrice -Force
}
Remove-Variable CurPoolObjects, GroupAvgSampleSize, GroupMedSampleSize, GroupAvgSampleSizeHalf, GroupMedSampleSizeHalf, GroupMedSampleSizeNoPercent, LastPrice, Penalty, PenaltySampleSizeHalf, PenaltySampleSizeNoPercent, PlusPrice, PoolName, SampleSizets, SampleSizeHalfts -ErrorAction Ignore
Remove-Variable CurPoolObjects, GroupAvgSampleSize, GroupMedSampleSize, GroupAvgSampleSizeHalf, GroupMedSampleSizeHalf, GroupMedSampleSizeNoPercent, LastPrice, Penalty, PenaltySampleSizeHalf, PenaltySampleSizeNoPercent, PlusPrice, PoolName, SampleSizets, SampleSizeHalfts -ErrorAction Ignore

If ($PoolConfig.BrainConfig.UseTransferFile -or $Config.PoolsConfig.$BrainName.BrainDebug) {
($AlgoData | ConvertTo-Json).replace("NaN", 0) | Out-File -LiteralPath $BrainDataFile -Force -ErrorAction Ignore
If ($PoolConfig.BrainConfig.UseTransferFile -or $Config.PoolsConfig.$BrainName.BrainDebug) {
($AlgoData | ConvertTo-Json).replace("NaN", 0) | Out-File -LiteralPath $BrainDataFile -Force -ErrorAction Ignore
}
}

$Variables.BrainData.$BrainName = $AlgoData
Expand All @@ -150,7 +152,7 @@ While ($PoolConfig = $Config.PoolsConfig.$BrainName) {

Write-Message -Level Debug "Brain '$BrainName': End loop (Duration $Duration sec. / Avg. loop duration: $DurationsAvg sec.); Price history $($PoolObjects.Count) objects; found $($Variables.BrainData.$BrainName.PSObject.Properties.Name.Count) valid pools."

While ($Timestamp -ge $Variables.PoolDataCollectedTimeStamp -or ($Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime().AddSeconds($DurationsAvg + 3) -le $Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime() -lt $Variables.EndCycleTime)) {
While (-not $Variables.MyIP -or $Timestamp -ge $Variables.PoolDataCollectedTimeStamp -or ($Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime().AddSeconds($DurationsAvg + 3) -le $Variables.EndCycleTime -and [DateTime]::Now.ToUniversalTime() -lt $Variables.EndCycleTime)) {
Start-Sleep -Seconds 1
}

Expand Down
Loading

0 comments on commit e73c3dd

Please sign in to comment.