Skip to content

Commit

Permalink
mem reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
MaynardMiner committed May 30, 2019
1 parent 925e6a4 commit b2113da
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build/powershell/background/startup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Get-Params {
}
if (-not $global:Config.Params.Platform) {
write-Host "Detecting Platform..." -Foreground Cyan
if (Test-Path "C:\") { $global:Config.Params.Platform = "windows" }
if ($IsWindows) { $global:Config.Params.Platform = "windows" }
else { $global:Config.Params.Platform = "linux" }
Write-Host "OS = $($global:Config.Params.Platform)" -ForegroundColor Green
}
Expand Down
2 changes: 1 addition & 1 deletion build/powershell/build/poolbans.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function Set-Donation {
$DonateTime = Get-Date;
$DonateText = "Miner has last donated on $DonateTime";
$DonateText | Set-Content ".\build\txt\donate.txt"
if ($SWARMAlgorithm.Count -gt 0 -and $SWARMAlgorithm -ne "") { $SWARMAlgorithm = $Null }
if ($global:SWARMAlgorithm.Count -gt 0 -and $global:SWARMAlgorithm -ne "") { $global:SWARMAlgorithm = $Null }
if ($global:Config.Params.Coin -gt 0) { $global:Config.Params.Coin = $Null }
}
elseif ($global:Config.Params.Coin.Count -eq 1 -and $global:Config.Params.Coin -ne "") {
Expand Down
3 changes: 1 addition & 2 deletions build/powershell/build/pricing.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ function Get-Pricing {
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
try {
Write-Log "SWARM Is Building The Database. Auto-Coin Switching: $($global:Config.Params.Auto_Coin)" -foreground "yellow"
$global:Rates = Invoke-RestMethod "https://api.coinbase.com/v2/exchange-rates?currency=BTC" -UseBasicParsing | Select-Object -ExpandProperty data | Select-Object -ExpandProperty rates
$global:Config.Params.Currency | Where-Object { $global:Rates.$_ } | ForEach-Object { $global:Rates | Add-Member $_ ([Double]$global:Rates.$_) -Force }
$global:Rates = Invoke-RestMethod "https://api.coinbase.com/v2/exchange-rates?currency=BTC" -UseBasicParsing | Select-Object -ExpandProperty data | Select-Object -ExpandProperty rates | Select-Object "$($global:Config.Params.Currency)"
$global:WattEX = [Double](((1 / $global:Rates.$($global:Config.Params.Currency)) * $global:WattHour))
}
catch {
Expand Down
4 changes: 2 additions & 2 deletions build/powershell/build/wallets.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Set-Donation {
$DonateTime = Get-Date;
$DonateText = "Miner has last donated on $DonateTime";
$DonateText | Set-Content ".\build\txt\donate.txt"
if ($SWARMAlgorithm.Count -gt 0 -and $SWARMAlgorithm -ne "") { $SWARMAlgorithm = $Null }
if ($global:SWARMAlgorithm.Count -gt 0 -and $global:SWARMAlgorithm -ne "") { $global:SWARMAlgorithm = $Null }
if ($global:Config.Params.Coin -gt 0) { $global:Config.Params.Coin = $Null }
}
elseif ($global:Config.Params.Coin.Count -eq 1 -and $global:Config.Params.Coin -ne "") {
Expand Down Expand Up @@ -119,7 +119,7 @@ function Get-Wallets {

function Add-Algorithms {
if ($global:Config.Params.Coin.Count -eq 1 -and $global:Config.Params.Coin -ne "") { $global:Config.Params.Passwordcurrency1 = $global:Config.Params.Coin; $global:Config.Params.Passwordcurrency2 = $global:Config.Params.Coin; $global:Config.Params.Passwordcurrency3 = $global:Config.Params.Coin }
if ($SWARMAlgorithm) { $SWARMALgorithm | ForEach-Object { $global:Algorithm += $_ } }
if ($global:SWARMAlgorithm) { $global:SWARMAlgorithm | ForEach-Object { $global:Algorithm += $_ } }
elseif ($global:Config.Params.Auto_Algo -eq "Yes") { $global:Algorithm = $global:Config.Pool_Algos.PSObject.Properties.Name }
if ($global:Config.Params.Type -notlike "*NVIDIA*") {
if ($global:Config.Params.Type -notlike "*AMD*") {
Expand Down
18 changes: 4 additions & 14 deletions build/powershell/miner/gather.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,8 @@ function Get-AlgoMiners {
$global:QuickTimer.Restart()
write-Log "Checking Algo Miners. . . ." -ForegroundColor Yellow
##Load Only Needed Algorithm Miners
$Global:AlgoMiners = New-Object System.Collections.ArrayList
$SearchMiners = Get-Miners
$SearchMiners | % { $Global:AlgoMiners.Add($_) | Out-Null }
$SearchMiners = $null
$global:AlgoPools = $null
if ($Global:AlgoMiners) { $Global:AlgoMiners | % { $Global:Miners.Add($_) | Out-Null } }
$Global:AlgoMiners = $null
Get-Miners | % { $Global:Miners.Add($_) | Out-Null }
$AlgoPools.Clear()
$global:QuickTimer.Stop()
Write-Log "Algo Miners Loading Time: $([math]::Round($global:QuickTimer.Elapsed.TotalSeconds)) seconds" -Foreground Green
}
Expand All @@ -119,13 +114,8 @@ function Get-CoinMiners {
$Global:Coins = $true
write-Log "Checking Coin Miners. . . . ." -ForegroundColor Yellow
##Load Only Needed Coin Miners
$Global:CoinMiners = New-Object System.Collections.ArrayList
$SearchMiners = Get-Miners
$SearchMiners | % { $Global:CoinMiners.Add($_) | Out-Null }
$SearchMiners = $Null
$global:CoinPools = $null
if ($Global:CoinMiners) { $Global:CoinMiners | % { $Global:Miners.Add($_) | Out-Null } }
$Global:CoinMiners = $null
Get-Miners | % { $Global:Miners.Add($_) | Out-Null }
$CoinPools.Clear()
$global:QuickTimer.Stop()
Write-Log "Coin Miners Loading Time: $([math]::Round($global:QuickTimer.Elapsed.TotalSeconds)) seconds" -Foreground Green
}
Expand Down
4 changes: 2 additions & 2 deletions build/powershell/pool/gather.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function Get-Pools {
}
function Get-AlgoPools {
$global:QuickTimer.Restart()
$Files = Get-ChildItem "algopools" | Where BaseName -in $global:Config.params.poolname #| Select -First 1
$Files = Get-ChildItem "algopools" | Where BaseName -in $global:Config.params.poolname
write-Log "Checking Algo Pools." -Foregroundcolor yellow;
$AllAlgoPools = Get-Pools -PoolType "Algo" -Items $Files
##Get Custom Pools
write-Log "Adding Custom Pools. ." -ForegroundColor Yellow;
$Files = Get-ChildItem "custompools" | Where BaseName -in $global:Config.params.poolname #| Select -First 1
$Files = Get-ChildItem "custompools" | Where BaseName -in $global:Config.params.poolname
$AllCustomPools = Get-Pools -PoolType "Custom" -Items $Files

if ($global:Config.Params.Auto_Algo -eq "Yes" -or $SingleMode -eq $True) {
Expand Down
2 changes: 1 addition & 1 deletion build/powershell/pool/initial.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Get-PoolTables {
$global:divisortable.Add("zergpool", @{ })
$global:divisortable.Add("fairpool", @{ })

if ($global:Config.Params.Coin.Count -eq 1 -and $global:Config.Params.Coin -ne "" -and $SWARMAlgorithm.Count -eq 1 -and $global:Config.Params.SWARM_Mode -ne "") {
if ($global:Config.Params.Coin.Count -eq 1 -and $global:Config.Params.Coin -ne "" -and $global:SWARMAlgorithm.Count -eq 1 -and $global:Config.Params.SWARM_Mode -ne "") {
$global:SingleMode = $true
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/powershell/scripts/background.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ try { if( -not ( $Net | Where {$_.DisplayName -like "*background.ps1*"} ) ) { Ne
}
$Net = $null

if(Test-Path "C:\"){ Start-Process "powershell" -ArgumentList "Set-Location `'$global:dir`'; .\build\powershell\scripts\icon.ps1 `'$global:dir\build\apps\comb.ico`'" -NoNewWindow }
if($IsWindows){ Start-Process "powershell" -ArgumentList "Set-Location `'$global:dir`'; .\build\powershell\scripts\icon.ps1 `'$global:dir\build\apps\comb.ico`'" -NoNewWindow }

$global:global = "$Global:Dir\build\powershell\global";
$global:background = "$Global:Dir\build\powershell\background";
Expand Down
2 changes: 1 addition & 1 deletion build/powershell/scripts/get.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ https://github.com/MaynardMiner/SWARM/wiki/HiveOS-management
else { $Get += "No Platforms Selected: Please choose a platform NVIDIA1,NVIDIA2,NVIDIA3,AMD1,CPU" }
}
"update" {
if (Test-Path "C:\") {
if ($IsWindows) {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -ne $false) {
$version = Get-Content ".\build\txt\version.txt"
Expand Down
4 changes: 2 additions & 2 deletions build/powershell/scripts/modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (Test-Path $Path) {
if ($Item.Name -like "*psm1*") {
if (test-path ".\build\pid\miner_pid.txt") {
##windows
if (test-Path "C:\") {
if ($IsWindows) {
$MPID = Get-Content ".\build\pid\miner_pid.txt" | % { Get-Process -Id $_ -ErrorAction SilentlyContinue }
if ($MPID) {
Stop-Process -Id $MPID.ID
Expand Down Expand Up @@ -51,7 +51,7 @@ if (Test-Path $Path) {
$SWARMPS1 | Set-Content ".\swarm.ps1" -Encoding UTF8
$message += "Module added. Restarting SWARM"

if (test-Path "C:\") { Start-Process ".\SWARM.bat" }
if ($IsWindows) { Start-Process ".\SWARM.bat" }
else { Start-Process "miner" -ArgumentList "start" -Wait }
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/powershell/scripts/view.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Param (
)

Clear-Host
if((Test-Path "C:\")){$Platform = "windows"}
if(($IsWindows)){$Platform = "windows"}
if(-not $n){$n = 5}
[cultureinfo]::CurrentCulture = 'en-US'

Expand Down
2 changes: 1 addition & 1 deletion build/powershell/startup/parameters.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Get-Parameters {

if (-not $global:Config.Params.Platform) {
write-Host "Detecting Platform..." -Foreground Cyan
if (Test-Path "C:\") { $global:Config.Params.Platform = "windows" }
if ($IsWindows) { $global:Config.Params.Platform = "windows" }
else { $global:Config.Params.Platform = "linux" }
Write-Host "OS = $($global:Config.Params.Platform)" -ForegroundColor Green
}
Expand Down
2 changes: 1 addition & 1 deletion build/powershell/startup/remoteagent.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function start-update {
Write-Log "User Specfied Updates: Searching For Previous Version" -ForegroundColor Yellow
Write-Log "Check $Location For any Previous Versions"

if (Test-Path "C:\") {
if ($IsWindows) {
$Global:amd = Get-Content ".\config\update\amd-win.json" | ConvertFrom-Json
$Global:nvidia = Get-Content ".\config\update\nvidia-win.json" | ConvertFrom-Json
$Global:cpu = Get-Content ".\config\update\cpu-win.json" | ConvertFrom-Json
Expand Down
2 changes: 1 addition & 1 deletion startup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $Defaults.PSObject.Properties.Name | % { if ($_ -notin $Parsed.keys) { $Parsed.A

$Parsed | convertto-json | Out-File ".\config\parameters\arguments.json"

if(Test-path "C:\") {
if($IsWindows) {
$host.ui.RawUI.WindowTitle = "SWARM";
Start-Process "CMD" -ArgumentList "/C `"pwsh -noexit -executionpolicy Bypass -WindowStyle Maximized -command `"Set-Location C:\; Set-Location `'$Dir`'; .\swarm.ps1`"`"" -Verb RunAs
}
Expand Down
Loading

0 comments on commit b2113da

Please sign in to comment.