-
Notifications
You must be signed in to change notification settings - Fork 40
/
swarm.ps1
executable file
·692 lines (573 loc) · 27.6 KB
/
swarm.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
<#
SWARM is open-source software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SWARM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#>
##############################################################################
####### Startup ######
##############################################################################
## any windows version below 10 invoke full screen mode.
if ($isWindows) {
$os_string = "$([System.Environment]::OSVersion.Version)".split(".") | Select -First 1
if ([int]$os_string -lt 10) {
invoke-expression "mode 800"
}
}
## Set Current Path
$Global:config = [hashtable]::Synchronized(@{ })
[cultureinfo]::CurrentCulture = 'en-US'
$Global:Config.Add("vars", @{ })
$Global:Config.vars.Add( "dir", (Split-Path $script:MyInvocation.MyCommand.Path) )
$Global:Config.vars.dir = $Global:Config.vars.dir -replace "/var/tmp", "/root"
Set-Location $Global:Config.vars.dir
if (-not (test-path ".\debug")) { New-Item -Path "debug" -ItemType Directory | Out-Null }
if ($IsWindows) {
## Fix weird PATH issues for commands
$restart = $false
$Target1 = [System.EnvironmentVariableTarget]::Machine
$Target2 = [System.EnvironmentVariableTarget]::Process
$Path = [System.Environment]::GetEnvironmentVariable('Path', $Target1)
$Path_List = $Path.Split(';')
## Remove all old SWARM Paths and add current
if ("$($Global:Config.vars.dir)\build\cmd" -notin $Path_List) {
Write-Host "Please Wait- Setting Environment Variables..." -ForegroundColor Green
$Path_List = $Path_List | Where { $_ -notlike "*SWARM*" }
$Path_List += "$($Global:Config.vars.dir)\build\cmd"
$New_PATH = $Path_List -join (';')
[System.Environment]::SetEnvironmentVariable('Path', $New_PATH, $Target1)
[System.Environment]::SetEnvironmentVariable('Path', $New_PATH, $Target2)
$restart = $true
}
## Set Path
if ($Env:SWARM_DIR -ne $Global:Config.vars.dir) {
$restart = $true
[System.Environment]::SetEnvironmentVariable('SWARM_DIR', "$($Global:Config.vars.dir)", $Target1)
[System.Environment]::SetEnvironmentVariable('SWARM_DIR', "$($Global:Config.vars.dir)", $Target2)
}
## By stopping explorer, it restarts retroactively with path refreshed
## for commands.
## Now set env variables for process- Just in case.
if ($restart -eq $true) {
Stop-Process -ProcessName explorer
}
}
## Check Powershell version. Output warning.
if ($PSVersionTable.PSVersion -ne "6.2.4") {
Write-Host "WARNING: Powershell Core Version is $($PSVersionTable.PSVersion)" -ForegroundColor Red
Write-Host "Currently supported version for SWARM is 6.2.4" -ForegroundColor Red
Write-Host "SWARM will continue anyways- It may cause issues." -ForegroundColor Red
Write-Host "Links for Powershell:" -ForegroundColor Red
Write-Host "https://github.com/PowerShell/PowerShell/releases/tag/v6.2.4" -ForegroundColor Red
Write-Host ""
Write-Host "Windows: Microsoft Visual C++ Redistributable for Visual Studio (2012) (2013) (2015,2017 and 2019)" -ForegroundColor Red
Write-Host "Is Requried As Well:" -ForegroundColor Red
Write-Host "https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads" -ForegroundColor Red
## Create a pause in case window is scrolling too fast.
Start-Sleep -S 5
}
##filepath dir
. .\build\powershell\global\modules.ps1
$env:Path += ";$($(vars).dir)\build\cmd"
## Window Security Items
if ($IsWindows) {
$Host.UI.RawUI.BackgroundColor = 'Black'
$Host.UI.RawUI.ForegroundColor = 'White'
try { Get-ChildItem $($(vars).dir) -Recurse | Unblock-File } catch { }
## Exclusion Windows Defender
try {
if ((Get-MpPreference).ExclusionPath -notcontains (Convert-Path .)) {
Start-Process "powershell" -Verb runAs -ArgumentList "Add-MpPreference -ExclusionPath `'$($(vars).dir)`'" -WindowStyle Minimized
}
}
catch { }
## Set Firewall Rule
try {
$Net = Get-NetFireWallRule
if ($Net) {
try {
if ( -not ( $Net | Where { $_.DisplayName -like "*swarm.ps1*" } ) ) {
New-NetFirewallRule -DisplayName 'swarm.ps1' -Direction Inbound -Program "$($(vars).dir)\swarm.ps1" -Action Allow | Out-Null
}
}
catch { }
}
}
catch { }
Remove-Variable -name Net -ErrorAction Ignore
## Windows Icon
Start-Process "powershell" -ArgumentList "Set-Location `'$($(vars).dir)`'; .\build\powershell\scripts\icon.ps1 `'$($(vars).dir)\build\apps\icons\SWARM.ico`'" -NoNewWindow
## Add .dll
Add-Type -Path ".\build\apps\launchcode.dll"
}
## Debug Mode- Allow you to run with last known arguments or arguments.json.
$(vars).Add("debug", $false)
if ($global:config.vars.debug -eq $True) {
Start-Transcript ".\logs\debug.log"
if (($IsWindows)) { Set-ExecutionPolicy Bypass -Scope Process }
}
## Load Modules
$(vars).Add("startup", "$($(vars).dir)\build\powershell\startup")
$(vars).Add("web", "$($(vars).dir)\build\api\web")
$(vars).Add("global", "$($(vars).dir)\build\powershell\global")
$(vars).Add("build", "$($(vars).dir)\build\powershell\build")
$(vars).Add("pool", "$($(vars).dir)\build\powershell\pool")
$(vars).Add("miner", "$($(vars).dir)\build\powershell\miner")
$(vars).Add("control", "$($(vars).dir)\build\powershell\control")
$(vars).Add("run", "$($(vars).dir)\build\powershell\run")
$(vars).Add("benchmark", "$($(vars).dir)\build\powershell\benchmark")
$p = [Environment]::GetEnvironmentVariable("PSModulePath")
if ($P -notlike "*$($(vars).dir)\build\powershell*") {
$P += ";$($(vars).startup)";
$P += ";$($(vars).web)";
$P += ";$($(vars).global)";
$P += ";$($(vars).build)";
$P += ";$($(vars).pool)";
$P += ";$($(vars).miner)";
$P += ";$($(vars).control)";
$P += ";$($(vars).run)";
$P += ";$($(vars).benchmark)";
[Environment]::SetEnvironmentVariable("PSModulePath", $p)
Write-Host "Modules Are Loaded" -ForegroundColor Green
}
Remove-Variable -name P -ErrorAction Ignore
$(vars).Add("Modules", @())
## Get Parameters
Global:Add-Module "$($(vars).startup)\parameters.psm1"
Global:Get-Parameters
$(arg).TCP_Port | Out-File ".\debug\port.txt"
##Insert Single Modules Here
## Startup Modules
Import-Module "$($(vars).global)\stats.psm1" -Scope Global
Import-Module "$($(vars).global)\hashrates.psm1" -Scope Global
Import-Module "$($(vars).global)\gpu.psm1" -Scope Global
. .\build\powershell\global\classes.ps1
if ($IsWindows -and [string]$Global:config.hive_params.MINER_DELAY -ne "") {
Write-Host "Miner Delay Specified- Sleeping for $($Global:config.hive_params.MINER_DELAY)"
$Sleep = [Double]$Global:config.hive_params.MINER_DELAY
Start-Sleep -S $Sleep
Remove-Variable -Name Sleep -ErrorAction Ignore
}
## Crash Reporting
Global:Add-Module "$($(vars).startup)\crashreport.psm1"
Global:Start-CrashReporting
## Start The Log
Global:Add-Module "$($(vars).startup)\startlog.psm1"
$($(vars).dir) | Set-Content ".\build\bash\dir.sh";
$Global:log_params = [hashtable]::Synchronized(@{ })
$Global:log_params.Add("lognum", 1)
$global:log_params.Add("logname", $null)
$Global:log_params.Add( "dir", (Split-Path $script:MyInvocation.MyCommand.Path) )
$Global:log_params.dir = $Global:Config.vars.dir -replace "/var/tmp", "/root"
Global:Start-Log -Number $global:log_params.lognum;
## Initiate Update Check
Global:Add-Module "$($(vars).startup)\remoteagent.psm1"
if ($(arg).Platform -eq "Windows" -or $(arg).Update -eq "Yes") {
Global:Get-Version
Global:Start-Update -Update $Getupdates
}
if ($(arg).Platform -eq "windows") {
Global:Add-Module "$($(vars).startup)\getconfigs.psm1"
Global:Start-AgentCheck
}
## create debug/command folder
if (-not (Test-Path ".\debug")) { New-Item -Path ".\build" -Name "txt" -ItemType "directory" | Out-Null }
##Start Data Collection
Global:Add-Module "$($(vars).startup)\datafiles.psm1"
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'
Global:Get-DateFiles
Global:Clear-Stats
Global:Get-ArgNotice
Global:Set-NewType
##HiveOS Confirmation
if ( (Test-Path "/hive/miners") -or $(arg).Hive_Hash -ne "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) { $(arg).HiveOS = "Yes" }
log "HiveOS = $($(arg).HiveOS)"
#Startings Settings (Non User Arguments):
Global:Add-New_Variables
##Determine Net Modules
$WebArg = @("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "")
if ($(arg).Hive_Hash -notin $WebArg -or (Test-Path "/hive/miners") ) { $(vars).NetModules += ".\build\api\hiveos"; $(vars).WebSites += "HiveOS" }
else { $(arg).HiveOS = "No" }
Remove-Variable -Name WebArg -ErrorAction Ignore
if ($Config.Params.Swarm_Hash -ne "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") { $(vars).NetModules += ".\build\api\swarm"; $(vars).WebSites += "SWARM" }
## Initialize
$(vars).Add("GPU_Count", $Null)
$(vars).Add("BusData", $Null)
$(vars).Add("types", @())
$(vars).Add("threads", $null)
switch ($(arg).Platform) {
"linux" {
Global:Add-Module "$($(vars).startup)\linuxconfig.psm1"
Global:Add-Module "$($(vars).startup)\sexyunixlogo.psm1"
Global:Start-LinuxConfig
}
"windows" {
Global:Add-Module "$($(vars).startup)\winconfig.psm1"
Global:Add-Module "$($(vars).startup)\sexywinlogo.psm1"
Global:Start-WindowsConfig
}
}
## Determine AMD platform
$(vars).add("AMDPlatform", 0)
if ($(arg).Type -like "*AMD*") {
if ([string]$(arg).CLPlatform) { $(vars).AMDPlatform = [string]$(arg).CLPlatform }
else {
log "Getting AMD OPENCL Platform. Note: If SWARM doesn't continue, a GPU has crashed on rig." -ForeGroundColor Yellow
Global:Add-Module "$($(vars).startup)\cl.psm1"
[string]$(vars).AMDPlatform = Global:Get-AMDPlatform
log "AMD OpenCL Platform is $($(vars).AMDPlatform)"
}
}
##GPU-Count- Parse the hashtable between devices.
if ($(arg).Type -like "*NVIDIA*" -or $(arg).Type -like "*AMD*" -or $(arg).Type -like "*CPU*") {
if (Test-Path ".\debug\nvidiapower.txt") { Remove-Item ".\debug\nvidiapower.txt" -Force }
if (Test-Path ".\debug\amdpower.txt") { Remove-Item ".\debug\amdpower.txt" -Force }
if ($(vars).GPU_Count -eq 0) { $Device_Count = $(arg).CPUThreads }
else { $Device_Count = $(vars).GPU_Count }
log "Device Count = $Device_Count" -foregroundcolor green
Remove-Variable -Name Device_Count -ErrorAction Ignore
Start-Sleep -S 2
if ([string]$(arg).GPUDevices1) {
$(vars).Add("NVIDIADevices1", ([String]$(arg).GPUDevices1 -replace " ", ","))
$(vars).Add("AMDDevices1", ([String]$(arg).GPUDevices1 -replace " ", ","))
}
else {
$(vars).Add("NVIDIADevices1", "none")
$(vars).Add("AMDDevices1", "none")
}
if ([string]$(arg).GPUDevices2) { $(vars).Add("NVIDIADevices2", ([String]$(arg).GPUDevices2 -replace " ", ",")) } else { $(vars).Add("NVIDIADevices2", "none") }
if ([string]$(arg).GPUDevices3) { $(vars).Add("NVIDIADevices3", ([String]$(arg).GPUDevices3 -replace " ", ",")) } else { $(vars).Add("NVIDIADevices3", "none") }
$(vars).Add("GCount", (Get-Content ".\debug\devicelist.txt" | ConvertFrom-Json))
$(vars).Add("NVIDIATypes", @()); if ($(arg).Type -like "*NVIDIA*") { $(arg).Type | Where { $_ -like "*NVIDIA*" } | % { $(vars).NVIDIATypes += $_ } }
$(vars).Add("CPUTypes", @()); if ($(arg).Type -like "*CPU*") { $(arg).Type | Where { $_ -like "*CPU*" } | % { $(vars).CPUTypes += $_ } }
$(vars).Add("AMDTypes", @()); if ($(arg).Type -like "*AMD*") { $(arg).Type | Where { $_ -like "*AMD*" } | % { $(vars).AMDTypes += $_ } }
}
##Start New Agent
Global:Add-Module "$($(vars).startup)\getconfigs.psm1"
log "Starting New Background Agent" -ForegroundColor Cyan
if ($(arg).Platform -eq "windows") { Global:Start-Background }
elseif ($(arg).Platform -eq "linux") { $Proc = Start-Process ".\build\bash\background.sh" -ArgumentList "background $($($(vars).dir))" -PassThru; $Proc | Wait-Process }
## Parse Wallet Configs
Global:Add-Module "$($(vars).build)\wallets.psm1"
$(vars).Add("All_AltWallets", $Null)
Global:Get-Wallets
if ([String]$(arg).Admin_Fee -eq 0) { if (test-Path ".\admin") { Remove-Item ".\admin" -Recurse -Force | Out-Null } }
## Stop stray miners from previous run before loop
Global:Add-Module "$($(vars).control)\stray.psm1"
if ($IsWindows) { Global:Stop-StrayMiners -Startup }
##Get Optional Miners
Global:Get-Optional
Global:Add-LogErrors
Global:Remove-Modules
$(vars).Remove("BusData")
$(vars).Remove("GPU_Count")
##############################################################################
####### End Startup ######
##############################################################################
While ($true) {
do {
##Insert Looping Modules Here
##############################################################################
####### PHASE 1: Build ######
##############################################################################
## Basic Variable Control:
## 'create' will add a new variable to the variable hashtable (vars)
## 'remove' will either remove the variable specified, or all varibles if 'all' is specified.
## 'create' will add the the (Vars)."Active_Variables" list as well as add the vars to $(vars)
## 'remove' will remove the name from the "Active_Variables" array.
## 'check' checks if variable currently exists- $true if does, $false if it doesn't
## This allows the abililty to remove/add variables to both, as well as clear them all with a single command.
## These are all global values- It can be used with user-created modules.
create Algorithm @()
create BanHammer @()
create ASICTypes @()
create ASICS @{ }
create All_AltWalltes $null
create SWARMAlgorithm $(arg).Algorithm
##Insert Build Single Modules Here
##Insert Build Looping Modules Here
#Get Miner Config Files
Global:Add-Module "$($(vars).build)\miners.psm1"
if ($(arg).Type -like "*CPU*") { create cpu (Global:Get-minerfiles -Types "CPU") }
if ($(arg).Type -like "*NVIDIA*") { create nvidia (Global:Get-minerfiles -Types "NVIDIA") }
if ($(arg).Type -like "*AMD*") { create amd (Global:Get-minerfiles -Types "AMD") }
## Check to see if wallet is present:
if (-not $(arg).Wallet1) {
log "missing wallet1 argument, exiting in 5 seconds" -ForeGroundColor Red;
Start-Sleep -S 5;
exit
}
## Load Miner Configurations
Global:Add-Module "$($(vars).build)\configs.psm1"
Global:Get-MinerConfigs
$global:Config.Pool_Algos = Get-Content ".\config\pools\pool-algos.json" | ConvertFrom-Json
Global:Add-ASICS
create oc_default (Get-Content ".\config\oc\oc-defaults.json" | ConvertFrom-Json)
create oc_algos (Get-Content ".\config\oc\oc-algos.json" | ConvertFrom-Json)
##Manage Pool Bans
Global:Add-Module "$($(vars).build)\poolbans.psm1"
Global:Start-PoolBans
## Handle Wallet Stuff / Bans
Global:Add-Module "$($(vars).build)\wallets.psm1"
Global:Set-Donation
Global:Get-Wallets
if ([String]$(arg).Admin_Fee -eq 0) { if (test-Path ".\admin") { Remove-Item ".\admin" -Recurse -Force | Out-Null } }
. .\build\powershell\scripts\bans.ps1 "add" $(arg).Bans "process" | Out-Null
Global:Add-Algorithms
Global:Set-Donation
# Pricing and Clearing Timeouts
Global:Add-Module "$($(vars).build)\pricing.psm1"
Global:Get-Watts
Global:Get-TimeCheck
Global:Get-Pricing
Global:Clear-Timeouts
## Phase Clean up
## Remove variables that were added from external run of a SWARM command.
Remove-Variable -Name BanDir -ErrorAction Ignore
Remove-Variable -Name Screen -ErrorAction Ignore
Remove-Variable -Name Value -ErrorAction Ignore
Remove-Variable -Name Item -ErrorAction Ignore
Remove-Variable -Name JsonBanHammer -ErrorAction Ignore
Remove-Variable -Name Launch -ErrorAction Ignore
Remove-Variable -Name BanChange -ErrorAction Ignore
Remove-Variable -Name PoolDir -ErrorAction Ignore
Remove-Variable -Name PoolChange -ErrorAction Ignore
Remove-Variable -Name BanJson -ErrorAction Ignore
Remove-Variable -Name Action -ErrorAction Ignore
Global:Remove-Modules
##############################################################################
####### END PHASE 1 ######
##############################################################################
##############################################################################
####### PHASE 2: POOLS ######
##############################################################################
## Build Initial Pool Hash Tables
create Coins $false
create FeeTable @{ }
create DivisorTable @{ }
create SingleMode @{ }
create AlgoPools 1
create CoinPools 1
create Pool_Hashrates @{ }
##Insert Pools Single Modules Here
##Insert Pools Looping Modules Here
Global:Add-Module "$($(vars).pool)\initial.psm1"
Global:Get-PoolTables
Global:Remove-BanHashrates
if ($(vars).Options -eq 1) {
. .\build\data\json.ps1
Global:Get-Message
}
##Add Global Modules - They Get Removed in Above Function
Global:Remove-Modules
. .\build\powershell\global\modules.ps1
##Get Algorithm Pools
Global:Add-Module "$($(vars).pool)\gather.psm1"
Global:Get-AlgoPools
Global:Get-CoinPools
Global:Remove-Modules
## Phase Clean up
## Remove variables no longer needed.
remove FeeTable
remove DivisorTable
##############################################################################
####### END PHASE 2 ######
##############################################################################
##############################################################################
####### PHASE 3: Miners ######
##############################################################################
create Thresholds @()
create Miners (New-Object System.Collections.ArrayList)
create PreviousMinerPorts @{AMD1 = ""; NVIDIA1 = ""; NVIDIA2 = ""; NVIDIA3 = ""; CPU = "" }
##Insert Miners Single Modules Here
##Insert Miners Looping Modules Here
##Load The Miners
Global:Add-Module "$($(vars).miner)\gather.psm1"
Global:Get-AlgoMiners
Global:Get-CoinMiners
##Send error if no miners found
if ($(vars).Miners.Count -eq 0) {
$HiveMessage = "No Miners Found! Check Arguments/Net Connection"
$HiveWarning = @{result = @{command = "timeout" } }
if ($(vars).WebSites) {
$(vars).WebSites | ForEach-Object {
$Sel = $_
try {
Global:Add-Module "$($(vars).web)\methods.psm1"
Global:Get-WebModules $Sel
$SendToHive = Global:Start-webcommand -command $HiveWarning -swarm_message $HiveMessage -Website "$($Sel)"
}
catch { log "WARNING: Failed To Notify $($Sel)" -ForeGroundColor Yellow }
Global:Remove-WebModules $sel
}
}
log "$HiveMessage" -ForegroundColor Red
Remove-Variable -Name HiveMessage -ErrorAction Ignore
Remove-Variable -Name HiveWarning -ErrorAction Ignore
Remove-Variable -Name Sel -ErrorAction Ignore
## Go to sleep for interval
start-sleep $(arg).Interval;
## Check How many times it occurred.
## If it occurred more than 10 times-
## Remove all current hashrates, and migrate backup hashrates
## to stats folder. Then Restart Computer.
$(vars).No_Miners++
Global:Confirm-Backup
##remove all active parameters, Then restart loop
remove all
continue
}
##Sort The Miners
Global:Add-Module "$($(vars).miner)\sorting.psm1"
if ($(arg).Volume -eq "Yes") { Get-Volume }
Global:Start-MinerDownloads
$CutMiners = Global:Start-MinerReduction
$CutMiners | ForEach-Object { $(vars).Miners.Remove($_) } | Out-Null;
Remove-Variable -Name CutMiners -ErrorAction Ignore
$(vars).Miners | ForEach-Object { $_.Symbol = $_.Symbol -replace "-Algo", ""; $_.Symbol = $_.Symbol -replace "-Coin", "" }
Global:Start-Sorting
Global:Add-SwitchingThreshold
##Choose The Best Miners
Global:Add-Module "$($(vars).miner)\choose.psm1"
Remove-BadMiners
create Miners_Combo (Global:Get-BestMiners)
$(vars).bestminers_combo = Global:Get-Conservative
log "Most Ideal Choice Is $($(vars).bestminers_combo.Symbol) on $($(vars).bestminers_combo.MinerPool)" -foregroundcolor green
## Phase Clean up
Global:Remove-Modules
$(vars).Watts = $null
remove CoinPools
remove AlgoPools
remove SWARMAlgorithm
remove BanHammer
remove ASICTypes
remove Algorithm
remove Coins
remove SingleMode
remove Miners_Combo
remove Pool_HashRates
##############################################################################
####### End Phase 3 ######
##############################################################################
##############################################################################
####### Phase 4: Control ######
##############################################################################
## Build the Current Active Miners
create Restart $false
create NoMiners $false
create SWARM_IT $false
create MinerInterval $null
create MinerStatInt $null
create ModeCheck 0
create Share_Table @{ }
create oc_groups @()
##Insert Control Single Modules Here
##Insert Control Looping Modules Here
## Add New Miners- Download if neccessary
## Ammend Their Pricing
Global:Add-Module "$($(vars).control)\config.psm1"
Global:Add-Module "$($(vars).control)\initial.psm1"
Global:Get-ActiveMiners
Global:Get-BestActiveMiners
Global:Get-ActivePricing
## Start / Stop / Restart Miners - Load Modules
Global:Add-Module "$($(vars).control)\run.psm1"
Global:Add-Module "$($(vars).control)\launchcode.psm1"
Global:Add-Module "$($(vars).control)\config.psm1"
Global:Add-Module "$($(vars).control)\stray.psm1"
Global:Add-Module "$($(vars).control)\hugepage.psm1"
## Stop miners that need to be stopped
Global:Stop-ActiveMiners
## Attack Stray Miners, if they are running
if ($IsWindows) { Global:Stop-StrayMiners }
## Randomx Hugepages Before starting miners
Global:Start-HugePage_Check
## Start New Miners
Global:Start-NewMiners -Reason "Launch"
## Determing Interval
Global:Add-Module "$($(vars).control)\notify.psm1"
Global:Get-LaunchNotification
Global:Get-Interval
## Get Shares
log "Getting Coin Tracking From Pool" -foregroundColor Cyan
if ($glbal:Config.params.Track_Shares -eq "Yes") { Global:Get-CoinShares }
## Phase Clean up
Global:Remove-Modules
remove oc_algos
remove oc_default
remove oc_groups
remove PreviousMinerPorts
remove Restart
remove NoMiners
##############################################################################
####### End Phase 4 ######
##############################################################################
##############################################################################
####### Phase 5: Run ######
#############################################################################
##Insert Run Single Modules Here
##Insert Run Looping Modules Here
## Clear Old Commands Data
Global:Add-Module "$($(vars).run)\initial.psm1"
Global:Get-ExchangeRate
Global:Get-ScreenName
$(vars).Miners | ConvertTo-Json -Depth 4 | Set-Content ".\debug\profittable.txt"
Global:Clear-Commands
Get-Date | Out-File ".\debug\minerstats.txt"
Get-Date | Out-File ".\debug\charts.txt"
Global:Get-Charts | Out-File ".\debug\charts.txt" -Append
## Refreshing Pricing Data
Global:Add-Module "$($(vars).run)\commands.psm1"
Global:Get-PriceMessage
Global:Get-Commands
remove Miners
Global:Get-Logo
Global:Update-Logging
Get-Date | Out-File ".\debug\mineractive.txt"
Global:Get-MinerActive | Out-File ".\debug\mineractive.txt" -Append
##Start SWARM Loop
Global:Add-Module "$($(vars).run)\loop.psm1"
Global:Start-MinerLoop
## Phase Clean up
Global:Remove-Modules
remove Thresholds
remove SWARM_IT
remove MinerInterval
remove ASICS
remove Share_Table
remove ModeCheck
##############################################################################
####### End Phase 5 ######
##############################################################################
##############################################################################
####### Phase 6: Benchmark ######
##############################################################################
Global:Add-Module "$($(vars).benchmark)\attempt.psm1"
##Insert Benchmark Single Modules Here
##Insert Benchmark Looping Modules Here
## Start WattOMeter function
if ($(arg).WattOMeter -eq "Yes") { Global:Start-WattOMeter }
##Try To Benchmark
Global:Start-Benchmark
##############################################################################
####### End Phase 6 ######
##############################################################################
## Remaining Clean up
remove all
Global:Remove-Modules
Get-Job -State Completed | Remove-Job
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
[GC]::Collect()
Clear-History
}until($Error.Count -gt 0)
Global:Add-LogErrors
Global:Remove-Modules
continue;
}