diff --git a/.gitignore b/.gitignore index b9d84438..b5a25496 100644 --- a/.gitignore +++ b/.gitignore @@ -5,12 +5,16 @@ Cache/* Config/* Downloads/* Archive/* +Dump/* .vscode/ Donation.ctr Wrapper_*.txt !empty.txt -config.ini + +Config.ini +Autoexec.txt +Donations.json WIP/* *custom* diff --git a/AfterburnerResult.bat b/AfterburnerResult.bat index a5278159..6decede5 100644 --- a/AfterburnerResult.bat +++ b/AfterburnerResult.bat @@ -1,3 +1,15 @@ @echo off -powershell -version 5.0 -executionpolicy bypass -command "&.\AfterburnerResult.ps1 -pause \ No newline at end of file + +cd /d %~dp0 + +set Command="&.\AfterburnerResult.ps1" + +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end +pause diff --git a/AutoExchange.bat b/AutoExchange.bat index 9b1207d7..460ec6c1 100644 --- a/AutoExchange.bat +++ b/AutoExchange.bat @@ -3,9 +3,16 @@ cd /d %~dp0 set Mode=Automatic -set Pools=NiceHash,Zpool,NLPool,ZergPool,BlockMasters +set Pools=NiceHash,Zpool,NLPool,ZergPool -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" +set Command="& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause diff --git a/AutoStart Example - Auto with algo filter.bat b/AutoStart Example - Auto with algo filter.bat index b8bfdf4b..e625f5d0 100644 --- a/AutoStart Example - Auto with algo filter.bat +++ b/AutoStart Example - Auto with algo filter.bat @@ -6,7 +6,14 @@ set Mode=Automatic set Pools=Zpool set Algos=Lyra2z -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Algorithm %Algos%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Algorithm %Algos%" +set Command="& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Algorithm %Algos%" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause diff --git a/AutoStart Example - Auto with coin filter.bat b/AutoStart Example - Auto with coin filter.bat index 60648871..9e5fb96b 100644 --- a/AutoStart Example - Auto with coin filter.bat +++ b/AutoStart Example - Auto with coin filter.bat @@ -6,7 +6,14 @@ set Mode=Automatic set Pools=Zpool,MiningPoolHub set Coins=Bitcore,Signatum,Zcash -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Coinsname %Coins%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Coinsname %Coins%" +set Command="& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Coinsname %Coins%" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause diff --git a/AutoStart Example - One coin manual.bat b/AutoStart Example - One coin manual.bat index 84b0113e..9162df22 100644 --- a/AutoStart Example - One coin manual.bat +++ b/AutoStart Example - One coin manual.bat @@ -6,7 +6,14 @@ set Mode=Manual set Pools=SuprNova set Coins=Bitcore -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Coinsname %Coins%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Coinsname %Coins%" +set Command="& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools% -Coinsname %Coins%" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause diff --git a/AutoStart Example - Two pools on Auto.bat b/AutoStart Example - Two pools on Auto.bat deleted file mode 100644 index b901be67..00000000 --- a/AutoStart Example - Two pools on Auto.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -cd /d %~dp0 - -set Mode=Automatic -set Pools=MiningPoolHub,NiceHash - -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" - -pause diff --git a/AutoStart.bat b/AutoStart.bat index f0268947..8e06cb53 100644 --- a/AutoStart.bat +++ b/AutoStart.bat @@ -3,9 +3,16 @@ cd /d %~dp0 set Mode=Automatic -set Pools=NiceHash,Zpool,BlockMasters,NLPool,ZergPool,WhatToMine,CoinCalc +set Pools=NiceHash,Zpool,NLPool,ZergPool,WhatToMine,CoinCalc -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" +set Command="& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause diff --git a/AutoStart24h.bat b/AutoStart24h.bat index 2053928e..bfbafc86 100644 --- a/AutoStart24h.bat +++ b/AutoStart24h.bat @@ -3,9 +3,16 @@ cd /d %~dp0 set Mode=Automatic24h -set Pools=Zpool,WhatToMine,NiceHash,MiningPoolHub +set Pools=NiceHash,Zpool,NLPool,ZergPool,WhatToMine,CoinCalc -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" -::pwsh -noexit -executionpolicy bypass -command "& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" +set Command="& .\Core.ps1 -MiningMode %Mode% -PoolsName %Pools%" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause diff --git a/BootStart.bat b/BootStart.bat index 75043a0a..a34bd296 100644 --- a/BootStart.bat +++ b/BootStart.bat @@ -5,3 +5,5 @@ cd /d %~dp0 timeout /t 180 AutoStart.bat + +pause diff --git a/Config-SAMPLE.ini b/Config-SAMPLE.ini index f9db8e0a..a2470fcc 100644 --- a/Config-SAMPLE.ini +++ b/Config-SAMPLE.ini @@ -1,14 +1,11 @@ -# ********************************************************************************************************** -# ******************** ******************** -# ******************** BASIC OPTIONS ******************** -# ******************** ******************** -# ********************************************************************************************************** + +# *** USER OPTIONS *** # Your rig ID. If not defined, will use your ComputerName. # On pools like Suprnova you MUST create workers on the pool website! ie. worker_amd, worker_cpu ; WorkerName = worker -# Autoexchange pools preferred currencies. +# Preferred currency for Autoexchange pools. # You can set a generic currency for all autoexchange pools CURRENCY=XXX or a specific currency for one pool CURRENCY_NAMEOFPOOL=BTC # Pools without autoexchange (YIIMP, SuprNova...) need a wallet of same coin you are mining # You must be sure selected pool support pay that coin or you can lose your money. @@ -26,79 +23,47 @@ Location = EU # Pool username for non-anonymous pools such as SuprNova, BlocksFactory, or MiningPoolHub # You can ignore this setting if you're not using these types of pools UserName = your_pool_username +UserName_NameOfPool = your_pool_username -# Your EMail, for pools that require +# Your EMail, for pools that require it EMail = xxx@yyy.com -# For auto exchange pools. You only need set a wallet for your preferred currencies (currency). +# For auto exchange pools you only need set a wallet for your preferred currencies (Currency). # Other pools without an auto exchange, like YIIMP, will need a wallet defined for the same coin you are mining. # You can add wallets using pattern WALLET_XXX=YYYYY (where XXX=currency symbol; YYYYY=your wallet). -# For NiceHash if a WALLET_BTC_NICE=XXXXXXX is found it will be used, if not WALLET_BTC will be used. +# For NiceHash if a Wallet_BTC_NICE=XXXXXXX is found it will be used, if not WALLET_BTC will be used. # For some coins, such as Electroneum, you may need a Payment ID. Add it after your address separated by a dot. Wallet_BTC_NICE = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Wallet_BTC = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY Wallet_XXX = ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ -# Number of minutes to mine as a donation each day (default is 15 mins which is ~1%). Minimum is 10 mins -Donate = 15 +# [OPTIONAL] API Keys +# Some non-anonymous pools, such as SuprNova and MPH, require API keys to obtain wallet details or pool speed. +ApiKey_MiningPoolHub = xxx +ApiKey_Suprnova = xxx + + + +# *** HARDWARE OPTIONS *** # Use your CPU to mine: Enabled/Disabled (you can start CPU only mining using empty GpuGroups config) CPUMining = Disabled -# Electricity cost in LOCALCURRENCY -# Example for all day cost [{"HourStart": 0, "HourEnd": 23, "CostKwh": 0.10}] -# Example for two periods cost (7:00-22:59,23:00-6:59) [{"HourStart": 7, "HourEnd": 22, "CostKwh": 0.083}, {"HourStart": 23, "HourEnd": 6, "CostKwh": 0.036}] +# CUDA version for NVIDIA miners. Some miners require certain version, please set the version your drivers support +CUDAVersion = 10.0 + +# Electricity cost in LocalCurrency +# Example for all day cost: ElectricityCost = [{"HourStart": 0, "HourEnd": 23, "CostKwh": 0.1}] +# Example for two periods cost (7:00-22:59,23:00-6:59) +; ElectricityCost = [{"HourStart": 7, "HourEnd": 22, "CostKwh": 0.083}, {"HourStart": 23, "HourEnd": 6, "CostKwh": 0.036}] -# Minimum Profit (Revenue - Electricity cost) for device group in LOCALCURRENCY +# Minimum Profit (Revenue minus Electricity cost) for Device Group in LocalCurrency MinProfit_AMD = 0 MinProfit_CPU = 0 -# ********************************************************************************************************** -# ******************** ******************** -# ******************** ADVANCED OPTIONS (don't change unless you know what you do) ******************** -# ******************** ******************** -# ********************************************************************************************************** - -# Profit recheck interval time (in seconds) for each kind of pool -# This interval recalculates and selects the most profitable algorithm -Interval_PPS = 300 -Interval_PPLS = 1800 - -# Maximum Benchmarks interval time (less than 300 not recommended for GPU due to miners ramp time) -# Benchmarks will usually complete within 2-3 minutes, when the speed is stable -BenchmarkTime = 600 - -# Keep updating miner stats after benchmarking. Enable only on dedicated mining systems. (Enabled/Disabled) -LiveStatsUpdate = Disabled - -# Screen to be shown at Forager start-up (WALLETS/CURRENT/HISTORY/PROFITS/STATS) -StartScreen = Profits - -# Percent to switch miner/algo, new miner/algo only will be launched if new profit is greater than actual profit -# in specified percent (example: 10 means that new miner/algo must be 10% more profitable than actual to be launched) -PercentToSwitch = 10 - -# Setting to Disabled will disable GPU Activity watchdog, Power usage and Electricity cost calculation. Hashrate watchdog will still work. -# Enabled by default, unless explicitly set to Disabled -HardwareMonitoring = Enabled - -# If WatchdogHashrate is defined, miner will be marked as failed when hashrate drops by defined percentage. -# Exclude Algos like X16r, which have very high rate fluctuations -# Recommended values: 20 - 40 (%) for dedicated miners. 0 to Disable -WatchdogHashrate = 0 -WatchdogExcludeAlgos = X16r - -# [OPTIONAL] API Keys -# Some non-anonymous pools, such as SuprNova and MPH, require API keys to obtain wallet details or pool speed. -# For example APIKEY_MINING_POOL_HUB=a04e6sx30b38f73878ae40775f70efseff6582e8ec37600215755487ccbd36b4510b4 -# FORMAT: APIKEY_NAMEOFPOOL=XXXXXXXXXX) [optional] -ApiKey_MiningPoolHub = xxx -ApiKey_Suprnova = xxx - # [OPTIONAL] GPU Groups/PowerLimits # if you don't set groups Forager automatically makes 2 groups, one for all NVIDIA Gpus and other for all AMD Gpus -# If you activate this option and you have more than 1 group of same type (AMD,NVIDIA) miners ports will be calculated dynamically # It's recommended to create a group for each card model in your rig, each group will be benchmarked and run separately (you can identify your GPU id's by launching DeviceList.bat) # Type must be NVIDIA or AMD # You can use DeviceList.bat to generate sample config string @@ -108,15 +73,17 @@ ApiKey_Suprnova = xxx # With Afterburner both AMD and NVIDIA power limit are supported and no Admin rights required # Without Afterburner only NVIDIA, and Forager must run with admin rights and UAC disabled or prompts will appear -# Example1: GPUGROUPS=[{"GroupName": "Card1", "Type": "NVIDIA", "Devices": "0", "PowerLimits": "0"}, {"GroupName": "Card2", "Type": "NVIDIA", "Devices": "0", "PowerLimits": "0"}, {"GroupName": "Card3", "Type": "NVIDIA", "Devices": "0", "PowerLimits": "0"}] -# Example2: GPUGROUPS=[{"GroupName": "1080s", "Type": "NVIDIA", "Devices": "0,1,2,3,4", "PowerLimits": "100,90,80"}, {"GroupName": "RX580s", "Type": "AMD", "Devices": "0,1", "PowerLimits": "0"}] +; GpuGroups=[{"GroupName": "Card1", "Type": "NVIDIA", "Devices": "0", "PowerLimits": "0"}, {"GroupName": "Card2", "Type": "NVIDIA", "Devices": "0", "PowerLimits": "0"}, {"GroupName": "Card3", "Type": "NVIDIA", "Devices": "0", "PowerLimits": "0"}] +; GpuGroups=[{"GroupName": "1080s", "Type": "NVIDIA", "Devices": "0,1,2,3,4", "PowerLimits": "100,90,80"}, {"GroupName": "RX580s", "Type": "AMD", "Devices": "0,1", "PowerLimits": "0"}] + # AMD PowerLimit Range from -50 to 50 ; GpuGroups = [{"GroupName": "RX580s", "Type": "AMD", "Devices": "0,1", "PowerLimits": "-20,0"}] # Don't mine with GPUs (will automatically enable CPUMining) - empty "GpuGroups" ; GpuGroups = -# Group by Type only (one group for AMD, one for NVIDIA). If DISABLED, will create groups by Device name + Memory amount. Only used when no GpuGroups defined +# Group by Type only (one group for AMD, one for NVIDIA). If DISABLED, will create groups by Device name + Memory amount. +# Only used when no GpuGroups defined above GpuGroupByType = Enabled # [OPTIONAL] MSI Afterburner support for AMD / CPU monitoring. @@ -124,55 +91,83 @@ GpuGroupByType = Enabled # Afterburner must be started before running Forager and continue running. If Afterburner is restarted, Forager must be also restarted. Afterburner = Enabled +# Setting to Disabled will disable GPU Activity watchdog, Power usage and Electricity cost calculation. Hashrate watchdog will still work. +HardwareMonitoring = Enabled + +# Define what algorithms can be mined for each Group Name, for an Algo can be mined must exists: 1. A pool, 2. A miner, 3. This config. +# If used, algorithm parameter from core.ps1 override this config. If Empty - All algos enabled for group +Algorithms_NVIDIA = Aergo,Allium,Argon2d250,Argon2d500,Argon2d4096,Bitcore,BCD,C11,CnAlloy,CnArto,CnDark,CnFast,CnFreeHaven,CnGpu,CnHalf,CnHaven,CnHeavy,CnHospital,CnHycon,CnItalo,CnLiteV7,CnMarketCash,CnMkt,CnRed,CnSaber,CnSwap,CnTurtle,CnUplexa,CnV7,CnV8,CnWaltz,CnWebchain,CnWow,CnXTL,Cuckaroo29,Cuckatoo31,Dedal,Equihash96,Equihash144,Equihash150,Equihash192,Equihash210,Ethash,Ethash_Blake2s,Ethash_Keccak,Exosis,Geek,Hex,HMQ1725,HSR,JHA,KeccakC,Lyra2vc0ban,Lyra2v3,Lyra2h,Lyra2z,Lyra2zz,MTP,NeoScrypt,Phi,Phi2,Polytimos,Renesis,SHA256t,SHA256q,Skunk,SonoA,Tensority,Timetravel,Throestl,Tribus,Veltor,Whirlpool,WhirlpoolX,X11evo,X16r,X16rt,X16s,X17,X20r,X21s,X22i,Xevan,Yescrypt +Algorithms_AMD = Aergo,Allium,Argon2d250,Argon2d500,Argon2d4096,Bitcore,BCD,C11,CnAlloy,CnArto,CnDark,CnFast,CnFreeHaven,CnGpu,CnHalf,CnHaven,CnHeavy,CnHospital,CnHycon,CnItalo,CnLiteV7,CnMarketCash,CnMkt,CnRed,CnSaber,CnSwap,CnTurtle,CnUplexa,CnV7,CnV8,CnWaltz,CnWebchain,CnWow,CnXTL,Cuckaroo29,Cuckatoo31,Dedal,Equihash96,Equihash144,Equihash150,Equihash192,Equihash210,Ethash,Ethash_Blake2s,Ethash_Keccak,Exosis,Geek,Hex,HMQ1725,HSR,JHA,KeccakC,Lyra2vc0ban,Lyra2v3,Lyra2h,Lyra2z,Lyra2zz,MTP,NeoScrypt,Phi,Phi2,Polytimos,Renesis,SHA256t,SHA256q,Skunk,SonoA,Tensority,Timetravel,Throestl,Tribus,Veltor,Whirlpool,WhirlpoolX,X11evo,X16r,X16rt,X16s,X17,X20r,X21s,X22i,Xevan,Yescrypt +Algorithms_CPU = Argon2ad,Argon2d250,Argon2d500,Argon2d4096,Argon2m,Binarium,CnLiteV7,CnHalf,CnFast,CnTurtle,HOdl,Lyra2h,Lyra2z330,M7M,RandomHash,Verium,Yescrypt,YescryptR8,YescryptR16,YescryptR24,YescryptR32,YesPower + +# Exclude specific miners for specific Device Groups. Accepts wildcards. example: A-OptiminerZero-1.1.0,*NSgminer* +; ExcludeMiners_AMD = +; ExcludeMiners_NVIDIA = + + + +# *** ADVANCED OPTIONS *** + +# Number of minutes to mine as a donation each day (default is 15 mins which is ~1%). Minimum is 10 mins +Donate = 15 + +# Profit recheck interval time (in seconds) for each kind of pool +# This interval recalculates and selects the most profitable algorithm +Interval_PPS = 300 +Interval_PPLS = 600 + +# Maximum Benchmarks interval time (less than 300 not recommended for GPU due to miners ramp time) +# Benchmarks will usually complete within 2-3 minutes, when the speed is stable +BenchmarkTime = 600 + +# Percent to switch miner/algo, new miner/algo only will be launched if new profit is greater than actual profit +# in specified percent (example: new miner/algo must be 10% more profitable than actual to be launched) +PercentToSwitch = 10 + +# If WatchdogHashrate is defined, miner will be marked as failed when hashrate drops by defined percentage. +# Exclude Algos like X16r, which have very high rate fluctuations +# Recommended values: 20 - 40 (%) for dedicated miners. 0 to Disable +WatchdogHashrate = 0 +WatchdogExcludeAlgos = X16r,X16rt + # [OPTIONAL] Pools profit correction factors # Usually pools revenue is overestimated, this factor allows manual correction (Profit= ReportedPoolProfit * PoolProfitFactor) # Update these values based on your experience -PoolProfitFactor_AHashPool = 0.7 PoolProfitFactor_NiceHash = 1 PoolProfitFactor_MiningPoolHub = 0.8 -PoolProfitFactor_ZPool = 0.7 -PoolProfitFactor_ZergPool = 0.7 -PoolProfitFactor_BlazePool = 0.7 -PoolProfitFactor_BsodPW = 0.7 -PoolProfitFactor_YIIMP = 0.7 -PoolProfitFactor_NLPool = 0.7 -PoolProfitFactor_BlockMasters = 0.7 -PoolProfitFactor_HashRefinery = 0.7 +PoolProfitFactor_AHashPool = 0.8 +PoolProfitFactor_ZPool = 0.8 +PoolProfitFactor_ZergPool = 0.8 +PoolProfitFactor_BlazePool = 0.8 +PoolProfitFactor_BsodPW = 0.8 +PoolProfitFactor_YIIMP = 0.8 +PoolProfitFactor_NLPool = 0.8 +PoolProfitFactor_BlockMasters = 0.8 +PoolProfitFactor_HashRefinery = 0.8 # To record mining session statistics to a CSV file set to Enabled. CSV files will be saved to Logs folder SessionStatistics = Disabled -# [Dangerous] Delayed miners closing. While new miner is starting, old one continue mining for specified seconds. May cause hangs -DelayCloseMiners = 0 - # Min number of workers in a pool to be considered as "good" -MinWorkers = 20 +MinWorkers = 30 +MinWorkers_NameOfPool = 0 -# Test pools and select only the responding ones (Disabled/Enabled). Some pools don't like this and may block your ip after several attempts +# Test pools and select only the responding ones (Disabled/Enabled). +# Some pools don't like this and may block your ip after several attempts PingPools = Disabled # This variable defines order for WhatToMine based stats virtual pool # For each coin in WTM Forager will search what real pool has this coin available, first found (in specified order) is selected. # Only pool that works at coin level are compatible, like Yiimp, Suprnova, MiningPoolHub, FairPool # WTM profit is based on instant coin exchange rate and difficulty, it's recommended use pools with autoexchange, like MiningPoolHub -WhatToMinePoolOrder = MyPools,MiningPoolHub,Suprnova,FairPool -CoinCalcPoolOrder = MyPools,MiningPoolHub,Suprnova,FairPool +PoolOrder_WhatToMine = MyPools,MiningPoolHub,Suprnova +PoolOrder_CoinCalc = MyPools,MiningPoolHub,Suprnova # Reporting mining status to https://multipoolminer.io/monitor/ # get ApiKey from the site or your BTC wallet address will be used as key MinerStatusUrl = https://multipoolminer.io/monitor/miner.php MinerStatusKey = -# Define what algorithms can be mined for each Platform Type, for an Algo can be mined must exists: 1. A pool, 2. A miner, 3. This config. -# If used, algorithm parameter from core.ps1 override this config. If Empty - All algos enabled for group -Algorithms_NVIDIA = Aergo,Allium,Bitcore,BCD,C11,CnAlloy,CnArto,CnDark,CnFast,CnFreeHaven,CnGpu,CnHalf,CnHaven,CnHeavy,CnHospital,CnHycon,CnItalo,CnLiteV7,CnMarketCash,CnMkt,CnRed,CnSaber,CnSwap,CnTurtle,CnUplexa,CnV7,CnV8,CnWaltz,CnWebchain,CnWow,CnXTL,Dedal,Equihash96,Equihash144,Equihash150,Equihash192,Equihash210,Ethash,Ethash_Blake2s,Ethash_Keccak,Exosis,Geek,Hex,HMQ1725,HSR,JHA,KeccakC,Lyra2vc0ban,Lyra2v3,Lyra2h,Lyra2z,Lyra2zz,MTP,NeoScrypt,Phi,Phi2,Polytimos,Renesis,ScryptN,SHA256t,SHA256q,Skunk,SonoA,Tensority,Timetravel,Throestl,Tribus,Veltor,Whirlpool,WhirlpoolX,X11evo,X16r,X16rt,X16s,X17,X20r,X21s,X22i,Xevan,Yescrypt -Algorithms_AMD = Aergo,Allium,Bitcore,BCD,C11,CnAlloy,CnArto,CnDark,CnFast,CnFreeHaven,CnGpu,CnHalf,CnHaven,CnHeavy,CnHospital,CnHycon,CnItalo,CnLiteV7,CnMarketCash,CnMkt,CnRed,CnSaber,CnSwap,CnTurtle,CnUplexa,CnV7,CnV8,CnWaltz,CnWebchain,CnWow,CnXTL,Dedal,Equihash96,Equihash144,Equihash150,Equihash192,Equihash210,Ethash,Ethash_Blake2s,Ethash_Keccak,Exosis,Geek,Hex,HMQ1725,HSR,JHA,KeccakC,Lyra2vc0ban,Lyra2v3,Lyra2h,Lyra2z,Lyra2zz,MTP,NeoScrypt,Phi,Phi2,Polytimos,Renesis,ScryptN,SHA256t,SHA256q,Skunk,SonoA,Tensority,Timetravel,Throestl,Tribus,Veltor,Whirlpool,WhirlpoolX,X11evo,X16r,X16rt,X16s,X17,X20r,X21s,X22i,Xevan,Yescrypt -Algorithms_CPU = Argon2ad,Argon2d250,Argon2d500,Argon2d4096,Argon2m,Binarium,CnLiteV7,CnHalf,CnFast,CnTurtle,HOdl,Lyra2h,Lyra2z330,M7M,RandomHash,Verium,Yescrypt,YescryptR8,YescryptR16,YescryptR24,YescryptR32,YesPower - -# Exclude specific miners for specific groups. Accepts wildcards. example: A-OptiminerZero-1.1.0,*NSgminer* -; ExcludeMiners_AMD = -; ExcludeMiners_NVIDIA = - # Include only specific Algos and Coins on pools. Includes are processed before Excludes, so you can include an algo and exclude a single coin on that algo ; IncludeAlgos_Zpool = Keccak ; IncludeCoins_MiningPoolHub = BitcoinGold,Maxcoin @@ -186,33 +181,3 @@ MinerWindowStyle = Minimized # Force Dynamic Miners Port. If enabled APIPort field from miner file is ignored. Must be enabled to run more than one instance of Forager ForceDynamicPorts = Disabled - -# Enable ETHlargementPill (RevB/RevA/Disabled) -# ETHlargementPill is a hashrate booster for Nvidia 1080 and 1080ti in some algos, enable if you have one of this models, disable if not -# The default is revB, but older GPUs (which tend to be 1080s) only take the revA well, that why it's needed to be specified -ETHlargementPill = Disabled - -# CUDA version for NVIDIA miners. Some miners require certain version, please set the version your drivers support -CUDAVersion = 9.2 - -# [Optional]Port for Forager API (http://localhost:port), set zero to disable API. -APIPort = 0 - -# ********************************************************************************************************** -# ******************** FARM MONITOR OPTIONS ******************** -# ******************** (only need to set to use this app to monitor all your rigs) ******************** -# ******************** (To run monitoring run start.bat / option 3) ******************** -# ********************************************************************************************************** - -# Farm Monitor addresses, indicates what rigs do you want monitor in Farm Monitor,only needs to be filled in your monitoring machine -FarmRigs = [{"IpOrLanName": "192.168.1.10", "ApiPort": "9999", "Notifications": "true"}, {"IpOrLanName": "192.168.1.20", "ApiPort": "9999", "Notifications": "true"}, {"IpOrLanName": "localhost", "ApiPort": "9999", "Notifications": "true"}] - -# Refresh interval in seconds -RefreshInterval = 15 - -# [OPTIONAL] Notification Mail and SMTPServer config: -# SMTP server password will be asked and encrypted locally first time you run (to change password delete smtp.ctr), -# this file can NOT be shared between rigs because use local encryption/decryption. -# GMAIL SMTP will not work if you have activated two pass verification -NotificationMail = zzzzzzzzzzzzz@yyy.com -SMTPServer = {"url": "smtp-mail.outlook.com", "port": 587, "user": "xxxxxxxx@outlook.com", "ssl": true} diff --git a/Core.ps1 b/Core.ps1 index b3ce682d..11964790 100644 --- a/Core.ps1 +++ b/Core.ps1 @@ -1,61 +1,32 @@ param( [Parameter(Mandatory = $false)] - [Array]$Algorithm = $null, + [Array]$Algorithm, [Parameter(Mandatory = $false)] - [Array]$PoolsName = $null, + [Array]$PoolsName, [Parameter(Mandatory = $false)] - [array]$CoinsName = $null, + [array]$CoinsName, [Parameter(Mandatory = $false)] - [String]$MiningMode = $null, + [String]$MiningMode, [Parameter(Mandatory = $false)] - [array]$GroupNames = $null, - - [Parameter(Mandatory = $false)] - [string]$PercentToSwitch = $null + [array]$GroupNames ) -##Parameters for testing, must be commented on real use - -# $MiningMode='Automatic' -# $MiningMode='Manual' - -# $PoolsName=('ahashpool','miningpoolhub','hashrefinery') -# $PoolsName='whattomine' -# $PoolsName='zergpool' -# $PoolsName='yiimp' -# $PoolsName='ahashpool' -# $PoolsName=('hashrefinery','zpool') -# $PoolsName='miningpoolhub' -# $PoolsName='zpool' -# $PoolsName='hashrefinery' -# $PoolsName='altminer' -# $PoolsName='blazepool' - -# $PoolsName="Nicehash" -# $PoolsName="Nanopool" +$Error.Clear() +Import-Module .\Include.psm1 -# $CoinsName =('bitcore','Signatum','Zcash') -# $CoinsName ='zcash' -# $Algorithm =('phi','x17') - -# $GroupNames=('rx580') - -$error.clear() -$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path -. $ScriptRoot\Include.ps1 +try {Set-WindowSize 180 50} catch {} #Start log file - -$LogPath = "$ScriptRoot\Logs\" -if (!(Test-Path -Path $LogPath)) { New-Item -Path $LogPath -ItemType directory | Out-Null } +$LogPath = ".\Logs\" +if (-not (Test-Path $LogPath)) { New-Item -Path $LogPath -ItemType directory | Out-Null } $LogName = $LogPath + "$(Get-Date -Format "yyyy-MM-dd_HH-mm-ss").log" -Start-Transcript $LogName #for start log msg -Stop-Transcript -$LogFile = [System.IO.StreamWriter]::new( $LogName, $true ) +Start-Transcript $LogName #for start log msg +Stop-Transcript | Out-Null +$global:LogFile = [System.IO.StreamWriter]::new( $LogName, $true ) $LogFile.AutoFlush = $true Clear-Files @@ -71,28 +42,27 @@ $culture.NumberFormat.NumberGroupSeparator = "," [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture $ErrorActionPreference = "Continue" -$Config = Get-Config -$Application = "Forager" -$Release = "19.02.1" -Log-Message "$Application v$Release" +$Global:Release = @{ + Application = "Forager" + Version = "19.02.1" +} +Log "$($Release.Application) v$($Release.Version)" -$Host.UI.RawUI.WindowTitle = "$Application v$Release" +$Host.UI.RawUI.WindowTitle = "$($Release.Application) v$($Release.Version)" -if ($env:CUDA_DEVICE_ORDER -ne 'PCI_BUS_ID') { setx CUDA_DEVICE_ORDER PCI_BUS_ID } #This align cuda id with nvidia-smi order +if ($env:CUDA_DEVICE_ORDER -ne 'PCI_BUS_ID') { setx CUDA_DEVICE_ORDER PCI_BUS_ID } #Align CUDA id with nvidia-smi order -if ($env:GPU_FORCE_64BIT_PTR -ne 0) { setx GPU_FORCE_64BIT_PTR 0 } #For AMD -if ($env:GPU_MAX_HEAP_SIZE -ne 100) { setx GPU_MAX_HEAP_SIZE 100 } #For AMD -if ($env:GPU_USE_SYNC_OBJECTS -ne 1) { setx GPU_USE_SYNC_OBJECTS 1 } #For AMD -if ($env:GPU_MAX_ALLOC_PERCENT -ne 100) { setx GPU_MAX_ALLOC_PERCENT 100 } #For AMD +if ($env:GPU_FORCE_64BIT_PTR -ne 0) { setx GPU_FORCE_64BIT_PTR 0 } #For AMD +if ($env:GPU_MAX_HEAP_SIZE -ne 100) { setx GPU_MAX_HEAP_SIZE 100 } #For AMD +if ($env:GPU_USE_SYNC_OBJECTS -ne 1) { setx GPU_USE_SYNC_OBJECTS 1 } #For AMD +if ($env:GPU_MAX_ALLOC_PERCENT -ne 100) { setx GPU_MAX_ALLOC_PERCENT 100 } #For AMD if ($env:GPU_SINGLE_ALLOC_PERCENT -ne 100) { setx GPU_SINGLE_ALLOC_PERCENT 100 } #For AMD -if ($env:GPU_MAX_WORKGROUP_SIZE -ne 256) { setx GPU_MAX_WORKGROUP_SIZE 256 } #For AMD +if ($env:GPU_MAX_WORKGROUP_SIZE -ne 256) { setx GPU_MAX_WORKGROUP_SIZE 256 } #For AMD -$progressPreference = 'silentlyContinue' #No progress message on web requests +$progressPreference = 'SilentlyContinue' #No progress message on web requests #$progressPreference = 'Stop' -Set-Location $ScriptRoot - #Set process priority to BelowNormal to avoid hash rate drops on systems with weak CPUs (Get-Process -Id $PID).PriorityClass = "BelowNormal" @@ -118,21 +88,20 @@ $Interval = @{ Benchmark = $null } -$Screen = $Config.StartScreen +$Global:Config = Get-Config #---Parameters checking if (@('Manual', 'Automatic', 'Automatic24h') -notcontains $MiningMode) { - Log-Message "Parameter MiningMode not valid, valid options: Manual, Automatic, Automatic24h" -Severity Warn + Log "Parameter MiningMode not valid, valid options: Manual, Automatic, Automatic24h" -Severity Warn Exit } $Params = @{ - Querymode = "info" + Querymode = "Info" PoolsFilterList = $PoolsName CoinFilterList = $CoinsName - Location = $Location + Location = $Config.Location AlgoFilterList = $Algorithm - } $PoolsChecking = Get-Pools @Params @@ -143,28 +112,27 @@ $PoolsErrors = switch ($MiningMode) { } $PoolsErrors | ForEach-Object { - Log-Message "Selected MiningMode is not valid for pool $($_.Name)" -Severity Warn + Log "$MiningMode MiningMode is not valid for pool $($_.Name)" -Severity Warn Exit } if ($MiningMode -eq 'Manual' -and ($CoinsName -split ',').Count -ne 1) { - Log-Message "On manual mode one coin must be selected" -Severity Warn + Log "On manual mode one coin must be selected" -Severity Warn Exit } if ($MiningMode -eq 'Manual' -and ($Algorithm -split ',').Count -ne 1) { - Log-Message "On manual mode one algorithm must be selected" -Severity Warn + Log "On manual mode one algorithm must be selected" -Severity Warn Exit } -#parameters backup - -$ParamAlgorithmBCK = $Algorithm -$ParamPoolsNameBCK = $PoolsName -$ParamCoinsNameBCK = $CoinsName -$ParamMiningModeBCK = $MiningMode - -try {Set-WindowSize 180 50} catch {} +#Parameters backup +$ParamsBackup = @{ + Algorithm = $Algorithm + PoolsName = $PoolsName + CoinsName = $CoinsName + MiningMode = $MiningMode +} $Interval.StartTime = Get-Date #first initialization, must be outside loop @@ -176,42 +144,19 @@ $Msg = @("Starting Parameters: " "CoinsName: " + [string]($CoinsName -join ",") "MiningMode: " + $MiningMode "GroupNames: " + [string]($GroupNames -join ",") - "PercentToSwitch: " + $PercentToSwitch ) -join ' //' -Log-Message $Msg -Severity Debug - -#Enable api -if ($config.ApiPort -gt 0) { - - Log-Message "Starting API on port $($config.ApiPort)" -Severity Debug +Log $Msg -Severity Debug - $ApiSharedFile = "$ScriptRoot\ApiShared" + [string](Get-Random -minimum 0 -maximum 99999999) + ".tmp" - $command = "-WindowStyle minimized -noExit -executionpolicy bypass -file $ScriptRoot\Includes\ApiListener.ps1 -port " + [string]$config.ApiPort + " -SharedFile $ApiSharedFile " - $APIprocess = Start-Process -FilePath "powershell.exe" -ArgumentList $command -Verb RunAs -PassThru -WindowStyle Minimized - - #open firewall port - $command = "New-NetFirewallRule -DisplayName '$Application' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $($config.ApiPort)" - Start-Process -FilePath "powershell.exe" -ArgumentList $command -Verb RunAs -WindowStyle Minimized - - $command = "New-NetFirewallRule -DisplayName '$Application' -Direction Outbound -Action Allow -Protocol TCP -LocalPort $($config.ApiPort)" - Start-Process -FilePath "powershell.exe" -ArgumentList $command -Verb RunAs -WindowStyle Minimized -} - -$Quit = $false +Start-Autoexec # Initialize MSI Afterburner -if ((Get-ConfigVariable "Afterburner") -eq "Enabled") { - . .\Includes\afterburner.ps1 +if ($Config.Afterburner) { + . .\Includes\Afterburner.ps1 } -#enable EthlargementPill - -if (@('RevA', 'RevB') -contains $config.EthlargementPill) { - Log-Message "Starting EthlargementPill" - $arg = "-" + $config.EthlargementPill - $EthPill = Start-Process -FilePath ".\Includes\OhGodAnETHlargementPill-r2.exe" -passthru -Verb RunAs -ArgumentList $arg -} +$Quit = $false +$Screen = 'Profits' #----------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------- @@ -225,126 +170,84 @@ if (@('RevA', 'RevB') -contains $config.EthlargementPill) { while ($Quit -eq $false) { - $Config = Get-Config - Log-Message ($Config | ConvertTo-Json) -Severity Debug + $Global:Config = Get-Config + Log ($Config | ConvertTo-Json) -Severity Debug - Clear-Host; $RepaintScreen = $true + Clear-Host + $RepaintScreen = $true - # Check for updates - try { - $Request = Invoke-APIRequest -Url "https://api.github.com/repos/yuzi-co/$Application/releases/latest" -Age 60 - $RemoteVersion = ($Request.tag_name -replace '[^\d.]') - $Uri = $Request.assets | Where-Object Name -eq "$Application-v$RemoteVersion.7z" | Select-Object -ExpandProperty browser_download_url - - if ([version]$RemoteVersion -gt [version]$Release) { - Log-Message "$Application is out of date. There is an updated version available at $Uri" -Severity Warn - } elseif ([version]$RemoteVersion -lt [version]$Release) { - Log-Message "$Application is pre-release version. Use at your own risk" -Severity Warn - } - } catch { - Log-Message "Failed to get $Application updates." -Severity Warn - } + Get-Updates #get mining types - $DeviceGroups = Get-MiningTypes -filter $GroupNames - - if ($null -eq $Interval.Last) { - Log-Message (Get-DevicesInformation $DeviceGroups | ConvertTo-Json) -Severity Debug - Log-Message ($DeviceGroups | ConvertTo-Json) -Severity Debug - Test-DeviceGroupsConfig $DeviceGroups + $DeviceGroupsConfig = Get-MiningTypes -Filter $GroupNames + if ($null -ne $DeviceGroups) { + $DeviceGroupsConfig | ForEach-Object { + if ($DeviceGroups.GroupName -contains $_.GroupName) { + $_.Enabled = $DeviceGroups | Where-Object GroupName -eq $_.GroupName | Select-Object -ExpandProperty Enabled -First 1 + } + } } + $DeviceGroups = $DeviceGroupsConfig + + Log (Get-DevicesInformation $DeviceGroups | ConvertTo-Json) -Severity Debug + Log ($DeviceGroups | ConvertTo-Json) -Severity Debug + Test-DeviceGroupsConfig $DeviceGroups $NumberTypesGroups = ($DeviceGroups | Measure-Object).count if ($NumberTypesGroups -gt 0) {$InitialProfitsScreenLimit = [Math]::Floor(30 / $NumberTypesGroups) - 5} #screen adjust to number of groups if ($null -eq $Interval.Last) {$ProfitsScreenLimit = $InitialProfitsScreenLimit} - Log-Message "New interval starting..." - Log-Message (Get-ComputerStats | ConvertTo-Json) -Severity Debug - - $Location = $Config.Location - - if ([string]::IsNullOrWhiteSpace($PercentToSwitch)) {$PercentToSwitch2 = [int]($Config.PercentToSwitch)} - else {$PercentToSwitch2 = [int]$PercentToSwitch} - $DelayCloseMiners = $Config.DelayCloseMiners - - $BenchmarkIntervalTime = [int]($Config.BenchmarkTime) - $LocalCurrency = $Config.LocalCurrency - if ([string]::IsNullOrWhiteSpace($LocalCurrency)) { - #for old config.ini compatibility - $LocalCurrency = switch ($Location) { - 'Europe' {"EUR"} - 'EU' {"EUR"} - 'US' {"USD"} - 'ASIA' {"USD"} - 'GB' {"GBP"} - default {"USD"} - } - } + Log "New interval starting..." $Interval.Last = $Interval.Current $Interval.LastTime = (Get-Date) - $Interval.StartTime $Interval.StartTime = Get-Date #Donation - $DonationStat = if (Test-Path -Path 'Donation.ctr') { (Get-Content -Path 'Donation.ctr') -split '_' } else { 0, 0 } - $DonationPastTime = [int]$DonationStat[0] - $DonatedTime = [int]$DonationStat[1] - $ElapsedDonationTime = [int]($DonationPastTime + $Interval.LastTime.TotalMinutes) - $ElapsedDonatedTime = [int]($DonatedTime + $Interval.LastTime.TotalMinutes) - - $ConfigDonateTime = [math]::Max([int]($Config.Donate), 10) + $DonationsFile = ".\Data\Donations.json" + $DonationStat = if (Test-Path $DonationsFile) { Get-Content $DonationsFile | ConvertFrom-Json } else { @(0, 0) } + $MiningTime = [int]($DonationStat[0] + $Interval.LastTime.TotalMinutes) + $DonatedTime = [int]($DonationStat[1] + $Interval.LastTime.TotalMinutes) #Activate or deactivate donation - if ($ElapsedDonationTime -gt 1440 -and $ConfigDonateTime -gt 0) { + if ($MiningTime -gt 24 * 60) { # donation interval $Interval.Current = "Donate" $Config.UserName = "ffwd" $Config.WorkerName = "Donate" - $CoinsWallets = @{ + $Wallets = @{ BTC = "3NoVvkGSNjPX8xBMWbP2HioWYK395wSzGL" } - $DonateInterval = ($ConfigDonateTime - $ElapsedDonatedTime) * 60 + $DonateInterval = ([math]::Max(($Config.DonateMinutes), 10) - $DonatedTime) * 60 $Algorithm = $null $PoolsName = ("NiceHash") $CoinsName = $null $MiningMode = "Automatic" - if ($ElapsedDonatedTime -ge $ConfigDonateTime) {"0_0" | Set-Content -Path 'Donation.ctr'} - else {[string]$DonationPastTime + "_" + [string]$ElapsedDonatedTime | Set-Content -Path 'Donation.ctr'} + if ($DonatedTime -ge [math]::Max(($Config.DonateMinutes), 10)) { + $DonatedTime = 0 + $DonationStat[0] = 0 + } + + @($DonationStat[0], $DonatedTime) | ConvertTo-Json | Set-Content $DonationsFile - Log-Message "Next interval you will be donating for $DonateInterval seconds, thanks for your support" + Log "Next interval you will be donating for $DonateInterval seconds, thanks for your support" } else { #NOT donation interval $Interval.Current = "Mining" + @($MiningTime, 0) | ConvertTo-Json | Set-Content $DonationsFile - $Algorithm = $ParamAlgorithmBCK - $PoolsName = $ParamPoolsNameBCK - $CoinsName = $ParamCoinsNameBCK - $MiningMode = $ParamMiningModeBCK - if (!$Config.WorkerName) {$Config.WorkerName = (Get-Culture).TextInfo.ToTitleCase(($env:COMPUTERNAME).ToLower())} - - $CoinsWallets = @{} - switch -regex -file config.ini { - "^\s*WALLET_(\w+)\s*=\s*(.*)" { - $name, $value = $matches[1..2] - $CoinsWallets[$name] = $value.Trim() - } - } - [string]$ElapsedDonationTime + "_0" | Set-Content -Path Donation.ctr - } - $Currency = $Config.Currency - $UserName = $Config.UserName - $WorkerName = $Config.WorkerName + $Algorithm = $ParamsBackup.Algorithm + $PoolsName = $ParamsBackup.PoolsName + $CoinsName = $ParamsBackup.CoinsName + $MiningMode = $ParamsBackup.MiningMode + if (-not $Config.WorkerName) {$Config.WorkerName = (Get-Culture).TextInfo.ToTitleCase(($env:COMPUTERNAME).ToLower())} - $MinerWindowStyle = $Config.MinerWindowStyle - if ([string]::IsNullOrEmpty($MinerWindowStyle)) {$MinerWindowStyle = 'Minimized'} - - $MinerStatusUrl = $Config.MinerStatusUrl - $MinerStatusKey = $Config.MinerStatusKey - if (!$MinerStatusKey -and $CoinsWallets.BTC) {$MinerStatusKey = $CoinsWallets.BTC} + $Global:Wallets = Get-Wallets + } Send-ErrorsToLog $LogFile @@ -359,117 +262,125 @@ while ($Quit -eq $false) { @(0..($_.HourEnd)) -contains (Get-Date).Hour ) ) - ) {$ElectricityCostValue = [double]$_.CostKwh} + ) { + $PowerCost = [decimal]$_.CostKwh + } } - Log-Message "Loading Pools Information..." + Log "Loading Pools Information..." #Load information about the Pools, only must read parameter passed files (not all as mph do), level is Pool-Algo-Coin do { $Params = @{ - Querymode = "core" + Querymode = "Core" PoolsFilterList = $PoolsName CoinFilterList = $CoinsName - Location = $Location + Location = $Config.Location AlgoFilterList = $Algorithm } $AllPools = Get-Pools @Params if ($AllPools.Count -eq 0) { - Log-Message "NO POOLS! Retry in 30 seconds" -Severity Warn - Log-Message "If you are mining on anonymous pool without exchage, like YIIMP, NANOPOOL or similar, you must set wallet for at least one pool coin in config.ini" -Severity Warn + Log "NO POOLS! Retry in 30 seconds" -Severity Warn + Log "If you are mining on anonymous pool without exchage, like YIIMP, NANOPOOL or similar, you must set wallet for at least one pool coin in config.ini" -Severity Warn Start-Sleep 30 } } while ($AllPools.Count -eq 0) - $AllPools | Select-Object name -unique | ForEach-Object {Log-Message "Pool $($_.Name) was responsive..."} + $AllPools | Select-Object Name -Unique | ForEach-Object {Log "Pool $($_.Name) was responsive..."} - Log-Message "Detected $($AllPools.Count) pools..." + Log "Detected $($AllPools.Count) pools..." #Filter by minworkers variable (only if there is any pool greater than minimum) - $Pools = ($AllPools | Where-Object {$_.PoolWorkers -ge $Config.MinWorkers -or $_.PoolWorkers -eq $null}) + $Pools = ($AllPools | Where-Object { + $_.PoolWorkers -eq $null -or + $_.PoolWorkers -ge $Config.MinWorkers + } + ) if ($Pools.Count -ge 1) { - Log-Message "$($Pools.Count) pools left after min workers filter..." + Log "$($Pools.Count) pools left after min workers filter..." } else { $Pools = $AllPools - Log-Message "No pools with workers greater than minimum config, filter ignored..." + Log "No pools with workers greater than minimum config, filter ignored..." } ## Select highest paying pool for each algo and check if pool is alive. - Log-Message "Select top paying pool for each algo in config" - if ($config.PingPools -eq 'Enabled') {Log-Message "Checking pool availability"} - $PoolsFiltered = $Pools | Group-Object -Property Algorithm | ForEach-Object { - $NeedPool = $false - foreach ($DeviceGroup in $DeviceGroups) { - ## Is pool algorithm defined in config? - $AlgoList = $DeviceGroup.Algorithms | ForEach-Object {$_ -split '_'} | Select-Object -Unique - if (!$AlgoList -or $AlgoList -contains $_.Name) {$NeedPool = $true} - } - if ($NeedPool) { - ## Order by price (profitability) - $_.Group | Sort-Object -Property ` - @{Expression = $(if ($MiningMode -eq 'Automatic24h') {"Price24h"} else {"Price"}); Descending = $true}, - @{Expression = "LocationPriority"; Ascending = $true} | ForEach-Object { - if ($NeedPool) { - ## test tcp connection to pool - if ($config.PingPools -ne 'Enabled' -or (Test-TCPPort -Server $_.Host -Port $_.Port -Timeout 100)) { - $NeedPool = $false - $_ ## return result - } else { - Log-Message "$($_.PoolName): $($_.Host):$($_.Port) is not responding!" -Severity Warn - } + Log "Select top paying pool for each algo in config" + if ($Config.PingPools) {Log "Checking pool availability"} + + if ($DeviceGroups | Where-Object {-not $_.Algorithms}) { + $AlgoList = $null + } else { + $AlgoList = $DeviceGroups.Algorithms | ForEach-Object {$_ -split '_'} | Select-Object -Unique + } + + $PoolsFiltered = $Pools | + Group-Object -Property Algorithm | + Where-Object {$null -eq $AlgoList -or $AlgoList -contains $_.Name} | + ForEach-Object { + $NeedPool = $true + ## Order by price (profitability) + $_.Group | Select-Object *, @{Name = "Estimate"; Expression = {if ($MiningMode -eq 'Automatic24h' -and $_.Price24h) {[decimal]$_.Price24h} else {[decimal]$_.Price}}} | + Sort-Object -Property ` + @{Expression = "Estimate"; Descending = $true}, + @{Expression = "LocationPriority"; Ascending = $true} | ForEach-Object { + if ($NeedPool) { + ## test tcp connection to pool + if (-not $Config.PingPools -or (Test-TCPPort -Server $_.Host -Port $_.Port -Timeout 100)) { + $NeedPool = $false + $_ ## return result + } else { + Log "$($_.PoolName): $($_.Host):$($_.Port) is not responding!" -Severity Warn } } } } $Pools = $PoolsFiltered - Log-Message "$($Pools.Count) pools left" + Log "$($Pools.Count) pools left" Remove-Variable PoolsFiltered #Call api to local currency conversion try { - $CDKResponse = Invoke-APIRequest -Url "https://api.coindesk.com/v1/bpi/currentprice/$LocalCurrency.json" -MaxAge 60 | + $CDKResponse = Invoke-APIRequest -Url "https://api.coindesk.com/v1/bpi/currentprice/$($Config.LocalCurrency).json" -MaxAge 60 | Select-Object -ExpandProperty BPI - $LocalBTCvalue = $CDKResponse.$LocalCurrency.rate_float - Log-Message "CoinDesk API was responsive..." + $LocalBTCvalue = $CDKResponse.$($Config.LocalCurrency).rate_float + Log "CoinDesk API was responsive..." } catch { - Log-Message "Coindesk API not responding, no local coin conversion..." -Severity Warn + Log "Coindesk API not responding, no local coin conversion..." -Severity Warn } #Load information about the Miner asociated to each Coin-Algo-Miner $Miners = @() - $MinersFolderContent = (Get-ChildItem "$ScriptRoot\Miners\*" -Include "*.json") + $MinersFolderContent = (Get-ChildItem ".\Miners\*" -Include "*.json") - Log-Message "Files in miner folder: $($MinersFolderContent.count)" -Severity Debug - Log-Message "Number of device groups: $($DeviceGroups.count)" -Severity Debug + Log "Files in miner folder: $($MinersFolderContent.count)" -Severity Debug + Log "Number of device groups: $(($DeviceGroups | Where-Object Enabled).Count)/$($DeviceGroups.Count)" -Severity Debug foreach ($MinerFile in $MinersFolderContent) { try { $Miner = $MinerFile | Get-Content | ConvertFrom-Json } catch { - Log-Message "Badly formed JSON: $MinerFile" -Severity Warn - Exit + Log "Badly formed JSON: $MinerFile" -Severity Warn + Start-Sleep -Seconds 10 + Continue } - foreach ($DeviceGroup in $DeviceGroups) { - #generate a line for each device group that has algorithm as valid - if ($Miner.Type -ne $DeviceGroup.type) { - Log-Message "$($MinerFile.pschildname) is NOT valid for $($DeviceGroup.GroupName). Skipping" -Severity Debug - Continue - } elseif ($Config.("ExcludeMiners_" + $DeviceGroup.GroupName) -and ($Config.("ExcludeMiners_" + $DeviceGroup.GroupName).split(',') | Where-Object {$MinerFile.BaseName -like $_})) { - Log-Message "$($MinerFile.pschildname) is Excluded for $($DeviceGroup.GroupName). Skipping" -Severity Debug + foreach ($DeviceGroup in ($DeviceGroups | Where-Object Type -eq $Miner.Type)) { + if ( + $Config.("ExcludeMiners_" + $DeviceGroup.GroupName) -and + ($Config.("ExcludeMiners_" + $DeviceGroup.GroupName).Split(',') | Where-Object {$MinerFile.BaseName -like $_}) + ) { + Log "$($MinerFile.BaseName) is Excluded for $($DeviceGroup.GroupName). Skipping" -Severity Debug Continue - } else { - #check group and miner types are the same - Log-Message "$($MinerFile.pschildname) is valid for $($DeviceGroup.GroupName)" -Severity Debug } + Log "$($MinerFile.BaseName) is valid for $($DeviceGroup.GroupName)" -Severity Debug foreach ($Algo in $Miner.Algorithms.PSObject.Properties) { ##AlgoName contains real name for dual and no dual miners $AlgoTmp = ($Algo.Name -split "\|")[0] - $AlgoLabel = ($Algo.Name -split ("\|"))[1] + $AlgoLabel = ($Algo.Name -split "\|")[1] $AlgoName = Get-AlgoUnifiedName (($AlgoTmp -split ("_"))[0]) $AlgoNameDual = Get-AlgoUnifiedName (($AlgoTmp -split ("_"))[1]) $Algorithms = $AlgoName + $(if ($AlgoNameDual) {"_$AlgoNameDual"}) @@ -481,14 +392,14 @@ while ($Quit -eq $false) { if ($DeviceGroup.MemoryGB -lt [int]$Matches.mem) {$SkipLabel = $true} } if ($SkipLabel) { - Log-Message "$($MinerFile.BaseName)/$Algorithms/$AlgoLabel skipped due to constraints" -Severity Debug + Log "$($MinerFile.BaseName)/$Algorithms/$AlgoLabel skipped due to constraints" -Severity Debug Continue } } - if ($Config.CUDAVersion -and $Miner.CUDA) { + if ($null -ne $Config.CUDAVersion -and $null -ne $Miner.CUDA) { if ($Miner.CUDA -gt $Config.CUDAVersion) { - Log-Message "$($MinerFile.BaseName) skipped due to CUDA version constraints" -Severity Debug + Log "$($MinerFile.BaseName) skipped due to CUDA version constraints" -Severity Debug Continue } } @@ -501,38 +412,40 @@ while ($Quit -eq $false) { # If Miner limited to pools if ($Miner.Pools -and $ExecutionContext.InvokeCommand.ExpandString($Miner.Pools) -eq $false) {Continue} - if (!$AlgoNameDual -or ($Pools | Where-Object Algorithm -eq $AlgoNameDual)) { + if (-not $AlgoNameDual -or ($Pools | Where-Object Algorithm -eq $AlgoNameDual)) { #Set flag if both Miner and Pool support SSL - $enableSSL = [bool]($Miner.SSL -and $Pool.SSL) + $EnableSSL = [bool]($Miner.SSL -and $Pool.SSL) #Replace wildcards patterns if ($Pool.PoolName -eq 'Nicehash') {$Nicehash = $true} else {$Nicehash = $false} - if ($Nicehash) { - $WorkerNameMain = $WorkerName + '-' + $DeviceGroup.GroupName #Nicehash requires alphanumeric WorkerNames + if ($Pool.PoolName -eq 'Nicehash') { + $WorkerNameMain = $Config.WorkerName + '-' + $DeviceGroup.GroupName #Nicehash requires alphanumeric WorkerNames } else { - $WorkerNameMain = $WorkerName + '_' + $DeviceGroup.GroupName + $WorkerNameMain = $Config.WorkerName + '_' + $DeviceGroup.GroupName } $PoolUser = $Pool.User -replace '#WorkerName#', $WorkerNameMain $PoolPass = $Pool.Pass -replace '#WorkerName#', $WorkerNameMain $Params = @{ - '#Protocol#' = $(if ($enableSSL) {$Pool.ProtocolSSL} else {$Pool.Protocol}) - '#Server#' = $(if ($enableSSL) {$Pool.HostSSL} else {$Pool.Host}) - '#Port#' = $(if ($enableSSL) {$Pool.PortSSL} else {$Pool.Port}) + '#AlgorithmParameters#' = $Algo.Value + '#Algorithm#' = $AlgoName + + '#Protocol#' = $(if ($EnableSSL) {$Pool.ProtocolSSL} else {$Pool.Protocol}) + '#Server#' = $(if ($EnableSSL) {$Pool.HostSSL} else {$Pool.Host}) + '#Port#' = $(if ($EnableSSL) {$Pool.PortSSL} else {$Pool.Port}) '#Login#' = $PoolUser '#Password#' = $PoolPass - '#GPUPlatform#' = $DeviceGroup.Platform - '#Algorithm#' = $AlgoName - '#AlgorithmParameters#' = $Algo.Value + '#EMail#' = $Config.EMail '#WorkerName#' = $WorkerNameMain - '#Devices#' = $DeviceGroup.Devices - '#DevicesClayMode#' = $DeviceGroup.DevicesClayMode - '#DevicesETHMode#' = $DeviceGroup.DevicesETHMode - '#DevicesNsgMode#' = $DeviceGroup.DevicesNsgMode '#EthStMode#' = $Pool.EthStMode + + '#GPUPlatform#' = $DeviceGroup.PlatformId + '#Devices#' = $DeviceGroup.Devices + '#DevicesClayMode#' = Format-DeviceList -List $DeviceGroup.Devices -Type Clay + '#DevicesETHMode#' = Format-DeviceList -List $DeviceGroup.Devices -Type Eth + '#DevicesNsgMode#' = Format-DeviceList -List $DeviceGroup.Devices -Type Nsg '#GroupName#' = $DeviceGroup.GroupName - '#EMail#' = $Config.EMail } $Arguments = $Miner.Arguments -join " " @@ -540,39 +453,35 @@ while ($Quit -eq $false) { foreach ($P in $Params.Keys) {$Arguments = $Arguments -replace $P, $Params.$P} $PatternConfigFile = $Miner.PatternConfigFile -replace '#Algorithm#', $AlgoName -replace '#GroupName#', $DeviceGroup.GroupName if ($PatternConfigFile -and (Test-Path -Path $PatternConfigFile)) { - $ConfigFileArguments = Replace-ForEachDevice (Get-Content $PatternConfigFile -raw) -Devices $DeviceGroup + $ConfigFileArguments = Edit-ForEachDevice (Get-Content $PatternConfigFile -raw) -Devices $DeviceGroup foreach ($P in $Params.Keys) {$ConfigFileArguments = $ConfigFileArguments -replace $P, $Params.$P} - } - - #select correct price by mode - $Price = $Pool.$(if ($MiningMode -eq 'Automatic24h') {"Price24h"} else {"Price"}) + } else {$ConfigFileArguments = $null} #Search for dualmining pool if ($AlgoNameDual) { #search dual pool and select correct price by mode $PoolDual = $Pools | Where-Object Algorithm -eq $AlgoNameDual | - Sort-Object @{Expression = $(if ($MiningMode -eq 'Automatic24h') {"Price24h"} else {"Price"}); Descending = $true} | + Sort-Object Estimate -Descending | Select-Object -First 1 - $PriceDual = [double]$PoolDual.$(if ($MiningMode -eq 'Automatic24h') {"Price24h"} else {"Price"}) #Set flag if both Miner and Pool support SSL - $enableDualSSL = ($Miner.SSL -and $PoolDual.SSL) + $EnableDualSSL = ($Miner.SSL -and $PoolDual.SSL) #Replace wildcards patterns if ($PoolDual.PoolName -eq 'Nicehash') { - $WorkerNameDual = $WorkerName + '-' + $DeviceGroup.GroupName + 'D' #Nicehash requires alphanumeric WorkerNames + $WorkerNameDual = $Config.WorkerName + '-' + $DeviceGroup.GroupName + 'D' #Nicehash requires alphanumeric WorkerNames } else { - $WorkerNameDual = $WorkerName + '_' + $DeviceGroup.GroupName + 'D' + $WorkerNameDual = $Config.WorkerName + '_' + $DeviceGroup.GroupName + 'D' } $PoolUserDual = $PoolDual.User -replace '#WorkerName#', $WorkerNameDual $PoolPassDual = $PoolDual.Pass -replace '#WorkerName#', $WorkerNameDual $Params = @{ - '#PortDual#' = $(if ($enableDualSSL) {$PoolDual.PortSSL} else {$PoolDual.Port}) - '#ServerDual#' = $(if ($enableDualSSL) {$PoolDual.HostSSL} else {$PoolDual.Host}) - '#ProtocolDual#' = $(if ($enableDualSSL) {$PoolDual.ProtocolSSL} else {$PoolDual.Protocol}) + '#PortDual#' = $(if ($EnableDualSSL) {$PoolDual.PortSSL} else {$PoolDual.Port}) + '#ServerDual#' = $(if ($EnableDualSSL) {$PoolDual.HostSSL} else {$PoolDual.Host}) + '#ProtocolDual#' = $(if ($EnableDualSSL) {$PoolDual.ProtocolSSL} else {$PoolDual.Protocol}) '#LoginDual#' = $PoolUserDual '#PasswordDual#' = $PoolPassDual '#AlgorithmDual#' = $AlgoNameDual @@ -585,7 +494,6 @@ while ($Quit -eq $false) { } else { $PoolDual = $null $PoolUserDual = $null - $PriceDual = 0 } ## SubMiner are variations of miner that not need to relaunch @@ -597,18 +505,21 @@ while ($Quit -eq $false) { ## look in ActiveMiners collection if we found that miner to conserve some properties and not read files $FoundMiner = $ActiveMiners | Where-Object { $_.Name -eq $MinerFile.BaseName -and - $_.Coin -eq $Pool.Info -and $_.Algorithm -eq $AlgoName -and - $_.CoinDual -eq $PoolDual.Info -and $_.AlgorithmDual -eq $AlgoNameDual -and - $_.PoolName -eq $Pool.PoolName -and - $_.PoolNameDual -eq $PoolDual.PoolName -and - $_.DeviceGroup.Id -eq $DeviceGroup.Id -and - $_.AlgoLabel -eq $AlgoLabel } + $_.AlgoLabel -eq $AlgoLabel -and + $_.Pool.PoolName -eq $Pool.PoolName -and + $_.PoolDual.PoolName -eq $PoolDual.PoolName -and + $_.Pool.Info -eq $Pool.Info -and + $_.PoolDual.Info -eq $PoolDual.Info -and + $_.DeviceGroup.Id -eq $DeviceGroup.Id + } + + if ($FoundMiner) {$FoundMiner.DeviceGroup = $DeviceGroup} $FoundSubMiner = $FoundMiner.SubMiners | Where-Object {$_.PowerLimit -eq $PowerLimit} - if (!$FoundSubMiner) { + if (-not $FoundSubMiner) { $Params = @{ Algorithm = $Algorithms MinerName = $MinerFile.BaseName @@ -631,9 +542,9 @@ while ($Quit -eq $false) { $p95Index = [math]::Ceiling($Hrs.Count * 0.95) $Hrs = $Hrs[$p5Index..$p95Index] - $PowerValue = [double]($Hrs | Measure-Object -property Power -average).average - $HashRateValue = [double]($Hrs | Measure-Object -property Speed -average).average - $HashRateValueDual = [double]($Hrs | Measure-Object -property SpeedDual -average).average + $PowerValue = [decimal]($Hrs | Measure-Object -property Power -average).average + $HashRateValue = [decimal]($Hrs | Measure-Object -property Speed -average).average + $HashRateValueDual = [decimal]($Hrs | Measure-Object -property SpeedDual -average).average } else { $PowerValue = 0 $HashRateValue = 0 @@ -641,14 +552,14 @@ while ($Quit -eq $false) { } #calculates revenue - $SubMinerRevenue = [double]($HashRateValue * $Price) - $SubMinerRevenueDual = [double]($HashRateValueDual * $PriceDual) + $SubMinerRevenue = [decimal]($HashRateValue * $Pool.Estimate) + $SubMinerRevenueDual = [decimal]($HashRateValueDual * $PoolDual.Estimate) #apply fee to revenues $MinerFee = [decimal]$ExecutionContext.InvokeCommand.ExpandString($Miner.Fee) $SubMinerRevenue *= (1 - $MinerFee) - if (!$FoundSubMiner) { + if (-not $FoundSubMiner) { $Params = @{ Algorithm = $Algorithms MinerName = $MinerFile.BaseName @@ -669,7 +580,7 @@ while ($Quit -eq $false) { FailedTimes = 0 StatsTime = [DateTime]0 } - if (!$StatsHistory) {$StatsHistory = $Stats} + if (-not $StatsHistory) {$StatsHistory = $Stats} if ($SubMiners.Count -eq 0 -or $SubMiners[0].StatsHistory.BestTimes -gt 0) { #only add a SubMiner (distinct from first if sometime first was best) @@ -683,7 +594,7 @@ while ($Quit -eq $false) { PowerAvg = $PowerValue PowerLimit = [int]$PowerLimit PowerLive = 0 - Profits = (($SubMinerRevenue + $SubMinerRevenueDual) * $localBTCvalue) - ($ElectricityCostValue * ($PowerValue * 24) / 1000) #Profit is revenue less electricity cost + Profits = (($SubMinerRevenue + $SubMinerRevenueDual) * $localBTCvalue) - ($PowerCost * ($PowerValue * 24) / 1000) #Profit is revenue less electricity cost ProfitsLive = 0 Revenue = $SubMinerRevenue RevenueDual = $SubMinerRevenueDual @@ -706,45 +617,25 @@ while ($Quit -eq $false) { AlgorithmDual = $AlgoNameDual Algorithms = $Algorithms Api = $Miner.Api - ApiPort = $(if (($DeviceGroups | Where-Object type -eq $DeviceGroup.type).Count -le 1 -and $DelayCloseMiners -eq 0 -and $config.ForceDynamicPorts -ne "Enabled") { $Miner.ApiPort }) + ApiPort = $(if (($DeviceGroups | Where-Object type -eq $DeviceGroup.type).Count -le 1 -and -not $Config.ForceDynamicPorts) { $Miner.ApiPort }) Arguments = $ExecutionContext.InvokeCommand.ExpandString($Arguments) BenchmarkArg = $ExecutionContext.InvokeCommand.ExpandString($Miner.BenchmarkArg) - Coin = $Pool.Info - CoinDual = $PoolDual.Info ConfigFileArguments = $ExecutionContext.InvokeCommand.ExpandString($ConfigFileArguments) + DeviceGroup = $DeviceGroup ExtractionPath = $(".\Bin\" + $MinerFile.BaseName + "\") GenerateConfigFile = $(if ($PatternConfigFile) {".\Bin\" + $MinerFile.BaseName + "\" + $Miner.GenerateConfigFile -replace '#GroupName#', $DeviceGroup.GroupName -replace '#Algorithm#', $AlgoName}) - DeviceGroup = $DeviceGroup - Host = $Pool.Host - Location = $Pool.Location - LocationDual = $PoolDual.Location MinerFee = $MinerFee Name = $MinerFile.BaseName NoCPUMining = $ExecutionContext.InvokeCommand.ExpandString($Miner.NoCPUMining) Path = $(".\Bin\" + $MinerFile.BaseName + "\" + $ExecutionContext.InvokeCommand.ExpandString($Miner.Path)) - PoolFee = [double]$Pool.Fee - PoolFeeDual = [double]$PoolDual.Fee - PoolName = $Pool.PoolName - PoolNameDual = $PoolDual.PoolName - PoolPrice = $(if ($MiningMode -eq 'Automatic24h') {[double]$Pool.Price24h} else {[double]$Pool.Price}) - PoolPriceDual = $(if ($MiningMode -eq 'Automatic24h') {[double]$PoolDual.Price24h} else {[double]$PoolDual.Price}) - PoolRewardType = $Pool.RewardType - PoolWorkers = $Pool.PoolWorkers - PoolWorkersDual = $PoolDual.PoolWorkers + Pool = $Pool + PoolDual = $PoolDual PrelaunchCommand = $ExecutionContext.InvokeCommand.ExpandString($Miner.PrelaunchCommand) - PrerequisitePath = $Miner.PrerequisitePath - PrerequisiteURI = $Miner.PrerequisiteURI - SubMiners = $SubMiners SHA256 = $Miner.SHA256 - Symbol = $Pool.Symbol - SymbolDual = $PoolDual.Symbol + SubMiners = $SubMiners URI = $Miner.URI UserName = $PoolUser UserNameDual = $PoolUserDual - WalletMode = $Pool.WalletMode - WalletModeDual = $PoolDual.WalletMode - WalletSymbol = $Pool.WalletSymbol - WalletSymbolDual = $PoolDual.WalletSymbol WorkerName = $WorkerNameMain WorkerNameDual = $WorkerNameDual } @@ -754,10 +645,7 @@ while ($Quit -eq $false) { } # end if types } #end foreach miner - # $Miners | ConvertTo-Json | Set-Content _miners.json - # $Pools | ConvertTo-Json | Set-Content _pools.json - - Log-Message "Miners/Pools combinations detected: $($Miners.Count)" + Log "Miners/Pools combinations detected: $($Miners.Count)" #Launch download of miners $Miners | @@ -769,23 +657,13 @@ while ($Quit -eq $false) { ForEach-Object { if (-not (Test-Path $_.Path)) {Start-Downloader -URI $_.URI -ExtractionPath $_.ExtractionPath -Path $_.Path -SHA256 $_.SHA256} } - #Launch download of prerequisites - $Miners | - Where-Object PrerequisitePath | - Select-Object PrerequisitePath, PrerequisiteURI -Unique | - ForEach-Object { - $_.PrerequisitePath = $ExecutionContext.InvokeCommand.ExpandString($_.PrerequisitePath) - if (-not (Test-Path $_.PrerequisitePath)) { - Start-Downloader -URI $_.PrerequisiteURI -Path $_.PrerequisitePath -ExtractionPath $_.PrerequisitePath - } - } Send-ErrorsToLog $LogFile #Paint no miners message $Miners = $Miners | Where-Object {Test-Path $_.Path} if ($Miners.Count -eq 0) { - Log-Message "NO MINERS! Retry in 30 seconds..." -Severity Warn + Log "NO MINERS! Retry in 30 seconds..." -Severity Warn Start-Sleep -Seconds 30 Continue } @@ -795,29 +673,26 @@ while ($Quit -eq $false) { #Search existing miners to update data $Miner = $Miners | Where-Object { $_.Name -eq $ActiveMiner.Name -and - $_.Coin -eq $ActiveMiner.Coin -and $_.Algorithm -eq $ActiveMiner.Algorithm -and - $_.CoinDual -eq $ActiveMiner.CoinDual -and $_.AlgorithmDual -eq $ActiveMiner.AlgorithmDual -and - $_.PoolName -eq $ActiveMiner.PoolName -and - $_.PoolNameDual -eq $ActiveMiner.PoolNameDual -and - $_.DeviceGroup.Id -eq $ActiveMiner.DeviceGroup.Id -and - $_.AlgoLabel -eq $ActiveMiner.AlgoLabel } + $_.AlgoLabel -eq $ActiveMiner.AlgoLabel -and + $_.Pool.PoolName -eq $ActiveMiner.Pool.PoolName -and + $_.PoolDual.PoolName -eq $ActiveMiner.PoolDual.PoolName -and + $_.Pool.Info -eq $ActiveMiner.Pool.Info -and + $_.PoolDual.Info -eq $ActiveMiner.PoolDual.Info -and + $_.DeviceGroup.Id -eq $ActiveMiner.DeviceGroup.Id + } if (($Miner | Measure-Object).count -gt 1) { - Clear-Host - Log-Message "DUPLICATE MINER $($Miner.Algorithms) in $($Miner.Name)" -Severity Warn + Log "DUPLICATE MINER $($Miner.Algorithms) in $($Miner.Name)" -Severity Warn Exit } if ($Miner) { # we found that miner $ActiveMiner.Arguments = $Miner.Arguments - $ActiveMiner.PoolPrice = $Miner.PoolPrice - $ActiveMiner.PoolPriceDual = $Miner.PoolPriceDual - $ActiveMiner.PoolFee = $Miner.PoolFee - $ActiveMiner.PoolFeeDual = $Miner.PoolFeeDual - $ActiveMiner.PoolWorkers = $Miner.PoolWorkers + $ActiveMiner.Pool = $Miner.Pool + $ActiveMiner.PoolDual = $Miner.PoolDual $ActiveMiner.IsValid = $true foreach ($SubMiner in $Miner.SubMiners) { @@ -845,16 +720,17 @@ while ($Quit -eq $false) { $ActiveMiner = $ActiveMiners | Where-Object { $_.Name -eq $Miner.Name -and - $_.Coin -eq $Miner.Coin -and $_.Algorithm -eq $Miner.Algorithm -and - $_.CoinDual -eq $Miner.CoinDual -and $_.AlgorithmDual -eq $Miner.AlgorithmDual -and - $_.PoolName -eq $Miner.PoolName -and - $_.PoolNameDual -eq $Miner.PoolNameDual -and - $_.DeviceGroup.Id -eq $Miner.DeviceGroup.Id -and - $_.AlgoLabel -eq $Miner.AlgoLabel} + $_.AlgoLabel -eq $Miner.AlgoLabel -and + $_.Pool.PoolName -eq $Miner.Pool.PoolName -and + $_.PoolDual.PoolName -eq $Miner.PoolDual.PoolName -and + $_.Pool.Info -eq $Miner.Pool.Info -and + $_.PoolDual.Info -eq $Miner.PoolDual.Info -and + $_.DeviceGroup.Id -eq $Miner.DeviceGroup.Id + } - if (!$ActiveMiner) { + if (-not $ActiveMiner) { $Miner.SubMiners | Add-Member IdF $ActiveMiners.Count $ActiveMiners += [PSCustomObject]@{ AlgoLabel = $Miner.AlgoLabel @@ -865,39 +741,22 @@ while ($Quit -eq $false) { ApiPort = $Miner.ApiPort Arguments = $Miner.Arguments BenchmarkArg = $Miner.BenchmarkArg - Coin = $Miner.Coin - CoinDual = $Miner.CoinDual ConfigFileArguments = $Miner.ConfigFileArguments - GenerateConfigFile = $Miner.GenerateConfigFile DeviceGroup = $Miner.DeviceGroup - Host = $Miner.Host + GenerateConfigFile = $Miner.GenerateConfigFile Id = $ActiveMiners.Count IsValid = $true - Location = $Miner.Location - LocationDual = $Miner.LocationDual MinerFee = $Miner.MinerFee Name = $Miner.Name NoCPUMining = $Miner.NoCPUMining Path = Convert-Path $Miner.Path - PoolFee = $Miner.PoolFee - PoolFeeDual = $Miner.PoolFeeDual - PoolName = $Miner.PoolName - PoolNameDual = $Miner.PoolNameDual - PoolPrice = $Miner.PoolPrice - PoolPriceDual = $Miner.PoolPriceDual - PoolWorkers = $Miner.PoolWorkers - PoolHashRate = $null - PoolHashRateDual = $null - PoolRewardType = $Miner.PoolRewardType + Pool = $Miner.Pool + PoolDual = $Miner.PoolDual PrelaunchCommand = $Miner.PrelaunchCommand Process = $null SubMiners = $Miner.SubMiners - Symbol = $Miner.Symbol - SymbolDual = $Miner.SymbolDual UserName = $Miner.UserName UserNameDual = $Miner.UserNameDual - WalletMode = $Miner.WalletMode - WalletSymbol = $Miner.WalletSymbol WorkerName = $Miner.WorkerName WorkerNameDual = $Miner.WorkerNameDual } @@ -908,12 +767,12 @@ while ($Quit -eq $false) { $ActiveMiners.SubMiners | Where-Object {$_.Status -eq 'Failed' -and $_.Stats.LastTimeActive -lt (Get-Date).AddHours(-4)} | ForEach-Object { $_.Status = 'Idle' $_.Stats.FailedTimes = 0 - Log-Message "Reset failed miner status: $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithms)" + Log "Reset failed miner status: $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithms)" } - Log-Message "Active Miners-pools: $($ActiveMiners.Count)" + Log "Active Miners-pools: $($ActiveMiners.Count)" Send-ErrorsToLog $LogFile - Log-Message "Pending benchmarks: $(($ActiveMiners | Where-Object IsValid | Select-Object -ExpandProperty SubMiners | Where-Object NeedBenchmark | Select-Object -ExpandProperty Id).Count)..." + Log "Pending benchmarks: $(($ActiveMiners | Where-Object IsValid | Select-Object -ExpandProperty SubMiners | Where-Object NeedBenchmark | Select-Object -ExpandProperty Id).Count)..." $Msg = ($ActiveMiners.SubMiners | ForEach-Object { "$($_.IdF)-$($_.Id), " + @@ -923,15 +782,15 @@ while ($Quit -eq $false) { "$($_.Status), " + "$($ActiveMiners[$_.IdF].Name), " + "$($ActiveMiners[$_.IdF].Algorithms), " + - "$($ActiveMiners[$_.IdF].Coin), " + + "$($ActiveMiners[$_.IdF].Pool.Info), " + "$($ActiveMiners[$_.IdF].Process.Id)" }) | ConvertTo-Json - Log-Message $Msg -Severity Debug + Log $Msg -Severity Debug $BestLastMiners = $ActiveMiners.SubMiners | Where-Object {@("Running", "PendingCancellation") -contains $_.Status} ## Select miners that need Benchmark, or if running in Manual mode, or highest Profit above zero. - $BestNowCandidates = $ActiveMiners | Where-Object {$_.IsValid -and $_.UserName} | + $BestNowCandidates = $ActiveMiners | Where-Object {$_.IsValid -and $_.UserName -and $_.DeviceGroup.Enabled} | Group-Object {$_.DeviceGroup.GroupName} | ForEach-Object { $_.Group.Subminers | Where-Object { $_.Status -ne 'Failed' -and @@ -939,7 +798,7 @@ while ($Quit -eq $false) { $_.NeedBenchmark -or $MiningMode -eq "Manual" -or $Interval.Current -eq "Donate" -or - $_.Profits -gt $Config.('MinProfit_' + $DeviceGroup.GroupName) -or + $_.Profits -gt $DeviceGroup.MinProfit -or -not $LocalBTCvalue -gt 0 ) } | Sort-Object -Descending NeedBenchmark, {$(if ($MiningMode -eq "Manual") {$_.HashRate} elseif ($LocalBTCvalue) {$_.Profits} else {$_.Revenue + $_.RevenueDual})}, {$ActiveMiners[$_.IdF].PoolPrice}, {$ActiveMiners[$_.IdF].PoolPriceDual}, PowerLimit @@ -962,10 +821,10 @@ while ($Quit -eq $false) { if ($AltBestNowMiners.NeedBenchmark -contains $true -or ($AltBestNowProfits -gt $BestNowProfits -and $BestNowMiners.NeedBenchmark -notcontains $true)) { $BestNowMiners = $AltBestNowMiners - Log-Message "Skipping miners that prevents CPU mining" -Severity Warn + Log "Skipping miners that prevent CPU mining" -Severity Warn } else { $BestNowMiners = $BestNowMiners | Where-Object {$ActiveMiners[$_.IdF].DeviceGroup.Type -ne 'CPU'} - Log-Message "Miner prevents CPU mining. Will not mine on CPU" -Severity Warn + Log "Miner prevents CPU mining. Will not mine on CPU" -Severity Warn } } @@ -981,25 +840,25 @@ while ($Quit -eq $false) { $BestLastLogMsg = $( "$($ActiveMiners[$BestLast.IdF].Name)/" + "$($ActiveMiners[$BestLast.IdF].Algorithms)/" + - "$($ActiveMiners[$BestLast.IdF].Coin)" + - "$(if ($ActiveMiners[$BestLast.IdF].CoinDual) { '_' + $ActiveMiners[$BestLast.IdF].CoinDual}) " + + "$($ActiveMiners[$BestLast.IdF].Pool.Info)" + + "$(if ($ActiveMiners[$BestLast.IdF].PoolDual.Info) { '_' + $ActiveMiners[$BestLast.IdF].PoolDual.Info}) " + "with Power Limit $($BestLast.PowerLimit) " + "(id $($BestLast.IdF)-$($BestLast.Id)) " + "for group $($DeviceGroup.GroupName)") # cancel miner if current pool workers below MinWorkers if ( - $ActiveMiners[$BestLast.IdF].PoolWorkers -ne $null -and - $ActiveMiners[$BestLast.IdF].PoolWorkers -le $config.MinWorkers + $null -ne $ActiveMiners[$BestLast.IdF].PoolWorkers -and + $ActiveMiners[$BestLast.IdF].PoolWorkers -le $Config.MinWorkers ) { $BestLast.Status = 'PendingCancellation' - Log-Message "Cancelling miner due to low worker count" + Log "Cancelling miner due to low worker count" } } else { $ProfitLast = 0 } - if ($BestLast -and $config.SessionStatistics -eq 'Enabled') { + if ($BestLast -and $Config.SessionStatistics) { $BestLast | Select-Object -Property ` @{Name = "Date"; Expression = {Get-Date -f "yyyy-MM-dd"}}, @{Name = "Time"; Expression = {Get-Date -f "HH:mm:ss"}}, @@ -1008,10 +867,10 @@ while ($Quit -eq $false) { @{Name = "Algorithm"; Expression = {$ActiveMiners[$_.IdF].Algorithm}}, @{Name = "AlgorithmDual"; Expression = {$ActiveMiners[$_.IdF].AlgorithmDual}}, @{Name = "AlgoLabel"; Expression = {$ActiveMiners[$_.IdF].AlgoLabel}}, - @{Name = "Coin"; Expression = {$ActiveMiners[$_.IdF].Coin}}, - @{Name = "CoinDual"; Expression = {$ActiveMiners[$_.IdF].CoinDual}}, - @{Name = "PoolName"; Expression = {$ActiveMiners[$_.IdF].PoolName}}, - @{Name = "PoolNameDual"; Expression = {$ActiveMiners[$_.IdF].PoolNameDual}}, + @{Name = "Coin"; Expression = {$ActiveMiners[$_.IdF].Pool.Info}}, + @{Name = "CoinDual"; Expression = {$ActiveMiners[$_.IdF].PoolDual.Info}}, + @{Name = "PoolName"; Expression = {$ActiveMiners[$_.IdF].Pool.PoolName}}, + @{Name = "PoolNameDual"; Expression = {$ActiveMiners[$_.IdF].PoolDual.PoolName}}, @{Name = "PowerLimit"; Expression = {$_.PowerLimit}}, @{Name = "HashRate"; Expression = {[decimal]$_.HashRate}}, @{Name = "HashRateDual"; Expression = {[decimal]$_.HashRateDual}}, @@ -1028,7 +887,7 @@ while ($Quit -eq $false) { if ($BestLast.Status -eq 'PendingCancellation') { if (($ActiveMiners[$BestLast.IdF].SubMiners.Stats.FailedTimes | Measure-Object -sum).sum -ge 3) { $ActiveMiners[$BestLast.IdF].SubMiners | ForEach-Object {$_.Status = 'Failed'} - Log-Message "Detected more than 3 fails, cancelling combination for $BestNowLogMsg" -Severity Warn + Log "Detected more than 3 fails, cancelling combination for $BestNowLogMsg" -Severity Warn } } @@ -1039,8 +898,8 @@ while ($Quit -eq $false) { $BestNowLogMsg = $( "$($ActiveMiners[$BestNow.IdF].Name)/" + "$($ActiveMiners[$BestNow.IdF].Algorithms)/" + - "$($ActiveMiners[$BestNow.IdF].Coin)" + - "$(if ($ActiveMiners[$BestNow.IdF].CoinDual) { '_' + $ActiveMiners[$BestNow.IdF].CoinDual}) " + + "$($ActiveMiners[$BestNow.IdF].Pool.Info)" + + "$(if ($ActiveMiners[$BestNow.IdF].PoolDual.Info) { '_' + $ActiveMiners[$BestNow.IdF].PoolDual.Info}) " + "with Power Limit $($BestNow.PowerLimit) " + "(id $($BestNow.IdF)-$($BestNow.Id))" "for group $($DeviceGroup.GroupName)") @@ -1053,9 +912,9 @@ while ($Quit -eq $false) { $ActiveMiners[$BestNow.IdF].SubMiners[$BestNow.Id].StatsHistory.BestTimes++ } - Log-Message "$BestNowLogMsg is the best combination for device group, last was $BestLastLogMsg" + Log "$BestNowLogMsg is the best combination for device group, last was $BestLastLogMsg" } else { - Log-Message "No valid candidate for device group $($DeviceGroup.GroupName)" -Severity Warn + Log "No valid candidate for device group $($DeviceGroup.GroupName)" -Severity Warn # Continue } @@ -1074,7 +933,7 @@ while ($Quit -eq $false) { -not $ActiveMiners[$BestLast.IdF].IsValid -or $BestNow.NeedBenchmark -or @('PendingCancellation', 'Failed') -contains $BestLast.Status -or - (@('Running') -contains $BestLast.Status -and $ProfitNow -gt ($ProfitLast * (1 + ($PercentToSwitch2 / 100)))) -or + (@('Running') -contains $BestLast.Status -and $ProfitNow -gt ($ProfitLast * (1 + ($Config.PercentToSwitch / 100)))) -or (($ActiveMiners[$BestLast.IdF].NoCPUMining -or $ActiveMiners[$BestNow.IdF].NoCPUMining) -and $BestLast -ne $BestNow) ) { #Must launch other miner and/or stop actual @@ -1086,24 +945,8 @@ while ($Quit -eq $false) { $ActiveMiners[$BestLast.IdF].Process -and $ActiveMiners[$BestLast.IdF].Process.Id -gt 0 ) { - Log-Message "Killing in $DelayCloseMiners sec. $BestLastLogMsg with system process id $($ActiveMiners[$BestLast.IdF].Process.Id)" - if ( - $DelayCloseMiners -eq 0 -or - $BestNow.NeedBenchmark -or - @('PendingCancellation', 'Failed') -contains $BestLast.Status - ) { - #immediate kill - Exit-Process $ActiveMiners[$BestLast.IdF].Process - } else { - #delayed kill - $Code = { - param($Process, $DelaySeconds) - Start-Sleep -Seconds $DelaySeconds - $Process.CloseMainWindow() | Out-Null - Stop-Process $Process.Id -force -wa SilentlyContinue -ea SilentlyContinue - } - Start-Job -ScriptBlock $Code -ArgumentList ($ActiveMiners[$BestLast.IdF].Process), $DelayCloseMiners - } + Log "Stopping miner $BestLastLogMsg with system process id $($ActiveMiners[$BestLast.IdF].Process.Id)" + Exit-Process $ActiveMiners[$BestLast.IdF].Process } $ActiveMiners[$BestLast.IdF].Process = $null @@ -1163,7 +1006,7 @@ while ($Quit -eq $false) { } $CommonParams = @{ WorkingDirectory = Split-Path $ActiveMiners[$BestNow.IdF].Path - MinerWindowStyle = $MinerWindowStyle + MinerWindowStyle = $Config.MinerWindowStyle Priority = if ($ActiveMiners[$BestNow.IdF].DeviceGroup.Type -eq "CPU") { -2 } else { 0 } } $ActiveMiners[$BestNow.IdF].Process = Start-SubProcess @ProcessParams @CommonParams @@ -1174,14 +1017,14 @@ while ($Quit -eq $false) { $ActiveMiners[$BestNow.IdF].SubMiners[$BestNow.Id].Stats.StatsTime = Get-Date $ActiveMiners[$BestNow.IdF].SubMiners[$BestNow.Id].StatsHistory.LastTimeActive = Get-Date $ActiveMiners[$BestNow.IdF].SubMiners[$BestNow.Id].TimeSinceStartInterval = [TimeSpan]0 - Log-Message "Started System process Id $($ActiveMiners[$BestNow.IdF].Process.Id) for $BestNowLogMsg --> $($ActiveMiners[$BestNow.IdF].Path) $($ActiveMiners[$BestNow.IdF].Arguments)" -Severity Debug + Log "Started System process Id $($ActiveMiners[$BestNow.IdF].Process.Id) for $BestNowLogMsg --> $($ActiveMiners[$BestNow.IdF].Path) $($ActiveMiners[$BestNow.IdF].Arguments)" -Severity Debug } } else { #Must mantain last miner by switch $ActiveMiners[$BestLast.IdF].SubMiners[$BestLast.Id].Best = $true if ($ProfitLast -lt $ProfitNow) { $ActiveMiners[$BestLast.IdF].SubMiners[$BestLast.Id].BestBySwitch = "*" - Log-Message "$BestNowLogMsg Continue mining due to PercentToSwitch value" + Log "$BestNowLogMsg Continue mining due to PercentToSwitch value" } } } @@ -1202,16 +1045,16 @@ while ($Quit -eq $false) { if ($ActiveMiners | Where-Object IsValid | Select-Object -ExpandProperty Subminers | Where-Object {$_.NeedBenchmark -and $_.Status -ne 'Failed'}) {$Interval.Benchmark = $true} else {$Interval.Benchmark = $false} if ($Interval.Current -eq "Donate") { $Interval.Duration = $DonateInterval } - elseif ($Interval.Benchmark) { $Interval.Duration = $BenchmarkIntervalTime } + elseif ($Interval.Benchmark) { $Interval.Duration = $Config.BenchmarkTime } else { $Interval.Duration = $ActiveMiners.SubMiners | Where-Object Status -eq 'Running' | Select-Object -ExpandProperty IdF | ForEach-Object { - $PoolInterval = $Config.("INTERVAL_" + $ActiveMiners[$_].PoolRewardType) - Log-Message "Interval for pool $($ActiveMiners[$_].PoolName) is $PoolInterval" -Severity Debug + $PoolInterval = $Config.("Interval_" + $ActiveMiners[$_].Pool.RewardType) + Log "Interval for pool $($ActiveMiners[$_].Pool.PoolName) is $PoolInterval" -Severity Debug $PoolInterval # Return value } | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum } if (-not $Interval.Duration) {$Interval.Duration = 60} # when no best miners available retry every minute - Log-Message "Next interval: $($Interval.Duration)" + Log "Next interval: $($Interval.Duration)" $FirstLoopExecution = $true $LoopStartTime = Get-Date @@ -1220,7 +1063,8 @@ while ($Quit -eq $false) { $SwitchLoop = 0 $ActivityAverages = @() - Clear-Host; $RepaintScreen = $true + Clear-Host + $RepaintScreen = $true while ($Host.UI.RawUI.KeyAvailable) {$Host.UI.RawUI.FlushInputBuffer()} #keyb buffer flush @@ -1240,7 +1084,7 @@ while ($Quit -eq $false) { $ExitLoop = $false - if ($Config.HardwareMonitoring -ne 'Disabled') { + if ($Config.HardwareMonitoring) { $Devices = Get-DevicesInformation $DeviceGroups } else { $Devices = $null @@ -1251,7 +1095,10 @@ while ($Quit -eq $false) { #Check Live Speed and record benchmark if necessary $ActiveMiners.SubMiners | Where-Object Best | ForEach-Object { - if ($FirstLoopExecution -and $_.NeedBenchmark) {$_.Stats.BenchmarkedTimes++; $_.StatsHistory.BenchmarkedTimes++} + if ($FirstLoopExecution -and $_.NeedBenchmark) { + $_.Stats.BenchmarkedTimes++ + $_.StatsHistory.BenchmarkedTimes++ + } $_.SpeedLive = 0 $_.SpeedLiveDual = 0 $_.ProfitsLive = 0 @@ -1262,22 +1109,22 @@ while ($Quit -eq $false) { $Miner_HashRates = Get-LiveHashRate -Miner $ActiveMiners[$_.IdF] if ($Miner_HashRates) { - $_.SpeedLive = [double]($Miner_HashRates[0]) - $_.SpeedLiveDual = [double]($Miner_HashRates[1]) - $_.RevenueLive = $_.SpeedLive * $ActiveMiners[$_.IdF].PoolPrice - $_.RevenueLiveDual = $_.SpeedLiveDual * $ActiveMiners[$_.IdF].PoolPriceDual + $_.SpeedLive = [decimal]($Miner_HashRates[0]) + $_.SpeedLiveDual = [decimal]($Miner_HashRates[1]) + $_.RevenueLive = $_.SpeedLive * $ActiveMiners[$_.IdF].Pool.Estimate + $_.RevenueLiveDual = $_.SpeedLiveDual * $ActiveMiners[$_.IdF].PoolDual.Estimate $_.ProfitsLive = ($_.RevenueLive * (1 - $ActiveMiners[$_.IdF].MinerFee) + $_.RevenueLiveDual) * $LocalBTCvalue - $_.PowerLive = ($Devices | Where-Object group -eq ($ActiveMiners[$_.IdF].DeviceGroup.GroupName) | Measure-Object -property PowerDraw -sum).sum - if ($_.PowerLive) { $_.ProfitsLive -= ($ElectricityCostValue * ($_.PowerLive * 24) / 1000) } + $_.PowerLive = ($Devices | Where-Object Group -eq ($ActiveMiners[$_.IdF].DeviceGroup.GroupName) | Measure-Object -Property PowerDraw -sum).sum + if ($_.PowerLive) { $_.ProfitsLive -= ($PowerCost * ($_.PowerLive * 24) / 1000) } $_.TimeSinceStartInterval = (Get-Date) - $_.Stats.LastTimeActive $TimeSinceStartInterval = [int]$_.TimeSinceStartInterval.TotalSeconds if ( $_.SpeedLive -and - ($_.SpeedLiveDual -or !$ActiveMiners[$_.IdF].AlgorithmDual) + ($_.SpeedLiveDual -or -not $ActiveMiners[$_.IdF].AlgorithmDual) ) { if ($_.Stats.StatsTime) { $_.Stats.ActiveTime += ((Get-Date) - $_.Stats.StatsTime).TotalSeconds } $_.Stats.StatsTime = Get-Date @@ -1288,17 +1135,13 @@ while ($Quit -eq $false) { #for avoid miners peaks recording $_.SpeedReads += [PSCustomObject]@{ - Speed = $_.SpeedLive - SpeedDual = $_.SpeedLiveDual - Activity = ($Devices | Where-Object group -eq ($ActiveMiners[$_.IdF].DeviceGroup.GroupName) | Measure-Object -property Utilization -average).average - Power = $_.PowerLive - Date = (Get-Date).DateTime - Benchmarking = $_.NeedBenchmark - TimeSinceStartInterval = $TimeSinceStartInterval - BenchmarkIntervalTime = $BenchmarkIntervalTime + Speed = [decimal]$_.SpeedLive + SpeedDual = [decimal]$_.SpeedLiveDual + Power = [int]$_.PowerLive + Date = (Get-Date).DateTime } } - if ($_.SpeedReads.Count -gt 2000) { + if ($_.SpeedReads.Count -gt 100) { # Remove 10 percent of lowest and highest rate samples which may skew the average $_.SpeedReads = $_.SpeedReads | Sort-Object Speed $p5Index = [math]::Ceiling($_.SpeedReads.Count * 0.05) @@ -1309,9 +1152,9 @@ while ($Quit -eq $false) { $_.SpeedReads = $_.SpeedReads[$p5Index..$p95Index] | Sort-Object Date } - if (($Config.LiveStatsUpdate) -eq "Enabled" -or $_.NeedBenchmark) { + if ($_.NeedBenchmark) { - if ($_.SpeedReads.Count -gt 20 -and $_.NeedBenchmark) { + if ($_.SpeedReads.Count -gt 20) { ### If average of last 2 periods is within SpeedDelta, we can stop benchmarking $SpeedDelta = 0.01 $pIndex = [math]::Ceiling($_.SpeedReads.Count * 0.1) @@ -1359,7 +1202,7 @@ while ($Quit -eq $false) { $ActivityAverages = $ActivityAverages[($ActivityAverages.Count - 20)..($ActivityAverages.Count - 1)] $ActivityAverage = ($ActivityAverages | Where-Object DeviceGroup -eq $ActiveMiners[$_.IdF].DeviceGroup.GroupName | Measure-Object -property Average -maximum).maximum $ActivityDeviceCount = ($ActivityAverages | Where-Object DeviceGroup -eq $ActiveMiners[$_.IdF].DeviceGroup.GroupName | Measure-Object -property NumberOfDevices -maximum).maximum - # Log-Message "Last 20 reads maximum Device activity is $ActivityAverage for DeviceGroup $($ActiveMiners[$_.IdF].DeviceGroup.GroupName)" -Severity Debug + # Log "Last 20 reads maximum Device activity is $ActivityAverage for DeviceGroup $($ActiveMiners[$_.IdF].DeviceGroup.GroupName)" -Severity Debug } else { $ActivityAverage = 100 } #only want watchdog works with at least 20 reads } ## HashRate Watchdog @@ -1379,7 +1222,7 @@ while ($Quit -eq $false) { # Remove failing SpeedReads from statistics to prevent average skewing $_.SpeedReads = $_.SpeedReads[0..($_.SpeedReads.count - 10)] $WatchdogHashRateFail = $true - Log-Message "Detected low hashrate $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithm) : $(ConvertTo-Hash $AvgCurr) vs $(ConvertTo-Hash $_.HashRate)" -Severity Warn + Log "Detected low hashrate $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithm) : $(ConvertTo-Hash $AvgCurr) vs $(ConvertTo-Hash $_.HashRate)" -Severity Warn } } @@ -1393,14 +1236,14 @@ while ($Quit -eq $false) { $_.Status = "PendingCancellation" $_.Stats.FailedTimes++ $_.StatsHistory.FailedTimes++ - Log-Message "Detected miner error $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithm) (id $($_.IdF)-$($_.Id)) --> $($ActiveMiners[$_.IdF].Path) $($ActiveMiners[$_.IdF].Arguments)" -Severity Warn + Log "Detected miner error $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithm) (id $($_.IdF)-$($_.Id)) --> $($ActiveMiners[$_.IdF].Path) $($ActiveMiners[$_.IdF].Arguments)" -Severity Warn } } #End For each ############################################################# if ($Interval.Benchmark -and ($ActiveMiners | Where-Object IsValid | Select-Object -ExpandProperty SubMiners | Where-Object {$_.NeedBenchmark -and $_.Best}).Count -eq 0) { - Log-Message "Benchmark completed early" + Log "Benchmark completed early" $ExitLoop = $true } @@ -1409,67 +1252,109 @@ while ($Quit -eq $false) { $TimeToNextIntervalSeconds = [int]$TimeToNextInterval.TotalSeconds if ($TimeToNextIntervalSeconds -lt 0) {$TimeToNextIntervalSeconds = 0} - Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 31) 2 - " | Next Interval: $TimeToNextIntervalSeconds secs..." | Out-Host + if ($RepaintScreen) {Clear-Host} + Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 28) 1 + Write-Color "{white}| Next Interval: {green}$TimeToNextIntervalSeconds{white} sec." Set-ConsolePosition 0 0 #display header - Print-HorizontalLine "$Application $Release" - Print-HorizontalLine - " (E)nd Interval (P)rofits (C)urrent (H)istory (W)allets (S)tats (Q)uit" | Out-Host + Out-HorizontalLine + Write-Color @( + " {green}$($Release.Application) $($Release.Version)" + " {white}|" + " {green}E{white}nd Interval" + " {green}R{white}eset Failed" + " {green}P{white}rofits" + " {green}C{white}urrent" + " {green}H{white}istory" + " {green}W{white}allets" + " {green}S{white}tats" + " {white}|" + " {green}Q{white}uit" + " {green}$([string[]]$DeviceGroups.Id -join '/'){white} Group toggle" + ) -join " " #display donation message - if ($CurrentInterval -eq "Donate") {" THIS INTERVAL YOU ARE DONATING, YOU CAN INCREASE OR DECREASE DONATION ON config.ini, THANK YOU FOR YOUR SUPPORT !!!!"} + if ($CurrentInterval -eq "Donate") {" This interval you are donating, You can increate or decrease donation in config.ini. Thank you for your support!"} #write speed - Log-Message ($ActiveMiners | Where-Object Best | Select-Object id, process.Id, GroupName, name, poolname, Algorithm, AlgorithmDual, SpeedLive, ProfitsLive, location, port, arguments | ConvertTo-Json) -Severity Debug + Log ($ActiveMiners | Where-Object Best | Select-Object Id, Process.Id, GroupName, Name, Pool.PoolName, PoolDual.PoolName, Algorithm, AlgorithmDual, SpeedLive, ProfitsLive, Pool.Location, Port, Arguments | ConvertTo-Json) -Severity Debug #get pool reported speed (1 or each 10 executions to not saturate pool) if ($SwitchLoop -eq 0) { - $CurrentAlgos = ($ActiveMiners.SubMiners | Where-Object Best | ForEach-Object {$ActiveMiners[$_.IdF].Symbol + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"_$($ActiveMiners[$_.IdF].SymbolDual)"})}) -join '/' + $CurrentAlgos = ( + $ActiveMiners.SubMiners | + Where-Object Best | + ForEach-Object { + $ActiveMiners[$_.IdF].Pool.Symbol + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"_$($ActiveMiners[$_.IdF].PoolDual.Symbol)"}) + } + ) -join '/' $RunTime = $(Get-Date) - $(Get-Process -Pid $Global:PID | Select-Object -ExpandProperty StartTime) $Host.UI.RawUI.WindowTitle = $(if ($RunTime.TotalDays -lt 1) {"{0:hh\:mm}" -f $RunTime} else {"{0:dd\d\ hh\:mm}" -f $RunTime}) + " : " + $CurrentAlgos # Report stats - if ($MinerStatusURL -and $MinerStatusKey) { & .\Includes\ReportStatus.ps1 -Key $MinerStatusKey -WorkerName $WorkerName -ActiveMiners $ActiveMiners -MinerStatusURL $MinerStatusURL } + if ($Config.MinerStatusURL -and $Config.MinerStatusKey) { + $Params = @{ + Key = $Config.MinerStatusKey + WorkerName = $Config.WorkerName + ActiveMiners = $ActiveMiners + MinerStatusURL = $Config.MinerStatusURL + } + & .\Includes\ReportStatus.ps1 @Params + } #To get pool speed - $PoolsSpeed = @() $Candidates = ($ActiveMiners.SubMiners | Where-Object Best | Select-Object IdF).IdF - $ActiveMiners | Where-Object {$Candidates -contains $_.Id} | Select-Object PoolName, UserName, WalletSymbol, Coin, WorkerName -unique | ForEach-Object { - $Info = [PSCustomObject]@{ - User = $_.UserName - PoolName = $_.PoolName - ApiKey = $Config.("APIKEY_" + $_.PoolName) - Symbol = $_.WalletSymbol - Coin = $_.Coin - WorkerName = $_.WorkerName - } - $PoolsSpeed += Get-Pools -Querymode "speed" -PoolsFilterList $_.PoolName -Info $Info - } - - #Dual miners - $ActiveMiners | Where-Object {$Candidates -contains $_.Id -and $_.PoolNameDual} | Select-Object PoolNameDual, UserNameDual, WalletSymbol, CoinDual, WorkerName -unique | ForEach-Object { - $Info = [PSCustomObject]@{ - User = $_.UserNameDual - PoolName = $_.PoolNameDual - ApiKey = $Config.("APIKEY_" + $_.PoolNameDual) - Symbol = $_.WalletSymbol - Coin = $_.CoinDual - WorkerName = $_.WorkerNameDual + $PoolsSpeed = @( + @( + $ActiveMiners | + Where-Object {$Candidates -contains $_.Id} | + Select-Object @{Name = "PoolName"; Expression = {$_.Pool.PoolName}}, + @{Name = "WalletSymbol"; Expression = {$_.Pool.WalletSymbol}}, + @{Name = "Coin"; Expression = {$_.Pool.Info}}, + UserName, WorkerName -Unique + + #Dual miners + $ActiveMiners | + Where-Object {$_.PoolDual.PoolName -and $Candidates -contains $_.Id} | + Select-Object @{Name = "PoolName"; Expression = {$_.PoolDual.PoolName}}, + @{Name = "WalletSymbol"; Expression = {$_.PoolDual.WalletSymbol}}, + @{Name = "Coin"; Expression = {$_.PoolDual.Info}}, + UserNameDual, WorkerName -Unique + + ) | Foreach-Object { + [PSCustomObject]@{ + User = $_.UserName + PoolName = $_.PoolName + ApiKey = $PoolConfig.($_.PoolName).ApiKey + Symbol = $_.WalletSymbol + Coin = $_.Coin + WorkerName = $_.WorkerName + } } - $PoolsSpeed += Get-Pools -Querymode "speed" -PoolsFilterList $_.PoolNameDual -Info $Info - } + ) | ForEach-Object { Get-Pools -Querymode "Speed" -PoolsFilterList $_.PoolName -Info $_ } foreach ($Candidate in $Candidates) { - $Me = $PoolsSpeed | Where-Object {$_.PoolName -eq $ActiveMiners[$Candidate].PoolName -and $_.WorkerName -eq $ActiveMiners[$Candidate].WorkerName } | Select-Object HashRate, PoolName, WorkerName -first 1 - $ActiveMiners[$Candidate].PoolHashRate = $Me.HashRate + $Me = $PoolsSpeed | Where-Object { $_.PoolName -eq $ActiveMiners[$Candidate].Pool.PoolName -and $_.WorkerName -eq $ActiveMiners[$Candidate].WorkerName } + if ($Me) { + if ($null -eq $ActiveMiners[$Candidate].Pool.HashRate) { + $ActiveMiners[$Candidate].Pool | Add-Member HashRate ($Me.HashRate | Measure-Object -Maximum).Maximum -Force + } else { + $ActiveMiners[$Candidate].Pool.HashRate = ($Me.HashRate | Measure-Object -Maximum).Maximum + } + } - $MeDual = $PoolsSpeed | Where-Object {$_.PoolName -eq $ActiveMiners[$Candidate].PoolNameDual -and $_.WorkerName -eq $ActiveMiners[$Candidate].WorkerNameDual} | Select-Object HashRate, PoolName, WorkerName -first 1 - $ActiveMiners[$Candidate].PoolHashRateDual = $MeDual.HashRate + $MeDual = $PoolsSpeed | Where-Object { $_.PoolName -eq $ActiveMiners[$Candidate].PoolDual.PoolName -and $_.WorkerName -eq $ActiveMiners[$Candidate].WorkerNameDual } + if ($MeDual) { + if ($null -eq $ActiveMiners[$Candidate].PoolDual.HashRate) { + $ActiveMiners[$Candidate].PoolDual | Add-Member HashRate ($MeDual.HashRate | Measure-Object -Maximum).Maximum -Force + } else { + $ActiveMiners[$Candidate].PoolDual.HashRate = ($MeDual.HashRate | Measure-Object -Maximum).Maximum + } + } } } @@ -1478,7 +1363,7 @@ while ($Quit -eq $false) { #display current mining info - Print-HorizontalLine + Out-HorizontalLine $ScreenOut = $ActiveMiners.Subminers | Where-Object Best | Sort-Object ` @@ -1493,14 +1378,13 @@ while ($Quit -eq $false) { RevDay = ((($_.RevenueLive + $_.RevenueLiveDual) * $localBTCvalue ).tostring("n2")) ProfitDay = (($_.ProfitsLive).tostring("n2")) Algorithm = $ActiveMiners[$_.IdF].Algorithms + $(if ($ActiveMiners[$_.IdF].AlgoLabel) {'|' + $ActiveMiners[$_.IdF].AlgoLabel}) + $_.BestBySwitch - Coin = $ActiveMiners[$_.IdF].Symbol + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"_$($ActiveMiners[$_.IdF].SymbolDual)"}) + Coin = $ActiveMiners[$_.IdF].Pool.Symbol + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"_$($ActiveMiners[$_.IdF].PoolDual.Symbol)"}) Miner = $ActiveMiners[$_.IdF].Name Power = [string]$_.PowerLive + 'W' - EfficiencyH = if (!($ActiveMiners[$_.IdF].AlgorithmDual) -and $_.PowerLive -gt 0) {ConvertTo-Hash ($_.SpeedLive / $_.PowerLive)} else {$null} EfficiencyW = if ($_.PowerLive -gt 0) {($_.ProfitsLive / $_.PowerLive).tostring("n4")} else {$null} - PoolSpeed = "$(ConvertTo-Hash $ActiveMiners[$_.IdF].PoolHashRate)" + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"/$(ConvertTo-Hash $ActiveMiners[$_.IdF].PoolHashRateDual)"}) - Pool = $ActiveMiners[$_.IdF].PoolName + '-' + $ActiveMiners[$_.IdF].Location + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"|($ActiveMiners[$_.IdF].PoolNameDual)-$($ActiveMiners[$_.IdF].LocationDual)"}) - Workers = $ActiveMiners[$_.IdF].PoolWorkers + PoolSpeed = "$(ConvertTo-Hash $ActiveMiners[$_.IdF].Pool.HashRate)" + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"/$(ConvertTo-Hash $ActiveMiners[$_.IdF].PoolDual.HashRate)"}) + Pool = $ActiveMiners[$_.IdF].Pool.PoolName + '-' + $ActiveMiners[$_.IdF].Pool.Location + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"/" + $ActiveMiners[$_.IdF].PoolDual.PoolName + "-" + $ActiveMiners[$_.IdF].PoolDual.Location}) + Workers = $ActiveMiners[$_.IdF].Pool.PoolWorkers } } @@ -1513,9 +1397,9 @@ while ($Quit -eq $false) { @{Label = "LocalSpeed"; Expression = {$_.LocalSpeed} ; Align = 'right'}, @{Label = "PwLim"; Expression = {$_.PwLim} ; Align = 'right'}, @{Label = "Watt"; Expression = {$_.Power} ; Align = 'right'}, - @{Label = "$LocalCurrency/W"; Expression = {$_.EfficiencyW} ; Align = 'right'}, + @{Label = "$($Config.LocalCurrency)/W"; Expression = {$_.EfficiencyW} ; Align = 'right'}, @{Label = "mBTC/Day"; Expression = {$_.mbtcDay} ; Align = 'right'}, - @{Label = "$LocalCurrency/Day"; Expression = {$_.RevDay} ; Align = 'right'}, + @{Label = "$($Config.LocalCurrency)/Day"; Expression = {$_.RevDay} ; Align = 'right'}, @{Label = "Profit/Day"; Expression = {$_.ProfitDay} ; Align = 'right'}, @{Label = "PoolSpeed"; Expression = {$_.PoolSpeed} ; Align = 'right'}, @{Label = "Pool"; Expression = {$_.Pool} ; Align = 'left'}, @@ -1525,22 +1409,6 @@ while ($Quit -eq $false) { Write-Warning "No miners above MinProfit" } - if ($config.ApiPort -gt 0) { - #generate api response - $ApiResponse = [PSCustomObject]@{} - $ApiResponse | Add-Member ActiveMiners $ScreenOut - $ApiResponse | Add-Member Config $config - $ApiResponse | Add-Member Params ([PSCustomObject]@{}) - $ApiResponse.Params | Add-Member Algorithms $Algorithm - $ApiResponse.Params | Add-Member Pools $PoolsName - $ApiResponse.Params | Add-Member Coins $CoinsName - $ApiResponse.Params | Add-Member MiningMode $MiningMode - $ApiResponse.Params | Add-Member GroupNames $GroupNames - $ApiResponse | Add-Member Release $Release - $ApiResponse | Add-Member RefreshDate ((Get-Date).tostring("o")) - $ApiResponse | ConvertTo-Json | Set-Content -path $ApiSharedFile - } - $XToWrite = [ref]0 $YToWrite = [ref]0 Get-ConsolePosition ([ref]$XToWrite) ([ref]$YToWrite) @@ -1550,62 +1418,40 @@ while ($Quit -eq $false) { Remove-Variable YToWrite ############################################################# - Print-HorizontalLine $Screen.ToUpper() + Out-HorizontalLine $Screen #display profits screen if ($Screen -eq "Profits" -and $RepaintScreen) { - Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 37) $YToWriteMessages - "(B)est Miners/All (T)op " + [string]$InitialProfitsScreenLimit + "/All" | Out-Host + Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 28) $YToWriteMessages + Write-Color @( + " {white}" + " {green}B{white}est Miners" + " {green}T{white}op $($InitialProfitsScreenLimit)/All" + ) -join " " + Set-ConsolePosition 0 $YToWriteData - $ProfitMiners = @() - if ($ShowBestMinersOnly) { - foreach ($SubMiner in ($ActiveMiners.SubMiners | Where-Object {$ActiveMiners[$_.IdF].IsValid -and $_.Status -ne 'Failed'})) { - $Candidates = $ActiveMiners | - Where-Object {$_.IsValid -and - $_.DeviceGroup.Id -eq $ActiveMiners[$SubMiner.IdF].DeviceGroup.Id -and - $_.Algorithm -eq $ActiveMiners[$SubMiner.IdF].Algorithm -and - $_.AlgorithmDual -eq $ActiveMiners[$SubMiner.IdF].AlgorithmDual } - $ExistsBest = $Candidates.SubMiners | Where-Object {$_.Profits -gt $SubMiner.Profits} - if ($null -eq $ExistsBest -and 0 -eq $SubMiner.Profits) { - $ExistsBest = $Candidates | Where-Object {$_.HashRate -gt $SubMiner.HashRate} - } - if ($null -eq $ExistsBest -or $true -eq $SubMiner.NeedBenchmark) { - $ProfitMiner = $ActiveMiners[$SubMiner.IdF] | Select-Object * -ExcludeProperty SubMiners - $ProfitMiner | Add-Member SubMiner $SubMiner - $ProfitMiner | Add-Member GroupName $ProfitMiner.DeviceGroup.GroupName #needed for groupby - $ProfitMiner | Add-Member NeedBenchmark $ProfitMiner.SubMiner.NeedBenchmark #needed for sort - $ProfitMiner | Add-Member Profits $ProfitMiner.SubMiner.Profits #needed for sort - $ProfitMiner | Add-Member Revenue ($ProfitMiner.SubMiner.Revenue + $ProfitMiner.SubMiner.RevenueDual) #needed for sort - $ProfitMiner | Add-Member Status $ProfitMiner.SubMiner.Status #needed for sort - $ProfitMiners += $ProfitMiner - } - } - } else { - $ActiveMiners.SubMiners | Where-Object {$ActiveMiners[$_.IdF].IsValid} | ForEach-Object { + $ProfitMiners = @( + $Candidates = $ActiveMiners.SubMiners | Where-Object {$ActiveMiners[$_.IdF].IsValid} | ForEach-Object { $ProfitMiner = $ActiveMiners[$_.IdF] | Select-Object * -ExcludeProperty SubMiners $ProfitMiner | Add-Member SubMiner $_ - $ProfitMiner | Add-Member GroupName $ProfitMiner.DeviceGroup.GroupName #needed for groupby + # $ProfitMiner | Add-Member GroupName $ProfitMiner.DeviceGroup.GroupName #needed for groupby + $ProfitMiner | Add-Member GroupName "$($ProfitMiner.DeviceGroup.Id)-$($ProfitMiner.DeviceGroup.GroupName)" #needed for groupby $ProfitMiner | Add-Member NeedBenchmark $ProfitMiner.SubMiner.NeedBenchmark #needed for sort $ProfitMiner | Add-Member Profits $ProfitMiner.SubMiner.Profits #needed for sort $ProfitMiner | Add-Member Revenue ($ProfitMiner.SubMiner.Revenue + $ProfitMiner.SubMiner.RevenueDual) #needed for sort $ProfitMiner | Add-Member Status $ProfitMiner.SubMiner.Status #needed for sort - $ProfitMiners += $ProfitMiner + $ProfitMiner } - } - - $ProfitMiners2 = @() - foreach ($DeviceGroupId in $DeviceGroups.Id) { - $inserted = 1 - $ProfitMiners | Where-Object {$_.DeviceGroup.Id -eq $DeviceGroupId} | Sort-Object -Descending GroupName, NeedBenchmark, @{expression = {if ($LocalBTCvalue) {$_.Profits} else {$_.Revenue}}; Descending = $true} | ForEach-Object { - if ($inserted -le $ProfitsScreenLimit) {$ProfitMiners2 += $_; $inserted++} #this can be done with Select-Object -first but then memory leak happens, ¿why? + $Candidates | Where-Object NeedBenchmark + $Candidates | Where-Object NeedBenchmark -eq $false | Group-Object {$_.GroupName + $_.Algorithm + $_.AlgorithmDual} | ForEach-Object { + $_.Group | Sort-Object Profits, Revenue -Descending | Select-Object -First $(if ($ShowBestMinersOnly) {1} else {1000}) } - } + ) | Group-Object GroupName | ForEach-Object {$_.Group | Sort-Object NeedBenchmark, Profits, Revenue -Descending | Select-Object -First $ProfitsScreenLimit} - #Display profits information - $ProfitMiners2 | Sort-Object ` - @{expression = {$_.GroupName -eq 'CPU'}; Ascending = $true}, + $ProfitMiners | Sort-Object ` + @{expression = {$_.GroupName -like '*CPU'}; Ascending = $true}, @{expression = "GroupName"; Ascending = $true}, @{expression = "Status"; Descending = $true}, @{expression = "NeedBenchmark"; Descending = $true}, @@ -1614,31 +1460,33 @@ while ($Quit -eq $false) { @{expression = "HashRateDual"; Descending = $true} | Format-Table ( @{Label = "Algorithm"; Expression = {$_.Algorithms + $(if ($_.AlgoLabel) {"|$($_.AlgoLabel)"})}}, - @{Label = "Coin"; Expression = {$_.Symbol + $(if ($_.AlgorithmDual) {"_$($_.SymbolDual)"})}}, + @{Label = "Coin"; Expression = {$_.Pool.Symbol + $(if ($_.AlgorithmDual) {"_$($_.PoolDual.Symbol)"})}}, @{Label = "Miner"; Expression = {$_.Name}}, - @{Label = "StatsSpeed"; Expression = {if ($_.SubMiner.NeedBenchmark) {"Bench"} else {"$(ConvertTo-Hash $_.SubMiner.HashRate)" + $(if ($_.AlgorithmDual) {"/$(ConvertTo-Hash $_.SubMiner.HashRateDual)"})}}; Align = 'right'}, + @{Label = "StatsSpeed"; Expression = {if ($_.NeedBenchmark) {"Bench"} else {"$(ConvertTo-Hash $_.SubMiner.HashRate)" + $(if ($_.AlgorithmDual) {"/$(ConvertTo-Hash $_.SubMiner.HashRateDual)"})}}; Align = 'right'}, @{Label = "PwLim"; Expression = {if ($_.SubMiner.PowerLimit -ne 0) {$_.SubMiner.PowerLimit}}; align = 'right'}, @{Label = "Watt"; Expression = {if ($_.SubMiner.PowerAvg -gt 0) {$_.SubMiner.PowerAvg.tostring("n0")} else {$null}}; Align = 'right'}, - @{Label = "$LocalCurrency/W"; Expression = {if ($_.SubMiner.PowerAvg -gt 0) {($_.SubMiner.Profits / $_.SubMiner.PowerAvg).tostring("n4")} else {$null} }; Align = 'right'}, - @{Label = "mBTC/Day"; Expression = {if ($_.SubMiner.Revenue) {((($_.SubMiner.Revenue + $_.SubMiner.RevenueDual) * 1000).tostring("n5"))} else {$null}} ; Align = 'right'}, - @{Label = $LocalCurrency + "/Day"; Expression = {if ($_.SubMiner.Revenue) {((($_.SubMiner.Revenue + $_.SubMiner.RevenueDual) * [double]$localBTCvalue).tostring("n2"))} else {$null}} ; Align = 'right'}, - @{Label = "Profit/Day"; Expression = {if ($_.SubMiner.Profits) {($_.SubMiner.Profits).tostring("n2") + " $LocalCurrency"} else {$null}}; Align = 'right'}, - @{Label = "PoolFee"; Expression = {if ($_.PoolFee -gt 0) {"{0:p2}" -f $_.PoolFee}}; Align = 'right'}, + @{Label = "$($Config.LocalCurrency)/W"; Expression = {if ($_.SubMiner.PowerAvg -gt 0) {($_.SubMiner.Profits / $_.SubMiner.PowerAvg).tostring("n4")} else {$null} }; Align = 'right'}, + @{Label = "mBTC/Day"; Expression = {if ($_.Revenue) {($_.Revenue * 1000).tostring("n3")} else {$null}} ; Align = 'right'}, + @{Label = $($Config.LocalCurrency) + "/Day"; Expression = {if ($_.Revenue) {($_.Revenue * [decimal]$localBTCvalue).tostring("n2")} else {$null}} ; Align = 'right'}, + @{Label = "Profit/Day"; Expression = {if ($_.Profits) {($_.Profits).tostring("n2") + " $($Config.LocalCurrency)"} else {$null}}; Align = 'right'}, + @{Label = "PoolFee"; Expression = {if ($_.Pool.Fee -gt 0) {"{0:p2}" -f $_.Pool.Fee}}; Align = 'right'}, @{Label = "MinerFee"; Expression = {if ($_.MinerFee -gt 0) {"{0:p2}" -f $_.MinerFee}}; Align = 'right'}, - @{Label = "Pool"; Expression = {$_.PoolName + '-' + $_.Location + $(if ($_.AlgorithmDual) {"/$($_.PoolNameDual)-$($_.LocationDual)"})}} - + @{Label = "Pool"; Expression = {$_.Pool.PoolName + '-' + $_.Pool.Location + $(if ($_.AlgorithmDual) {"/" + $_.PoolDual.PoolName + "-" + $_.PoolDual.Location})}} ) -GroupBy GroupName | Out-Host Remove-Variable ProfitMiners - Remove-Variable ProfitMiners2 $RepaintScreen = $false } if ($Screen -eq "Current") { + Set-ConsolePosition 0 $YToWriteMessages + Write-Color "{white}Start Time: {green}$((Get-Process -PID $PID).StartTime)" + Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 26) $YToWriteMessages + Write-Color "{white}Running Mode: {green}$MiningMode" Set-ConsolePosition 0 $YToWriteData # Display devices info - Print-DevicesInformation $Devices + Out-DevicesInformation $Devices } ############################################################# @@ -1653,59 +1501,56 @@ while ($Quit -eq $false) { $WalletsUpdate = Get-Date - $WalletsToCheck = @() - - $WalletsToCheck += $AllPools | - Where-Object {$_.WalletMode -eq 'WALLET' -and $_.User} | - Select-Object PoolName, User, WalletMode, WalletSymbol -unique | - ForEach-Object { - [PSCustomObject]@{ - PoolName = $_.PoolName - WalletMode = $_.WalletMode - User = $_.User - Coin = $null - Algorithm = $null - Symbol = $_.WalletSymbol + $WalletsToCheck = @( + $AllPools | + Where-Object {$_.WalletMode -eq 'Wallet' -and $_.User} | + Select-Object PoolName, User, WalletMode, WalletSymbol -Unique | + ForEach-Object { + [PSCustomObject]@{ + PoolName = $_.PoolName + WalletMode = $_.WalletMode + User = $_.User + Coin = $null + Algorithm = $null + Symbol = $_.WalletSymbol + } } - } - $WalletsToCheck += $AllPools | - Where-Object {$_.WalletMode -eq 'APIKEY' -and $Config.("APIKEY_" + $_.PoolName)} | - Select-Object PoolName, Algorithm, WalletMode, WalletSymbol, @{Name = "ApiKey"; Expression = {$Config.("APIKEY_" + $_.PoolName)}} -unique | - ForEach-Object { - [PSCustomObject]@{ - PoolName = $_.PoolName - WalletMode = $_.WalletMode - User = $null - Algorithm = $_.Algorithm - Symbol = $_.WalletSymbol - ApiKey = $_.ApiKey + $AllPools | + Where-Object {$_.WalletMode -eq 'ApiKey' -and $Config.("ApiKey_" + $_.PoolName)} | + Select-Object PoolName, Algorithm, WalletMode, WalletSymbol, @{Name = "ApiKey"; Expression = {$Config.("ApiKey_" + $_.PoolName)}} -Unique | + ForEach-Object { + [PSCustomObject]@{ + PoolName = $_.PoolName + WalletMode = $_.WalletMode + User = $null + Algorithm = $_.Algorithm + Symbol = $_.WalletSymbol + ApiKey = $_.ApiKey + } } - } + ) - $WalletStatus = @() - $WalletsToCheck | ForEach-Object { + $WalletStatus = $WalletsToCheck | ForEach-Object { Set-ConsolePosition 0 $YToWriteMessages " " * 70 | Out-Host Set-ConsolePosition 0 $YToWriteMessages - if ($_.WalletMode -eq "WALLET") {Log-Message "Checking $($_.PoolName) - $($_.Symbol)"} - else {Log-Message "Checking $($_.PoolName) - $($_.Symbol) ($($_.Algorithm))"} + if ($_.WalletMode -eq "Wallet") {Log "Checking $($_.PoolName) - $($_.Symbol)"} + else {Log "Checking $($_.PoolName) - $($_.Symbol) ($($_.Algorithm))"} $Ws = Get-Pools -Querymode $_.WalletMode -PoolsFilterList $_.PoolName -Info ($_) - if ($_.WalletMode -eq "WALLET") {$Ws | Add-Member Wallet $_.User} + if ($_.WalletMode -eq "Wallet") {$Ws | Add-Member Wallet $_.User} else {$Ws | Add-Member Wallet $_.Coin} $Ws | Add-Member PoolName $_.PoolName $Ws | Add-Member WalletSymbol $_.Symbol - $WalletStatus += $Ws - - } -End { - Set-ConsolePosition 0 $YToWriteMessages - " " * 70 | Out-Host + $Ws } + Set-ConsolePosition 0 $YToWriteMessages + " " * 70 | Out-Host if (-not $WalletStatusAtStart) {$WalletStatusAtStart = $WalletStatus} @@ -1729,22 +1574,18 @@ while ($Quit -eq $false) { if ($Screen -eq "Wallets" -and $RepaintScreen) { Set-ConsolePosition 0 $YToWriteMessages - "Start Time: $((Get-Process -PID $PID).StartTime) " - Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 10) $YToWriteMessages - "(U)pdate" | Out-Host - "" | Out-Host + Write-Color "{white}Start Time: {green}$((Get-Process -PID $PID).StartTime) " + Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 8) $YToWriteMessages + Write-Color "{green}U{white}pdate" $WalletStatus | Where-Object Balance | Sort-Object @{expression = "PoolName"; Ascending = $true}, @{expression = "balance"; Descending = $true} | - Format-Table -Wrap -groupby PoolName ( + Format-Table -Wrap -GroupBy PoolName ( @{Label = "Coin"; Expression = {if ($_.WalletSymbol -ne $null) {$_.WalletSymbol} else {$_.wallet}}}, @{Label = "Balance"; Expression = {$_.Balance.tostring("n5")}; Align = 'right'}, - @{Label = "IncFromStart"; Expression = {($_.Balance - $_.BalanceAtStart).tostring("n5")}; Align = 'right'} + @{Label = "Session"; Expression = {($_.Balance - $_.BalanceAtStart).tostring("n5")}; Align = 'right'} ) | Out-Host - $Pools | Where-Object WalletMode -eq 'NONE' | Select-Object PoolName -unique | ForEach-Object { - "NO API FOR POOL " + $_.PoolName + " - NO WALLETS CHECK" | Out-Host - } $RepaintScreen = $false } } @@ -1753,8 +1594,9 @@ while ($Quit -eq $false) { if ($Screen -eq "History" -and $RepaintScreen) { Set-ConsolePosition 0 $YToWriteMessages - "Running Mode: $MiningMode" | Out-Host - + Write-Color "{white}Start Time: {green}$((Get-Process -PID $PID).StartTime)" + Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 26) $YToWriteMessages + Write-Color "{white}Running Mode: {green}$MiningMode" Set-ConsolePosition 0 $YToWriteData #Display activated miners list @@ -1767,6 +1609,7 @@ while ($Quit -eq $false) { @{Label = "LastTimeActive"; Expression = {$($_.Stats.LastTimeActive).tostring("dd/MM/yy H:mm")}}, @{Label = "Command"; Expression = {"$($ActiveMiners[$_.IdF].Path.TrimStart((Convert-Path ".\Bin\"))) $($ActiveMiners[$_.IdF].Arguments)"}} ) | Out-Host + $RepaintScreen = $false } @@ -1774,12 +1617,9 @@ while ($Quit -eq $false) { if ($Screen -eq "Stats" -and $RepaintScreen) { Set-ConsolePosition 0 $YToWriteMessages - "Start Time: $((Get-Process -PID $PID).StartTime)" - - Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 30) $YToWriteMessages - - "Running Mode: $MiningMode" | Out-Host - + Write-Color "{white}Start Time: {green}$((Get-Process -PID $PID).StartTime)" + Set-ConsolePosition ($Host.UI.RawUI.WindowSize.Width - 26) $YToWriteMessages + Write-Color "{white}Running Mode: {green}$MiningMode" Set-ConsolePosition 0 $YToWriteData #Display activated miners list @@ -1791,8 +1631,8 @@ while ($Quit -eq $false) { @{expression = {$_.Stats.Activetime}; Descending = $true} | Format-Table -Wrap -GroupBy @{Label = "Group"; Expression = {$ActiveMiners[$_.IdF].DeviceGroup.GroupName}}( @{Label = "Algorithm"; Expression = {$ActiveMiners[$_.IdF].Algorithms + $(if ($ActiveMiners[$_.IdF].AlgoLabel) {"|$($ActiveMiners[$_.IdF].AlgoLabel)"})}}, - @{Label = "Coin"; Expression = {$ActiveMiners[$_.IdF].Symbol + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"_$($ActiveMiners[$_.IdF].SymbolDual)"})}}, - @{Label = "Pool"; Expression = {$ActiveMiners[$_.IdF].PoolName + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"/$($ActiveMiners[$_.IdF].PoolNameDual)"})}}, + @{Label = "Coin"; Expression = {$ActiveMiners[$_.IdF].Pool.Symbol + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"_$($ActiveMiners[$_.IdF].PoolDual.Symbol)"})}}, + @{Label = "Pool"; Expression = {$ActiveMiners[$_.IdF].Pool.PoolName + $(if ($ActiveMiners[$_.IdF].AlgorithmDual) {"/$($ActiveMiners[$_.IdF].PoolDual.PoolName)"})}}, @{Label = "Miner"; Expression = {$ActiveMiners[$_.IdF].Name}}, @{Label = "PwLmt"; Expression = {if ($_.PowerLimit -gt 0) {$_.PowerLimit}}}, @{Label = "Launch"; Expression = {$_.Stats.ActivatedTimes}}, @@ -1807,36 +1647,60 @@ while ($Quit -eq $false) { #Loop for reading key and wait - $KeyPressed = Read-KeyboardTimed 3 ('P', 'C', 'H', 'E', 'W', 'U', 'T', 'B', 'S', 'X', 'Q') - - switch ($KeyPressed) { - 'P' {$Screen = 'PROFITS'} - 'C' {$Screen = 'CURRENT'} - 'H' {$Screen = 'HISTORY'} - 'S' {$Screen = 'STATS'} - 'E' {$ExitLoop = $true; Log-Message "Forced end of interval by E key"} - 'W' {$Screen = 'WALLETS'} - 'U' {if ($Screen -eq "WALLETS") {$WalletsUpdate = $null}} - 'T' {if ($Screen -eq "PROFITS") {if ($ProfitsScreenLimit -eq $InitialProfitsScreenLimit) {$ProfitsScreenLimit = 1000} else {$ProfitsScreenLimit = $InitialProfitsScreenLimit}}} - 'B' {if ($Screen -eq "PROFITS") {$ShowBestMinersOnly = !$ShowBestMinersOnly}} - 'X' {try {Set-WindowSize 180 50} catch {}} - 'Q' {$Quit = $true; $ExitLoop = $true} + $ValidGroups = [string[]]$DeviceGroups.Id + $KeyPressed = Read-KeyboardTimed -SecondsToWait 3 -ValidKeys (@('P', 'C', 'H', 'E', 'W', 'U', 'T', 'B', 'S', 'X', 'Q', 'D', 'R') + $ValidGroups) + + switch -regex ($KeyPressed) { + 'P' {$Screen = 'Profits'; Log "Switch to Profits screen"} + 'C' {$Screen = 'Current'; Log "Switch to Current screen"} + 'H' {$Screen = 'History'; Log "Switch to History screen"} + 'S' {$Screen = 'Stats'; Log "Switch to Stats screen"} + 'E' {$ExitLoop = $true; Log "Forced end of interval by E key"} + 'W' {$Screen = 'Wallets'; Log "Switch to Wallet screen"} + 'U' {if ($Screen -eq "Wallets") {$WalletsUpdate = $null}; Log "Update wallets"} + 'T' {if ($Screen -eq "Profits") {$ProfitsScreenLimit = $(if ($ProfitsScreenLimit -eq $InitialProfitsScreenLimit) {1000} else {$InitialProfitsScreenLimit}); Log "Toggle Profits Top"}} + 'B' {if ($Screen -eq "Profits") {$ShowBestMinersOnly = -not $ShowBestMinersOnly}; Log "Toggle Profits Best"} + 'X' {try {Set-WindowSize 180 50} catch {}; Log "Reset screen size"} + 'Q' {$Quit = $true; $ExitLoop = $true; Log "Exit by Q key"} + 'D' { + if (-not (Test-Path ".\Dump")) { New-Item -Path .\Dump -ItemType directory -Force | Out-Null } + $Pools | ConvertTo-Json -Depth 10 | Set-Content .\Dump\Pools.json + $ActiveMiners | ConvertTo-Json -Depth 10 | Set-Content .\Dump\Miners.json + $DeviceGroups | ConvertTo-Json -Depth 10 | Set-Content .\Dump\DeviceGroups.json + } + 'R' { + ## Reset failed miners + $ActiveMiners.SubMiners | Where-Object {$_.Status -eq 'Failed'} | ForEach-Object { + $_.Status = 'Idle' + $_.Stats.FailedTimes = 0 + Log "Reset failed miner status: $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithms)" + } + } + "\d" { + if ($DeviceGroups | Where-Object {$_.ID -eq "$KeyPressed"}) { + $DeviceGroups | Where-Object {$_.ID -eq "$KeyPressed"} | ForEach-Object {$_.Enabled = -not $_.Enabled} + $ExitLoop = $true + Log "Toggle Device group $_" + } + } } - if ($KeyPressed) {Clear-Host; $RepaintScreen = $true} + if ($KeyPressed) { + $RepaintScreen = $true + } - if (((Get-Date) -ge ($LoopStartTime.AddSeconds($Interval.Duration))) ) { + if ((Get-Date) -ge $LoopStartTime.AddSeconds($Interval.Duration)) { #If time of interval has over, Exit of main loop #If last interval was benchmark and no speed detected mark as failed $ActiveMiners.SubMiners | Where-Object Best | ForEach-Object { if ($_.NeedBenchmark -and $_.SpeedReads.Count -eq 0) { $_.Status = 'PendingCancellation' $_.Stats.FailedTimes++ - Log-Message "No speed detected while benchmark $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithm) (id $($ActiveMiners[$_.IdF].Id))" -Severity Warn + Log "No speed detected while benchmark $($ActiveMiners[$_.IdF].Name)/$($ActiveMiners[$_.IdF].Algorithm) (id $($ActiveMiners[$_.IdF].Id))" -Severity Warn } } $ExitLoop = $true - Log-Message "Interval ends by time: $($Interval.Duration)" -Severity Debug + Log "Interval ends by time: $($Interval.Duration)" -Severity Debug } if ($ExitLoop) {break} #forced Exit @@ -1844,8 +1708,8 @@ while ($Quit -eq $false) { Send-ErrorsToLog $LogFile } - Remove-Variable miners - Remove-Variable pools + Remove-Variable Miners + Remove-Variable Pools Get-Job -State Completed | Remove-Job [GC]::Collect() #force garbage collector for free memory } @@ -1856,11 +1720,11 @@ while ($Quit -eq $false) { #----------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------- -Log-Message "Exiting Forager" +Log "Exiting Forager" $LogFile.close() + Clear-Files $ActiveMiners | Where-Object Process -ne $null | ForEach-Object {try {Exit-Process $_.Process} catch {}} -try {Invoke-WebRequest ("http://localhost:$($config.ApiPort)/?command=Exit") -timeoutsec 1 -UseDefaultCredentials} catch {} +Stop-Autoexec -if ($EthPill -ne $null) {Stop-Process -Id $EthPill.Id} Stop-Process -Id $PID diff --git a/Includes/algorithms.json b/Data/algorithms.json similarity index 100% rename from Includes/algorithms.json rename to Data/algorithms.json diff --git a/Includes/amd-cards-tdp.json b/Data/amd-cards-tdp.json similarity index 100% rename from Includes/amd-cards-tdp.json rename to Data/amd-cards-tdp.json diff --git a/Includes/cpu-tdp.json b/Data/cpu-tdp.json similarity index 100% rename from Includes/cpu-tdp.json rename to Data/cpu-tdp.json diff --git a/DeviceList.bat b/DeviceList.bat index 58a9887f..32333db6 100644 --- a/DeviceList.bat +++ b/DeviceList.bat @@ -1,3 +1,15 @@ @echo off -powershell -version 5.0 -executionpolicy bypass -command "&.\DeviceList.ps1 -pause \ No newline at end of file + +cd /d %~dp0 + +set Command="&.\DeviceList.ps1 + +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end +pause diff --git a/DeviceList.ps1 b/DeviceList.ps1 index 6e5c52c7..503df9a2 100644 --- a/DeviceList.ps1 +++ b/DeviceList.ps1 @@ -1,8 +1,10 @@ -. .\Include.ps1 -if ((Get-ConfigVariable "Afterburner") -eq "Enabled") { +Import-Module .\Include.psm1 + +$global:Config = Get-Config +if ($Config.Afterburner) { . .\Includes\Afterburner.ps1 } -Print-DevicesInformation (Get-DevicesInformation (Get-MiningTypes -All)) +Out-DevicesInformation (Get-DevicesInformation (Get-MiningTypes -All)) $Groups = Get-MiningTypes -All | Where-Object Type -ne 'CPU' | Select-Object GroupName,Type,Devices,@{Name = 'PowerLimits'; Expression = {$_.PowerLimits -join ','}} | ConvertTo-Json -Compress diff --git a/Include.ps1 b/Include.psm1 similarity index 73% rename from Include.ps1 rename to Include.psm1 index 431790e4..bf7bd198 100644 --- a/Include.ps1 +++ b/Include.psm1 @@ -1,4 +1,4 @@ -Add-Type -Path $PSScriptRoot\Includes\OpenCL\*.cs +Add-Type -Path .\Includes\OpenCL\*.cs function Set-NvidiaPowerLimit ([int]$PowerLimitPercent, [string]$Devices) { @@ -17,27 +17,13 @@ function Set-NvidiaPowerLimit ([int]$PowerLimitPercent, [string]$Devices) { $PowerDefaultLimit = [int]((invoke-expression $xpr) -replace 'W', '') #powerlimit change must run in admin mode - $newProcess = New-Object System.Diagnostics.ProcessStartInfo ".\includes\nvidia-smi.exe" - $newProcess.Verb = "runas" - #$newProcess.UseShellExecute = $false - $newProcess.Arguments = "-i $Device -pl $([Math]::Floor([int]($PowerDefaultLimit -replace ' W', '') * ($PowerLimitPercent / 100)))" - [System.Diagnostics.Process]::Start($newProcess) | Out-Null + $NewProcess = New-Object System.Diagnostics.ProcessStartInfo ".\includes\nvidia-smi.exe" + $NewProcess.Verb = "runas" + #$NewProcess.UseShellExecute = $false + $NewProcess.Arguments = "-i $Device -pl $([Math]::Floor([int]($PowerDefaultLimit -replace ' W', '') * ($PowerLimitPercent / 100)))" + [System.Diagnostics.Process]::Start($NewProcess) | Out-Null } - Remove-Variable newprocess -} - -function Get-ComputerStats { - $avg = Get-CimInstance win32_processor | Measure-Object -property LoadPercentage -Average | ForEach-Object {$_.Average} - $mem = Get-CimInstance win32_operatingsystem | ForEach-Object {"{0:N2}" -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory) * 100) / $_.TotalVisibleMemorySize)} - $memV = Get-CimInstance win32_operatingsystem | ForEach-Object {"{0:N2}" -f ((($_.TotalVirtualMemorySize - $_.FreeVirtualMemory) * 100) / $_.TotalVirtualMemorySize)} - $free = Get-CimInstance Win32_Volume -Filter "DriveLetter = 'C:'" | ForEach-Object {"{0:N2}" -f (($_.FreeSpace / $_.Capacity) * 100)} - $nprocs = (Get-Process).count - if (Get-Command "Get-NetTCPConnection" -ErrorAction SilentlyContinue) { - $Conns = (Get-NetTCPConnection).count - } else { - $Error.Remove($Error[$Error.Count - 1]) - } - "AverageCpu = $avg % | MemoryUsage = $mem % | VirtualMemoryUsage = $memV % | PercentCFree = $free % | Processes = $nprocs | Connections = $Conns" + Remove-Variable NewProcess } function Send-ErrorsToLog ($LogFile) { @@ -46,13 +32,13 @@ function Send-ErrorsToLog ($LogFile) { if ($error[$i].InnerException.Paramname -ne "scopeId") { # errors in debug $Msg = "###### ERROR ##### " + [string]($error[$i]) + ' ' + $error[$i].ScriptStackTrace - Log-Message $msg -Severity Error -NoEcho + Log $msg -Severity Error -NoEcho } } $error.clear() } -function Replace-ForEachDevice { +function Edit-ForEachDevice { param( [Parameter(Mandatory = $true)] [string]$ConfigFileArguments, @@ -68,9 +54,11 @@ function Replace-ForEachDevice { $Match.Matches | ForEach-Object { $Base = $_.value -replace "#ForEachDevice#" -replace "#EndForEachDevice#" - $Final = "" $Index = 0 - $Devices.Devices -split ',' | ForEach-Object {$Final += ($base -replace "#DeviceID#", $_ -replace "#DeviceIndex#", $Index); $Index++} + $Final = $Devices.Devices -split ',' | ForEach-Object { + $Base -replace "#DeviceID#", $_ -replace "#DeviceIndex#", $Index + $Index++ + } $ConfigFileArguments = $ConfigFileArguments.Substring(0, $_.index) + $Final + $ConfigFileArguments.Substring($_.index + $_.Length, $ConfigFileArguments.Length - ($_.index + $_.Length)) } } @@ -129,13 +117,13 @@ function Exit-Process { if ($sw.Elapsed.TotalSeconds -gt 1) { Stop-Process -InputObject $Process -Force } - if (!$Process.HasExited) { + if (-not $Process.HasExited) { Start-Sleep -Milliseconds 1 } - } while (!$Process.HasExited) + } while (-not $Process.HasExited) } finally { $sw.Stop() - if (!$Process.HasExited) { + if (-not $Process.HasExited) { Stop-Process -InputObject $Process -Force } } @@ -186,7 +174,7 @@ function Get-DevicesInformation ($Types) { $Command = ".\Includes\OverdriveN.exe" $AdlResult = & $Command | Where-Object {$_ -notlike "*&???" -and $_ -ne "ADL2_OverdriveN_Capabilities_Get is failed"} - $AmdCardsTDP = Get-Content .\Includes\amd-cards-tdp.json | ConvertFrom-Json + $AmdCardsTDP = Get-Content .\Data\amd-cards-tdp.json | ConvertFrom-Json if ($null -ne $AdlResult) { $AdlResult | ForEach-Object { @@ -298,7 +286,7 @@ function Get-DevicesInformation ($Types) { } } if (-not $CpuData.PowerDraw) { - if (-not $CpuTDP) {$CpuTDP = Get-Content ".\Includes\cpu-tdp.json" | ConvertFrom-Json} + if (-not $CpuTDP) {$CpuTDP = Get-Content ".\Data\cpu-tdp.json" | ConvertFrom-Json} $CpuData.PowerDraw = $CpuTDP.($_.Name.Trim()) * $CpuData.Utilization / 100 } if (-not $CpuData.Clock) {$CpuData.Clock = $_.MaxClockSpeed} @@ -320,7 +308,7 @@ function Get-DevicesInformation ($Types) { $Devices } -function Print-DevicesInformation ($Devices) { +function Out-DevicesInformation ($Devices) { $Devices | Where-Object Type -ne 'CPU' | Sort-Object Type | Format-Table -Wrap ( @{Label = "Id"; Expression = {$_.Id}; Align = 'right'}, @@ -351,154 +339,235 @@ function Print-DevicesInformation ($Devices) { ) -groupby Type | Out-Host } -Function Get-MiningTypes () { - param( - [Parameter(Mandatory = $false)] - [array]$Filter = $null, - [Parameter(Mandatory = $false)] - [switch]$All = $false - ) - - if ($null -eq $Filter) {$Filter = @()} # to allow comparation after - - $OCLPlatforms = [OpenCl.Platform]::GetPlatformIDs() - $PlatformID = 0 +function Get-Devices { + $OCLPlatforms = @([OpenCl.Platform]::GetPlatformIds()) + $PlatformId = 0 $OCLDevices = @($OCLPlatforms | ForEach-Object { $Devs = [OpenCl.Device]::GetDeviceIDs($_, [OpenCl.DeviceType]::All) - $Devs | Add-Member PlatformID $PlatformID - $PlatformID++ + $Devs | Add-Member PlatformId $PlatformId + $Devs | ForEach-Object { + $_ | Add-Member DeviceIndex $([array]::indexof($Devs, $_)) + } + $PlatformId++ $Devs }) # # start fake # $OCLDevices = @() - # $OCLDevices += [PSCustomObject]@{Name = 'Ellesmere'; Vendor = 'Advanced Micro Devices, Inc.'; GlobalMemSize = 8GB; PlatformID = 0; Type = 'Gpu'} - # $OCLDevices += [PSCustomObject]@{Name = 'Ellesmere'; Vendor = 'Advanced Micro Devices, Inc.'; GlobalMemSize = 8GB; PlatformID = 0; Type = 'Gpu'} - # $OCLDevices += [PSCustomObject]@{Name = 'Ellesmere'; Vendor = 'Advanced Micro Devices, Inc.'; GlobalMemSize = 4GB; PlatformID = 0; Type = 'Gpu'} - # $OCLDevices += [PSCustomObject]@{Name = 'GeForce 1060'; Vendor = 'NVIDIA Corporation'; GlobalMemSize = 3GB; PlatformID = 1; Type = 'Gpu'} - # $OCLDevices += [PSCustomObject]@{Name = 'GeForce 1060'; Vendor = 'NVIDIA Corporation'; GlobalMemSize = 3GB; PlatformID = 1; Type = 'Gpu'} + # $OCLDevices += [PSCustomObject]@{Name = 'Ellesmere'; Vendor = 'Advanced Micro Devices, Inc.'; GlobalMemSize = 8GB; PlatformId = 0; Type = 'Gpu'; DeviceIndex = 0} + # $OCLDevices += [PSCustomObject]@{Name = 'Ellesmere'; Vendor = 'Advanced Micro Devices, Inc.'; GlobalMemSize = 8GB; PlatformId = 0; Type = 'Gpu'; DeviceIndex = 1} + # $OCLDevices += [PSCustomObject]@{Name = 'Ellesmere'; Vendor = 'Advanced Micro Devices, Inc.'; GlobalMemSize = 4GB; PlatformId = 0; Type = 'Gpu'; DeviceIndex = 2} + # $OCLDevices += [PSCustomObject]@{Name = 'GeForce 1060'; Vendor = 'NVIDIA Corporation'; GlobalMemSize = 3GB; PlatformId = 1; Type = 'Gpu'; DeviceIndex = 1} + # $OCLDevices += [PSCustomObject]@{Name = 'GeForce 1060'; Vendor = 'NVIDIA Corporation'; GlobalMemSize = 3GB; PlatformId = 1; Type = 'Gpu'; DeviceIndex = 2} # # end fake - $Types0 = Get-ConfigVariable "GpuGroups" - - if ($null -eq $Types0 -or $All) { - # Autodetection on, must add types manually - $Types0 = @() - $OCLDevices | Where-Object Type -eq 'Gpu' | Group-Object -Property PlatformID | ForEach-Object { - $DeviceID = 0 - $_.Group | ForEach-Object { - - $Vendors = @{ - "Advanced Micro Devices, Inc." = "AMD" - "NVIDIA Corporation" = "NVIDIA" - # "Intel(R) Corporation" = "INTEL" #Nothing to be mined on Intel iGPU - # "Intel Corporation" = "INTEL" #Nothing to be mined on Intel iGPU - } + $Vendors = @{ + "Advanced Micro Devices, Inc." = "AMD" + "NVIDIA Corporation" = "NVIDIA" + # "Intel(R) Corporation" = "INTEL" #Nothing to be mined on Intel iGPU + # "Intel Corporation" = "INTEL" #Nothing to be mined on Intel iGPU + "GenuineIntel" = 'CPU' + "AuthenticAMD" = 'CPU' + } + # $OCLDevices | Where-Object Type -eq 'Gpu' | Group-Object PlatformId, Name, GlobalMemSize, MaxComputeUnits | ForEach-Object { + # $Devices = $_.Group | Select-Object -Property PlatformId, Name, Vendor, GlobalMemSize, MaxComputeUnits -First 1 + # if ($Vendors.($Devices.Vendor)) { + # $Devices | Add-Member Devices $($_.Group.DeviceIndex -join ',') + # $Devices | Add-Member Type $Vendors.($Devices.Vendor) + # $Devices | Add-Member GroupName $(($Devices.Name -replace "[^A-Z0-9]") + '_' + [int]($Devices.GlobalMemSize / 1GB) + 'gb_' + $Devices.MaxComputeUnits) + + # $Devices | Select-Object -Property GroupName, Type, Name, PlatformId, Devices, Enabled + # } + # } + if ($Config.GpuGroupByType) { + $OCLDevices | Where-Object Type -eq 'Gpu' | Group-Object PlatformId, Name | ForEach-Object { + $Devices = $_.Group | Select-Object -Property PlatformId, Name, Vendor -First 1 + if ($Vendors.($Devices.Vendor)) { + $Devices | Add-Member Devices $($_.Group.DeviceIndex -join ',') + $Devices | Add-Member Type $Vendors.($Devices.Vendor) + $Devices | Add-Member GroupName $Vendors.($Devices.Vendor) + $Devices | Add-Member Enabled $true + + $Devices | Select-Object -Property GroupName, Type, Name, PlatformId, Devices, Enabled + } + } + } else { + $OCLDevices | Where-Object Type -eq 'Gpu' | Group-Object PlatformId, Name, GlobalMemSize | ForEach-Object { + $Devices = $_.Group | Select-Object -Property PlatformId, Name, Vendor, GlobalMemSize -First 1 + if ($Vendors.($Devices.Vendor)) { + $Devices | Add-Member Devices $($_.Group.DeviceIndex -join ',') + $Devices | Add-Member Type $Vendors.($Devices.Vendor) + $Devices | Add-Member GroupName $(($Devices.Name -replace "[^A-Z0-9]") + '_' + [int]($Devices.GlobalMemSize / 1GB) + 'gb') + $Devices | Add-Member Enabled $true + + $Devices | Select-Object -Property GroupName, Type, Name, PlatformId, Devices, Enabled + } + } + } + # if ($Config.CPUMining) { + # $OCLDevices | Where-Object Type -eq 'Cpu' | Select-Object -First 1 | ForEach-Object { + # $Devices = $_ | Select-Object -Property PlatformId, Name, Vendor + # if ($Vendors.($Devices.Vendor)) { + # $Devices | Add-Member Devices $_.DeviceIndex + # $Devices | Add-Member Type $Vendors.($Devices.Vendor) + # $Devices | Add-Member GroupName $Vendors.($Devices.Vendor) + # $Devices | Add-Member Enabled $true + + # $Devices | Select-Object -Property GroupName, Type, Name, PlatformId, Devices, Enabled + # } + # } + # } +} - $Type = $Vendors.($_.Vendor) +function Get-MiningTypes () { + param( + [Parameter(Mandatory = $false)] + [array]$Filter = @(), + [Parameter(Mandatory = $false)] + [switch]$All = $false + ) - $MemoryGB = [int]($_.GlobalMemSize / 1GB) + $OCLPlatforms = [OpenCl.Platform]::GetPlatformIds() + $PlatformId = 0 + $OCLDevices = @($OCLPlatforms | ForEach-Object { + $Devs = [OpenCl.Device]::GetDeviceIDs($_, [OpenCl.DeviceType]::All) + $Devs | Add-Member PlatformId $PlatformId + $Devs | ForEach-Object { + $_ | Add-Member DeviceIndex $([array]::indexof($Devs, $_)) + } + $PlatformId++ + $Devs + }) - if ((Get-ConfigVariable "GpuGroupByType") -eq "Enabled") { - $Name_Norm = $Type - } else { - $Name_Norm = (Get-Culture).TextInfo.ToTitleCase(($_.Name)) -replace "[^A-Z0-9]" - $Name_Norm += $MemoryGB - } + $Devices = $Config.GpuGroups - $PlatformID = $_.PlatformID - - if ($Type) { - if ($null -eq ($Types0 | Where-Object {$_.GroupName -eq $Name_Norm -and $_.Platform -eq $PlatformID})) { - $Types0 += [PSCustomObject] @{ - GroupName = $Name_Norm - Type = $Type - Devices = [string]$DeviceID - Platform = $PlatformID - MemoryGB = $MemoryGB - PowerLimits = "0" - } - } else { - $Types0 | Where-Object {$_.GroupName -eq $Name_Norm -and $_.Platform -eq $PlatformID} | ForEach-Object { - $_.Devices += "," + $DeviceID - } - } - } - $DeviceID++ - } - } - } elseif ("" -eq $Types0) { + if ($null -eq $Devices -or $All) { + # Autodetection on + [array]$Devices = Get-Devices + } elseif ("" -eq $Devices) { # Empty GpuGroups - don't autodetect, use cpu only - [array]$Types0 = $null + [array]$Devices = $null } else { # GpuGroups not empty - parse it - [array]$Types0 = $Types0 | ConvertFrom-Json + [array]$Devices = $Devices | ConvertFrom-Json + $Devices | ForEach-Object { + if ($null -eq $_.Enabled) { $_ | Add-Member Enabled $true } + } + } + + if ($Config.CpuMining) { + $Devices += $OCLDevices | Where-Object Type -eq 'Cpu' | Select-Object -First 1 | ForEach-Object { + $Devices = $_ | Select-Object -Property PlatformId, Name, Vendor + $Devices | Add-Member Devices $_.DeviceIndex + $Devices | Add-Member Type 'CPU' + $Devices | Add-Member GroupName 'CPU' + $Devices | Add-Member Enabled $true + + $Devices | Select-Object -Property GroupName, Type, Name, PlatformId, Devices, Enabled + } } - #if cpu mining is enabled add a new group - if ( - (!$Filter -and (Get-ConfigVariable "CPUMining") -eq 'ENABLED') -or - $Filter -contains "CPU" -or - $Types0.Length -eq 0 - ) { - $SysResult = @(Get-CimInstance Win32_ComputerSystem) + if ($Devices | Where-Object {$_.Type -eq 'CPU'}) { + + $SysResult = Get-CimInstance Win32_ComputerSystem + $CpuResult = Get-CimInstance Win32_Processor $Features = $($feat = @{}; switch -regex ((& .\Includes\CHKCPU32.exe /x) -split "") {"^\s*<_?(\w+)>(\d+).*" {$feat.($matches[1]) = [int]$matches[2]}}; $feat) - $RealCores = [int[]](0..($Features.Threads - 1)) - if ($Features.Threads -gt $Features.Cores) { + $RealCores = [int[]](0..($CpuResult.NumberOfLogicalProcessors - 1)) + if ($CpuResult.NumberOfLogicalProcessors -gt $CpuResult.NumberOfCores) { $RealCores = $RealCores | Where-Object {-not ($_ % 2)} } - $Types0 += [PSCustomObject]@{ - GroupName = 'CPU' - Type = 'CPU' - Devices = $RealCores -join ',' - MemoryGB = [int]($SysResult.TotalPhysicalMemory / 1GB) - PowerLimits = "0" - Features = $Features + $Devices | Where-Object {$_.Type -eq 'CPU'} | ForEach-Object { + $_ | Add-Member RealCores ($RealCores -join ',') + $_ | Add-Member MemoryGB ([int]($SysResult.TotalPhysicalMemory / 1GB)) + $_ | Add-Member Features $Features } } - $Types = @() $TypeID = 0 - $Types0 | ForEach-Object { - if (!$Filter -or (Compare-Object $_.GroupName $Filter -IncludeEqual -ExcludeDifferent)) { + $DeviceGroups = $Devices | ForEach-Object { + if (-not $Filter -or (Compare-Object $_.GroupName $Filter -IncludeEqual -ExcludeDifferent)) { $_ | Add-Member ID $TypeID $TypeID++ - $_ | Add-Member DevicesArray @([int[]]($_.Devices -split ',')) # @(0,1,2,10,11,12) - $_ | Add-Member DevicesClayMode (($_.DevicesArray | ForEach-Object {'{0:X}' -f $_}) -join '') # 012ABC - $_ | Add-Member DevicesETHMode ($_.DevicesArray -join ' ') # 0 1 2 10 11 12 - $_ | Add-Member DevicesNsgMode (($_.DevicesArray | ForEach-Object { "-d " + $_}) -join ' ') # -d 0 -d 1 -d 2 -d 10 -d 11 -d 12 - $_ | Add-Member DevicesCount ($_.DevicesArray.count) # 6 - - switch ($_.Type) { - AMD { $Pattern = 'Advanced Micro Devices, Inc.' } - NVIDIA { $Pattern = 'NVIDIA Corporation' } - INTEL { $Pattern = 'Intel(R) Corporation' } - CPU { $Pattern = '' } - } - $_ | Add-Member OCLDevices @($OCLDevices | Where-Object {$_.Vendor -eq $Pattern -and $_.Type -eq 'Gpu'})[$_.DevicesArray] - if ($null -eq $_.Platform) {$_ | Add-Member Platform ($_.OCLDevices.PlatformID | Select-Object -First 1)} - if ($null -eq $_.MemoryGB) {$_ | Add-Member MemoryGB ([int](($_.OCLDevices | Measure-Object -Property GlobalMemSize -Minimum | Select-Object -ExpandProperty Minimum) / 1GB ))} - if ($null -eq $_.DevicesMask) {$_ | Add-Member DevicesMask ('{0:X}' -f [int]($_.DevicesArray | ForEach-Object { [System.Math]::Pow(2, $_) } | Measure-Object -Sum).Sum)} + $_ | Add-Member DevicesArray @([int[]]($_.Devices -split ',')) # @(0,1,2,10,11,12) + $_ | Add-Member DevicesCount ($_.DevicesArray.count) # 6 - $_.PowerLimits = @([int[]]($_.PowerLimits -split ',') | Sort-Object -Descending -Unique) + $Pattern = switch ($_.Type) { + AMD { 'Advanced Micro Devices, Inc.' } + NVIDIA { 'NVIDIA Corporation' } + INTEL { 'Intel(R) Corporation' } + CPU { '' } + } + $OCLDevice = @($OCLDevices | Where-Object {$_.Vendor -eq $Pattern -and $_.Type -eq 'Gpu'})[$_.DevicesArray] + if ($null -eq $_.PlatformId) {$_ | Add-Member PlatformId ($OCLDevice.PlatformId | Select-Object -First 1)} + if ($null -eq $_.MemoryGB) {$_ | Add-Member MemoryGB ([int](($OCLDevice | Measure-Object -Property GlobalMemSize -Minimum).Minimum / 1GB ))} + # if ($OCLDevice[0].Platform.Version -match "CUDA\s+([\d\.]+)") {$_ | Add-Member CUDAVersion $Matches[1] -Force} + + if ($_.PowerLimits.Count -eq 0) { + $_ | Add-Member PowerLimits @(0) + } elseif ( + $_.Type -eq 'Intel' -or + ($_.Type -eq 'AMD' -and -not $abControl) + ) { + $_.PowerLimits = @(0) + } else { + $_.PowerLimits = @([int[]]($_.PowerLimits -split ',') | Sort-Object -Descending -Unique) + } - if ( - $_.PowerLimits.Count -eq 0 -or - @('Intel') -contains $_.Type -or - (@('AMD') -contains $_.Type -and !$abControl) - ) {$_.PowerLimits = @(0)} + $_ | Add-Member MinProfit ($Config.("MinProfit_" + $_.GroupName)) + $_ | Add-Member Algorithms ($Config.("Algorithms_" + $_.GroupName) -split ',') - $_ | Add-Member Algorithms ((Get-ConfigVariable ("Algorithms_" + $_.Type)) -split ',') - $Types += $_ + $_ } } - $Types #return + $DeviceGroups #return +} + +function Format-DeviceList { + param( + [Parameter(Mandatory = $false)] + [Array]$Devices, + + [Parameter(Mandatory = $false)] + [string]$List, + + [Parameter(Mandatory = $true)] + [ValidateSet('Clay', 'Nsg', 'Eth', 'Count', 'Mask')] + [string]$Type = 'Info' + ) + + if ($List -and -not $Devices) { + $Devices = $List -split ',' + } + + switch ($Type) { + Clay { ($Devices | ForEach-Object {'{0:X}' -f $_}) -join '' } # 012ABC + Nsg { ($Devices | ForEach-Object { "-d " + $_}) -join ' ' } # -d 0 -d 1 -d 2 -d 10 -d 11 -d 12 + Eth { $Devices -join ' ' } # 0 1 2 10 11 12 + Count { $Devices.count } # 6 + Mask { '{0:X}' -f [int]($Devices | ForEach-Object { [System.Math]::Pow(2, $_) } | Measure-Object -Sum).Sum } + } +} + + +function Get-SystemInfo () { + + $OperatingSystem = Get-CimInstance Win32_OperatingSystem + $Features = $($feat = @{}; switch -regex ((& .\Includes\CHKCPU32.exe /x) -split "") {"^\s*<_?(\w+)>(\d+).*" {$feat.($matches[1]) = [int]$matches[2]}}; $feat) + + [PSCustomObject]@{ + OSName = $OperatingSystem.Caption + OSVersion = [version]$OperatingSystem.Version + ComputerName = $env:COMPUTERNAME + CPUCores = $Features.cores + CPUThreads = $Features.threads + CPUFeatures = $Features + } } -Function Log-Message { +Function Write-Log { param( [Parameter()] [string]$Message, @@ -521,8 +590,7 @@ Function Log-Message { } } } -Set-Alias Log Log-Message - +Set-Alias Log Write-Log Function Read-KeyboardTimed { param( @@ -536,32 +604,32 @@ Function Read-KeyboardTimed { $KeyPressed = $null while ((New-TimeSpan $LoopStart (Get-Date)).Seconds -le $SecondsToWait -and $ValidKeys -notcontains $KeyPressed) { - if ($host.UI.RawUI.KeyAvailable) { - $Key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") + if ($Host.UI.RawUI.KeyAvailable) { + $Key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") $KeyPressed = $Key.character - while ($Host.UI.RawUI.KeyAvailable) {$host.UI.RawUI.FlushInputBuffer()} #keyb buffer flush + while ($Host.UI.RawUI.KeyAvailable) {$Host.UI.RawUI.FlushInputBuffer()} #keyb buffer flush } Start-Sleep -Milliseconds 30 } $KeyPressed } -function Clear-ScreenZone { - param( - [Parameter(Mandatory = $true)] - [int]$startY, - [Parameter(Mandatory = $true)] - [int]$endY - ) +# function Clear-ScreenZone { +# param( +# [Parameter(Mandatory = $true)] +# [int]$startY, +# [Parameter(Mandatory = $true)] +# [int]$endY +# ) - $BlankLine = " " * $Host.UI.RawUI.WindowSize.Width +# $BlankLine = " " * $Host.UI.RawUI.WindowSize.Width - Set-ConsolePosition 0 $start +# Set-ConsolePosition 0 $start - for ($i = $startY; $i -le $endY; $i++) { - $BlankLine | Out-Host - } -} +# for ($i = $startY; $i -le $endY; $i++) { +# $BlankLine | Out-Host +# } +# } function Invoke-TCPRequest { param( @@ -667,7 +735,7 @@ function Invoke-APIRequest { $CachePath = '.\Cache\' $CacheFile = $CachePath + [System.Web.HttpUtility]::UrlEncode($Url) + '.json' - if (!(Test-Path -Path $CachePath)) { New-Item -Path $CachePath -ItemType directory -Force | Out-Null } + if (-not (Test-Path -Path $CachePath)) { New-Item -Path $CachePath -ItemType directory -Force | Out-Null } if (Test-Path -LiteralPath $CacheFile -NewerThan (Get-Date).AddMinutes( - $Age)) { $Response = Get-Content -Path $CacheFile | ConvertFrom-Json } else { @@ -706,25 +774,25 @@ function Get-LiveHashRate { $Request = Invoke-TCPRequest -Port $Miner.ApiPort -Request $Message if ($Request) { - $Data = $Request.Substring($Request.IndexOf("{"), $Request.LastIndexOf("}") - $Request.IndexOf("{") + 1) -replace " ", "_" | ConvertFrom-Json + $Data = $Request.Substring($Request.IndexOf("{"), $Request.LastIndexOf("}") - $Request.IndexOf("{") + 1) | ConvertFrom-Json $HashRate = @( - [double]$Data.SUMMARY.HS_5s - [double]$Data.SUMMARY.KHS_5s * 1e3 - [double]$Data.SUMMARY.MHS_5s * 1e6 - [double]$Data.SUMMARY.GHS_5s * 1e9 - [double]$Data.SUMMARY.THS_5s * 1e12 - [double]$Data.SUMMARY.PHS_5s * 1e15 + [double]$Data.SUMMARY."HS 5s" + [double]$Data.SUMMARY."MHS 5s" * 1e6 + [double]$Data.SUMMARY."KHS 5s" * 1e3 + [double]$Data.SUMMARY."GHS 5s" * 1e9 + [double]$Data.SUMMARY."THS 5s" * 1e12 + [double]$Data.SUMMARY."PHS 5s" * 1e15 ) | Where-Object {$_ -gt 0} | Select-Object -First 1 if (-not $HashRate) { $HashRate = @( - [double]$Data.SUMMARY.HS_av - [double]$Data.SUMMARY.KHS_av * 1e3 - [double]$Data.SUMMARY.MHS_av * 1e6 - [double]$Data.SUMMARY.GHS_av * 1e9 - [double]$Data.SUMMARY.THS_av * 1e12 - [double]$Data.SUMMARY.PHS_av * 1e15 + [double]$Data.SUMMARY."HS av" + [double]$Data.SUMMARY."MHS av" * 1e6 + [double]$Data.SUMMARY."KHS av" * 1e3 + [double]$Data.SUMMARY."GHS av" * 1e9 + [double]$Data.SUMMARY."THS av" * 1e12 + [double]$Data.SUMMARY."PHS av" * 1e15 ) | Where-Object {$_ -gt 0} | Select-Object -First 1 } } @@ -768,7 +836,6 @@ function Get-LiveHashRate { Ubqhash* { $Multiplier *= 1000 } } } - $HashRate = @( [double]$Data.result[2].Split(";")[0] * $Multiplier [double]$Data.result[4].Split(";")[0] * $Multiplier @@ -1067,7 +1134,7 @@ function Expand-WebRequest { try { if (Test-Path -LiteralPath $FilePath) { if ($SHA256 -and (Get-FileHash -Path $FilePath -Algorithm SHA256).Hash -ne $SHA256) { - Log-Message "Existing file hash doesn't match. Will re-download." -Severity Warn + Log "Existing file hash doesn't match. Will re-download." -Severity Warn Remove-Item $FilePath } } @@ -1076,7 +1143,7 @@ function Expand-WebRequest { } if (Test-Path -LiteralPath $FilePath) { if ($SHA256 -and (Get-FileHash -Path $FilePath -Algorithm SHA256).Hash -ne $SHA256) { - Log-Message "File hash doesn't match. Removing file." -Severity Warn + Log "File hash doesn't match. Removing file." -Severity Warn } elseif (@('.msi', '.exe') -contains (Get-Item $FilePath).Extension) { Start-Process $FilePath "-qb" -Wait } else { @@ -1095,13 +1162,10 @@ function Get-Pools { [String]$Querymode, [Parameter(Mandatory = $false)] [array]$PoolsFilterList = $null, - #[array]$PoolsFilterList='Mining_pool_hub', [Parameter(Mandatory = $false)] [array]$CoinFilterList, - #[array]$CoinFilterList = ('GroestlCoin','Feathercoin','zclassic'), [Parameter(Mandatory = $false)] [string]$Location = $null, - #[string]$Location='EU' [Parameter(Mandatory = $false)] [array]$AlgoFilterList, [Parameter(Mandatory = $false)] @@ -1109,11 +1173,7 @@ function Get-Pools { ) #in detail mode returns a line for each pool/algo/coin combination, in info mode returns a line for pool - if ($location -eq 'GB') {$location = 'EU'} - - $PoolsFolderContent = Get-ChildItem ($PSScriptRoot + '\pools') -File | Where-Object {$PoolsFilterList.Count -eq 0 -or (Compare-Object $PoolsFilterList $_.BaseName -IncludeEqual -ExcludeDifferent | Measure-Object).Count -gt 0} - - $ChildItems = @() + $PoolsFolderContent = Get-ChildItem ($PSScriptRoot + '\Pools\*') -File -Include '*.ps1' | Where-Object {$PoolsFilterList.Count -eq 0 -or (Compare-Object $PoolsFilterList $_.BaseName -IncludeEqual -ExcludeDifferent | Measure-Object).Count -gt 0} if ($null -eq $Info) { $Info = [PSCustomObject]@{} } @@ -1122,10 +1182,10 @@ function Get-Pools { $Info | Add-Member SharedFile [string]$null - $PoolsFolderContent | ForEach-Object { + $ChildItems = $PoolsFolderContent | ForEach-Object { $Basename = $_.BaseName - $SharedFile = $PSScriptRoot + "\" + $Basename + [string](Get-Random -minimum 0 -maximum 9999999) + ".tmp" + $SharedFile = $PSScriptRoot + "\Cache\" + $Basename + [string](Get-Random -minimum 0 -maximum 9999999) + ".tmp" $Info.SharedFile = $SharedFile if (Test-Path $SharedFile) {Remove-Item $SharedFile} @@ -1134,7 +1194,7 @@ function Get-Pools { $Content = Get-Content $SharedFile | ConvertFrom-Json Remove-Item $SharedFile } else { $Content = $null } - $Content | ForEach-Object {$ChildItems += [PSCustomObject]@{Name = $Basename; Content = $_}} + $Content | ForEach-Object {[PSCustomObject]@{Name = $Basename; Content = $_}} } $AllPools = $ChildItems | ForEach-Object {if ($_.Content) {$_.Content | Add-Member @{Name = $_.Name} -PassThru}} @@ -1143,10 +1203,10 @@ function Get-Pools { #Apply filters $AllPools2 = @() - if ($Querymode -eq "core" -or $Querymode -eq "menu" ) { + if ($Querymode -eq "Core" -or $Querymode -eq "Menu" ) { foreach ($Pool in $AllPools) { #must have wallet - if (!$Pool.User) {continue} + if (-not $Pool.User) {continue} # Include pool algos and coins if ( @@ -1158,7 +1218,7 @@ function Get-Pools { @($Config.("IncludeCoins_" + $Pool.PoolName) -split ',') -notcontains $Pool.Info ) ) { - Log-Message "Excluding $($Pool.Algorithm)/$($Pool.Info) on $($Pool.PoolName) due to Include filter" -Severity Debug + Log "Excluding $($Pool.Algorithm)/$($Pool.Info) on $($Pool.PoolName) due to Include filter" -Severity Debug continue } @@ -1167,7 +1227,7 @@ function Get-Pools { @($Config.("ExcludeAlgos_" + $Pool.PoolName) -split ',') -contains $Pool.Algorithm -or @($Config.("ExcludeCoins_" + $Pool.PoolName) -split ',') -contains $Pool.Info ) { - Log-Message "Excluding $($Pool.Algorithm)/$($Pool.Info) on $($Pool.PoolName) due to Exclude filter" -Severity Debug + Log "Excluding $($Pool.Algorithm)/$($Pool.Info) on $($Pool.PoolName) due to Exclude filter" -Severity Debug continue } @@ -1183,7 +1243,7 @@ function Get-Pools { elseif ($Pool.Location -eq 'US' -and $Location -eq 'EU') {$Pool.LocationPriority = 2} ## factor actual24h if price differs by factor of 10 - if ($Pool.Actual24h -gt 0) { + if ($Pool.Actual24h) { $factor = 0.2 if ($Pool.Price -gt ($Pool.Actual24h * 10)) {$Pool.Price = $Pool.Price * $factor + $Pool.Actual24h * (1 - $factor)} if ($Pool.Price24h -gt ($Pool.Actual24h * 10)) {$Pool.Price24h = $Pool.Price24h * $factor + $Pool.Actual24h * (1 - $factor)} @@ -1210,11 +1270,58 @@ function Get-Pools { $Return } +function Get-Configs { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [String]$Type + ) + if (Test-Path ".\Config\$Type.json") { + Get-Content ".\Config\$Type.json" | ConvertFrom-Json + } +} + +function Get-Updates { + try { + $Request = Invoke-APIRequest -Url "https://api.github.com/repos/yuzi-co/$($Release.Application)/releases/latest" -Age 60 + $RemoteVersion = ($Request.tag_name -replace '[^\d.]') + $Uri = $Request.assets | Where-Object Name -eq "$($Release.Application)-v$RemoteVersion.7z" | Select-Object -ExpandProperty browser_download_url + + if ([version]$RemoteVersion -gt [version]$Release.Version) { + Log "$($Release.Application) v$($Release.Version) is out of date. There is an updated version available at $Uri" -Severity Warn + } elseif ([version]$RemoteVersion -lt [version]$Release.Version) { + Log "$($Release.Application) v$($Release.Version) is pre-release version. Use at your own risk" -Severity Warn + } + } catch { + Log "Failed to get $($Release.Application) updates." -Severity Warn + } +} + function Get-Config { $Result = @{} switch -regex -file config.ini { "^\s*(\w+)\s*=\s*(.*)" { + $name, $value = $matches[1..2] + $Result[$name] = switch -wildcard ($value.Trim()) { + 'enable*' {$true} + 'disable*' {$false} + 'on' {$true} + 'off' {$false} + 'yes' {$true} + 'no' {$false} + Default {$value.Trim()} + } + } + } + $Result # Return Value +} + +function Get-Wallets { + + $Result = @{} + switch -regex -file config.ini { + "^\s*WALLET_(\w+)\s*=\s*(.*)" { $name, $value = $matches[1..2] $Result[$name] = $value.Trim() } @@ -1249,14 +1356,14 @@ function Get-BestHashRateAlgo { if ($Hrs -gt $BestHashRate) { $BestHashRate = $Hrs - $Miner = ($_.pschildname -split '_')[0] + $MinerName = ($_.pschildname -split '_')[0] } - $Return = [PSCustomObject]@{ + $Miner = [PSCustomObject]@{ HashRate = $BestHashRate - Miner = $Miner + Miner = $MinerName } } - $Return + $Miner } function Set-ConsolePosition ([int]$x, [int]$y) { @@ -1278,15 +1385,16 @@ function Get-ConsolePosition ([ref]$x, [ref]$y) { remove-variable position } -function Print-HorizontalLine ([string]$Title) { +function Out-HorizontalLine ([string]$Title) { $Width = $Host.UI.RawUI.WindowSize.Width if ([string]::IsNullOrEmpty($Title)) {$str = "-" * $Width} else { - $str = ("-" * ($Width / 2 - ($Title.Length / 2) - 4)) + " " + $Title + " " - $str += "-" * ($Width - $str.Length) + $str = '{white}' + ("-" * [math]::floor(($Width - $Title.Length - 4) / 2)) + $str += "{green} " + $Title + " " + $str += '{white}' + ("-" * [math]::floor(($Width + 1 - $Title.Length - 4) / 2)) } - $str | Out-Host + Write-Color $str } function Set-WindowSize ([int]$Width, [int]$Height) { @@ -1309,7 +1417,7 @@ function Get-AlgoUnifiedName ([string]$Algo) { $Algo = $Algo -ireplace '[^\w]' if ($Algo) { - $Algos = Get-Content -Path ".\Includes\algorithms.json" | ConvertFrom-Json + $Algos = Get-Content -Path ".\Data\algorithms.json" | ConvertFrom-Json if ($Algos.$Algo) { $Algos.$Algo } else { $Algo } } @@ -1353,7 +1461,7 @@ function Get-HashRates { if ($AlgoLabel -eq "") {$AlgoLabel = 'X'} $Pattern = $PSScriptRoot + "\Stats\" + $MinerName + "_" + $Algorithm + "_" + $GroupName + "_" + $AlgoLabel + "_PL" + $PowerLimit + "_HashRate" - if (!(Test-Path -path "$Pattern.csv")) { + if (-not (Test-Path -path "$Pattern.csv")) { if (Test-Path -path "$Pattern.txt") { $Content = (Get-Content -path "$Pattern.txt") try {$Content = $Content | ConvertFrom-Json} catch { @@ -1364,14 +1472,29 @@ function Get-HashRates { } } else { $Content = (Get-Content -path "$Pattern.csv") - try {$Content = $Content | ConvertFrom-Csv} catch { + try { + $Content = $Content | ConvertFrom-Csv + } catch { #if error from convert from json delete file - Log-Message "Corrupted file $Pattern.csv, deleting" -Severity Warn + Log "Corrupted file $Pattern.csv, deleting" -Severity Warn Remove-Item -path "$Pattern.csv" } } - if ($null -eq $Content) {$Content = @()} + if ($Content) { + $Content | ForEach-Object { + $_.Speed = [decimal]$_.Speed + $_.SpeedDual = [decimal]$_.SpeedDual + $_.Power = [int]$_.Power + + if ($_.Activity) { $_.PSObject.Properties.Remove('Activity') } + if ($_.Benchmarking) { $_.PSObject.Properties.Remove('Benchmarking') } + if ($_.TimeSinceStartInterval) { $_.PSObject.Properties.Remove('TimeSinceStartInterval') } + if ($_.BenchmarkIntervalTime) { $_.PSObject.Properties.Remove('BenchmarkIntervalTime') } + } + } else { + $Content = @() + } $Content } @@ -1415,37 +1538,37 @@ function Get-Stats { if ($AlgoLabel -eq "") {$AlgoLabel = 'X'} $Pattern = $PSScriptRoot + "\Stats\" + $MinerName + "_" + $Algorithm + "_" + $GroupName + "_" + $AlgoLabel + "_PL" + $PowerLimit + "_stats" - if (!(Test-Path -path "$Pattern.json")) { + if (-not (Test-Path -path "$Pattern.json")) { if (Test-Path -path "$Pattern.txt") {Rename-Item -Path "$Pattern.txt" -NewName "$Pattern.json"} } else { $Content = (Get-Content -path "$Pattern.json") try {$Content = $Content | ConvertFrom-Json} catch { #if error from convert from json delete file - Log-Message "Corrupted file $Pattern.json, deleting" -Severity Warn + Log "Corrupted file $Pattern.json, deleting" -Severity Warn Remove-Item -path "$Pattern.json" } } $Content } -function Get-AllStats { - $Stats = @() - if (-not (Test-Path "Stats")) {New-Item "Stats" -ItemType "directory" | Out-Null} - Get-ChildItem "Stats" -Filter "*_stats.json" | Foreach-Object { - $Name = $_.BaseName - $_ | Get-Content | ConvertFrom-Json | ForEach-Object { - $Values = $Name -split '_' - $Stats += @{ - MinerName = $Values[0] - Algorithm = $Values[1] - GroupName = $Values[2] - AlgoLabel = $Values[3] - PowerLimit = ($Values[4] -split 'PL')[-1] - Stats = $_ - } - } - } - Return $Stats -} +# function Get-AllStats { +# $Stats = @() +# if (-not (Test-Path "Stats")) {New-Item "Stats" -ItemType "directory" | Out-Null} +# Get-ChildItem "Stats" -Filter "*_stats.json" | Foreach-Object { +# $Name = $_.BaseName +# $_ | Get-Content | ConvertFrom-Json | ForEach-Object { +# $Values = $Name -split '_' +# $Stats += @{ +# MinerName = $Values[0] +# Algorithm = $Values[1] +# GroupName = $Values[2] +# AlgoLabel = $Values[3] +# PowerLimit = ($Values[4] -split 'PL')[-1] +# Stats = $_ +# } +# } +# } +# Return $Stats +# } function Set-Stats { @@ -1490,17 +1613,17 @@ function Start-Downloader { $null = New-Item (Split-Path $Path) -ItemType "Directory" (New-Object System.Net.WebClient).DownloadFile($URI, $Path) if ($SHA256 -and (Get-FileHash -Path $Path -Algorithm SHA256).Hash -ne $SHA256) { - Log-Message "File hash doesn't match. Removing file." -Severity Warn + Log "File hash doesn't match. Removing file." -Severity Warn Remove-Item $Path } } else { # downloading an archive or installer - Log-Message "Downloading $URI" -Severity Info + Log "Downloading $URI" -Severity Info Expand-WebRequest -URI $URI -Path $ExtractionPath -SHA256 $SHA256 -ErrorAction Stop } } catch { $Message = "Cannot download $URI" - Log-Message $Message -Severity Warn + Log $Message -Severity Warn } } } @@ -1586,17 +1709,74 @@ function Test-DeviceGroupsConfig ($Types) { $DetectedDevices = @() $DetectedDevices += $Devices | Where-Object Group -eq $_.GroupName if ($DetectedDevices.count -eq 0) { - Log-Message "No Devices for group " + $_.GroupName + " was detected, activity based watchdog will be disabled for that group, this can happens if AMD beta blockchain drivers are installed or incorrect gpugroups config" -Severity Warn + Log ("No Devices for group " + $_.GroupName + " was detected, activity based watchdog will be disabled for that group, this can happens if AMD beta blockchain drivers are installed or incorrect gpugroups config") -Severity Warn Start-Sleep -Seconds 5 } elseif ($DetectedDevices.count -ne $_.DevicesCount) { - Log-Message "Mismatching Devices for group " + $_.GroupName + " was detected, check gpugroups config and gpulist.bat" -Severity Warn + Log ("Mismatching Devices for group " + $_.GroupName + " was detected, check gpugroups config and gpulist.bat") -Severity Warn Start-Sleep -Seconds 5 } } $TotalMem = (($Types | Where-Object Type -ne 'CPU').OCLDevices.GlobalMemSize | Measure-Object -Sum).Sum / 1GB $TotalSwap = (Get-CimInstance Win32_PageFile | Select-Object -ExpandProperty FileSize | Measure-Object -Sum).Sum / 1GB if ($TotalMem -gt $TotalSwap) { - Log-Message "Make sure you have at least $TotalMem GB swap configured" -Severity Warn + Log "Make sure you have at least $TotalMem GB swap configured" -Severity Warn Start-Sleep -Seconds 5 } } + +function Start-Autoexec { + [cmdletbinding()] + param( + [ValidateRange(-2, 3)] + [Parameter(Mandatory = $false)] + [Int]$Priority = 0 + ) + if (-not (Test-Path ".\Autoexec.txt") -and (Test-Path ".\Data\Autoexec.default.txt")) {Copy-Item ".\Data\Autoexec.default.txt" ".\Autoexec.txt" -Force -ErrorAction Ignore} + [System.Collections.ArrayList]$Script:AutoexecCommands = @() + foreach ($cmd in @(Get-Content ".\Autoexec.txt" -ErrorAction Ignore | Select-Object)) { + if ($cmd -match "^[\s\t]*`"(.+?)`"(.*)$") { + try { + $Job = Start-SubProcess -FilePath "$($Matches[1])" -ArgumentList "$($Matches[2].Trim())" -WorkingDirectory (Split-Path "$($Matches[1])") -Priority $Priority + if ($Job) { + $Job | Add-Member FilePath "$($Matches[1])" -Force + $Job | Add-Member Arguments "$($Matches[2].Trim())" -Force + $Job | Add-Member HasOwnMinerWindow $true -Force + Log "Autoexec command started: $($Matches[1]) $($Matches[2].Trim())" -Severity Info + $Script:AutoexecCommands.Add($Job) | Out-Null + } + } catch {} + } + } +} + +function Stop-Autoexec { + $Script:AutoexecCommands | Where-Object Process | Foreach-Object { + Stop-SubProcess -Job $_ -Title "Autoexec command" -Name "$($_.FilePath) $($_.Arguments)" + } +} + +function Write-Color() { + Param ( + [string] $text = $(Write-Error "You must specify some text"), + [switch] $NoNewLine = $false + ) + + $startColor = $host.UI.RawUI.ForegroundColor; + + $text.Split( [char]"{", [char]"}" ) | ForEach-Object { $i = 0; } { + if ($i % 2 -eq 0) { + Write-Host $_ -NoNewline; + } else { + if ($_ -in [enum]::GetNames("ConsoleColor")) { + $host.UI.RawUI.ForegroundColor = ($_ -as [System.ConsoleColor]); + } + } + + $i++; + } + + if (!$NoNewLine) { + Write-Host; + } + $host.UI.RawUI.ForegroundColor = $startColor; +} diff --git a/Includes/Afterburner.ps1 b/Includes/Afterburner.ps1 index 1cd902cd..20fea190 100644 --- a/Includes/Afterburner.ps1 +++ b/Includes/Afterburner.ps1 @@ -5,25 +5,25 @@ $baseFolder = Split-Path -parent $script:MyInvocation.MyCommand.Path try { Add-Type -Path $baseFolder\MSIAfterburner.NET.dll } catch { - Log-Message $_.Exception.Message -Severity Warn - Log-Message "Failed to load Afterburner interface library" -Severity Error + Log $_.Exception.Message -Severity Warn + Log "Failed to load Afterburner interface library" -Severity Error Exit } try { - $abMonitor = New-Object MSI.Afterburner.HardwareMonitor + $global:abMonitor = New-Object MSI.Afterburner.HardwareMonitor } catch { - Log-Message $_.Exception.Message -Severity Warn - Log-Message "Failed to create MSI Afterburner Monitor object. Falling back to standard monitoring." -Severity Warn + Log $_.Exception.Message -Severity Warn + Log "Failed to create MSI Afterburner Monitor object. Falling back to standard monitoring." -Severity Warn $abMonitor = $false Start-Sleep -Seconds 5 } try { - $abControl = New-Object MSI.Afterburner.ControlMemory + $global:abControl = New-Object MSI.Afterburner.ControlMemory } catch { - Log-Message $_.Exception.Message -Severity Warn - Log-Message "Failed to create MSI Afterburner Control object. PowerLimits will not be available" -Severity Warn + Log $_.Exception.Message -Severity Warn + Log "Failed to create MSI Afterburner Control object. PowerLimits will not be available" -Severity Warn $abControl = $false Start-Sleep -Seconds 5 } @@ -68,8 +68,8 @@ function Get-AfterburnerDevices ($Type) { try { $abControl.ReloadAll() } catch { - Log-Message $_.Exception.Message -Severity Warn - Log-Message "Failed to communicate with MSI Afterburner" -Severity Error + Log $_.Exception.Message -Severity Warn + Log "Failed to communicate with MSI Afterburner" -Severity Error Exit } diff --git a/Includes/ApiListener.ps1 b/Includes/ApiListener.ps1 deleted file mode 100644 index 7cb89692..00000000 --- a/Includes/ApiListener.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -Param ( - - [Parameter()] - [String] $SharedFile, #complete path - #[String] $SharedFile='C:\Users\admin\Desktop\Forager\ApiShared34474029.tmp', - - [Parameter()] - [Int] $Port = 9999, - - [Parameter()] - [String] $Url = "", - - [Parameter()] - [System.Net.AuthenticationSchemes] $Auth = [System.Net.AuthenticationSchemes]::IntegratedWindowsAuthentication - ) - - $ErrorActionPreference = "Stop" - - if ($Url.Length -gt 0 -and -not $Url.EndsWith('/')) { - $Url += "/" - } - - $Host.UI.RawUI.WindowTitle = "Forager API Listener" - - $listener = New-Object System.Net.HttpListener - $prefix = "http://*:$Port/$Url" - $listener.Prefixes.Add($prefix) - $listener.AuthenticationSchemes = $Auth - - $listener.Start() - - Write-Warning "Forager Api Listening on port $port......." - Write-Warning "Don´t close this window while you want to use API." - - while ($true) { - $statusCode = 200 - $context = $listener.GetContext() - - Write-Warning "Received request $(Get-Date)" - - $request = $context.Request - $command = $request.QueryString.Item("command") - if ($command -eq "exit") { - Write-Warning "Received command to exit listener" - break - } - - try{$commandOutput = get-content -path $SharedFile -raw } catch{$commandOutput=""} - - if ($commandOutput -ne $null -and $commandOutput -ne "") { - $A=(Get-Date) - $B=([datetime]($commandOutput |convertfrom-json).RefreshDate) - $Ago = $A - $B - if ($Ago.TotalSeconds -gt 20) {$commandOutput=""} #check info refresh date - - if ($Ago.TotalSeconds -gt 300) {break} #check info refresh date - } - - $response = $context.Response - $response.StatusCode = $statusCode - - $Response.ContentEncoding = [System.Text.Encoding]::utf8 - $Response.ContentType = "text/plain; charset=utf-8" - - if (!$commandOutput) {$commandOutput = [string]::Empty} - $buffer = [System.Text.Encoding]::utf8.GetBytes($commandOutput) - - $response.ContentLength64 = $buffer.Length - $output = $response.OutputStream - - try { - $output.Write($buffer,0,$buffer.Length) - $output.Close() - } catch{} - - } - -$listener.Stop() -stop-process -Id $PID diff --git a/Includes/FarmMonitor.ps1 b/Includes/FarmMonitor.ps1 deleted file mode 100644 index 41d79573..00000000 --- a/Includes/FarmMonitor.ps1 +++ /dev/null @@ -1,122 +0,0 @@ -. .\Include.ps1 - -$config = Get-Config -$FarmRigs = $config.FarmRigs | ConvertFrom-Json -$smtp = $config.Smtp#Port# |ConvertFrom-Json - -#Look for SMTP Password, propmpt and store if not available - -if ($config.NotificationMail -ne $null -and $config.NotificationMail -ne "") { - #mail notification enabled - - if (Test-Path ".\smtp.ctr") { - $EncPass = Get-Content -path ".\smtp.ctr" | ConvertTo-SecureString - } else { - - $PlainPass = Read-Host -Prompt 'TYPE YOUR SMTP SERVER ACCOUNT PASSWORD:' - $EncPass = ConvertTo-SecureString $PlainPass -AsPlainText -Force - ConvertFrom-SecureString $EncPass | Set-Content -path ".\smtp.ctr" - Remove-Variable PlainPass #for security pass is not stored unencrypted in memory - } - -} - -$Host.UI.RawUI.WindowTitle = "Forager Farm Monitor" - -$FarmRigs | ForEach-Object { - $_ | Add-Member LastContent $null - $_ | Add-Member State $null - $_ | Add-Member LastState $null - $_ | Add-Member LastTime $null - $_ | Add-Member ChangeStateTime (Get-Date) - $_ | Add-Member PendingNotify $false - $_ | Add-Member WorkerName "" -} - -while ($true) { - - $Requests = @() - ForEach ($rig in $FarmRigs) { - $uri = "http://" + $rig.IpOrLanName + ':' + $rig.ApiPort - $rig.LastTime = Get-Date - if ($rig.LastState -ne $rig.State -and $rig.LastState -ne $null) { - $rig.ChangeStateTime = Get-Date - if ($rig.PendingNotify) - {$rig.PendingNotify = $false} #state changes before last change was notified, must anulate notify - else - {$rig.PendingNotify = $true} - } - $rig.LastState = $rig.State - try { - $Request = Invoke-restmethod $uri -timeoutsec 10 -UseDefaultCredential - if ($request.ActiveMiners -ne $null) {$rig.State = "OK"} else {$rig.State = "ERROR"} - $rig.LastContent = $Request - } catch { - $rig.State = "ERROR" - } - } - try {Set-WindowSize 185 60} catch {} - Clear-Host - - Print-HorizontalLine ("Forager FARM MONITOR (" + (Get-Date).tostring("g") + ")") - "" | Out-Host - - $FarmRigs | ForEach-Object { - - Print-HorizontalLine ($_.IpOrLanName + " (" + $_.LastContent.config.WorkerName + ")") - - if ($_.ChangeStateTime -ne $null) {$ChangeStateElapsed = ((Get-Date) - [datetime]$_.ChangeStateTime).minutes} else {$ChangeStateElapsed = 0} #calculates time since state change - - if ($_.State -eq "OK") { - - "Mode: " + $_.LastContent.params.MiningMode + " Pool/s: " + ($_.LastContent.params.pools -join ",") + " Release: " + $_.LastContent.Release |Out-Host - - $_.WorkerName = $_.LastContent.config.WorkerName - - $_.LastContent.Activeminers | Format-Table ( - @{Label = "GroupName"; Expression = {$_.GroupName}}, - @{Label = "PwLim"; Expression = {$_.PwLim} ; Align = 'right'}, - @{Label = "LocalSpeed"; Expression = {$_.LocalSpeed} ; Align = 'right'}, - @{Label = "mBTC/Day"; Expression = {$_.mbtcDay} ; Align = 'right'}, - @{Label = "Rev/Day"; Expression = {$_.RevDay} ; Align = 'right'}, - @{Label = "Profit/Day"; Expression = {$_.ProfitDay} ; Align = 'right'}, - @{Label = "Algorithm"; Expression = {$_.Algorithm}}, - @{Label = "Coin"; Expression = {$_.Coin}}, - @{Label = "Miner"; Expression = {$_.Miner}}, - @{Label = "Power"; Expression = {$_.Power} ; Align = 'right'}, - @{Label = "Efficiency"; Expression = {$_.EfficiencyH} ; Align = 'right'}, - @{Label = "Efficiency"; Expression = {$_.EfficiencyW} ; Align = 'right'}, - @{Label = "Pool"; Expression = {$_.Pool}} - ) | Out-Host - } else { - "" | Out-Host - write-warning "NOT RESPONDING FOR $ChangeStateElapsed MINUTES...." - "" | Out-Host - } - - if ($ChangeStateElapsed -gt 4) { - #change state 5 minutes ago - #if ($true) { - - if ($config.NotificationMail -ne $null -and $config.NotificationMail -ne "" -and $_.Notifications -and $_.PendingNotify ) { - #mail notification enabled - - $_.PendingNotify = $false - - $mailmsg = $_.IpOrLanName + "(" + $_.WorkerName + ") is " - - if ($_.State -eq 'OK') {$mailmsg += "ONLINE"} else {$mailmsg += "OFFLINE"} - - $Creds = New-Object PSCredential $smtp.user, $EncPass - - if ($smtp.ssl) { - Send-MailMessage -usessl -To $config.NotificationMail -From $smtp.user -Subject $mailmsg -smtp ($smtp.url) -Port ($smtp.port) -Credential $Creds - } else { - Send-MailMessage -To $config.NotificationMail -From $smtp.user -Subject $mailmsg -smtp ($smtp.url) -Port ($smtp.port) -Credential $creds - } - } - } - } - - Start-Sleep -Seconds $Config.RefreshInterval -} diff --git a/Includes/ReportStatus.ps1 b/Includes/ReportStatus.ps1 index e81366af..e7bd9120 100644 --- a/Includes/ReportStatus.ps1 +++ b/Includes/ReportStatus.ps1 @@ -14,11 +14,11 @@ $MinerReport = ConvertTo-Json @($ActiveMiners.SubMiners | Where-Object Status -e [PSCustomObject]@{ Name = $M.Name # Path = Resolve-Path -Relative $_.Path ## Not the most useful info - Path = $M.Symbol + $(if ($M.AlgorithmDual) {'_' + $M.SymbolDual}) + Path = $M.Pool.Symbol + $(if ($M.AlgorithmDual) {'_' + $M.PoolDual.Symbol}) Type = $M.DeviceGroup.GroupName Active = $(if ($_.Stats.Activetime -le 3600) {"{0:N1} mins" -f ($_.Stats.ActiveTime / 60)} else {"{0:N1} hours" -f ($_.Stats.ActiveTime / 3600)}) Algorithm = $M.Algorithm + $(if ($M.AlgorithmDual) {'_' + $M.AlgorithmDual}) + $M.BestBySwitch + $(if ($M.AlgoLabel) {"|$($M.AlgoLabel)"}) - Pool = $M.PoolName + '-' + $M.Location + $(if ($M.AlgorithmDual) {"/$($M.PoolNameDual + '-' + $M.LocationDual)"}) + Pool = $M.Pool.PoolName + '-' + $M.Pool.Location + $(if ($M.AlgorithmDual) {"/$($M.PoolDual.PoolName + '-' + $M.PoolDual.Location)"}) CurrentSpeed = (ConvertTo-Hash $_.SpeedLive) + $(if ($M.AlgorithmDual) {"/$(ConvertTo-Hash $_.SpeedLiveDual)"}) -replace ",", "." EstimatedSpeed = (ConvertTo-Hash $_.HashRate) + $(if ($M.AlgorithmDual) {"/$(ConvertTo-Hash $_.HashRateDual)"}) -replace ",", "." PID = $M.Process.Id diff --git a/Miner.ps1 b/Miner.ps1 index cfab30da..9cf93a27 100644 --- a/Miner.ps1 +++ b/Miner.ps1 @@ -7,56 +7,30 @@ param( [string]$CoinsName = $null ) -. .\Include.ps1 +Import-Module .\Include.psm1 + +$global:Config = Get-Config +$global:Wallets =Get-Wallets #check parameters if (($MiningMode -eq "MANUAL") -and ($PoolsName.count -gt 1)) {Write-Warning "ONLY ONE POOL CAN BE SELECTED ON MANUAL MODE"} -#--------------Load config.ini file - -$Currency = Get-ConfigVariable "Currency" -$Location = Get-ConfigVariable "Location" -$FarmRigs = Get-ConfigVariable "FarmRigs" -$LocalCurrency = Get-ConfigVariable "LocalCurrency" -if (-not $LocalCurrency) { - #for old config.ini compatibility - $LocalCurrency = switch ($location) { - 'EU' {"EUR"} - 'US' {"USD"} - 'ASIA' {"USD"} - 'GB' {"GBP"} - default {"USD"} - } -} - -#needed for anonymous pools load -$CoinsWallets = @{} -switch -regex -file config.ini { - "^\s*WALLET_(\w+)\s*=\s*(.*)" { - $name, $value = $matches[1..2] - $CoinsWallets[$name] = $value.Trim() - } -} -$UserName = Get-ConfigVariable "UserName" - $SelectedOption = "" #-----------------Ask user for mode to mining AUTO/MANUAL to use, if a pool is indicated in parameters no prompt Clear-Host -Print-HorizontalLine "" -Print-HorizontalLine "SELECT OPTION" -Print-HorizontalLine "" - -$Modes = @() -$Modes += [PSCustomObject]@{"Option" = 0; "Mode" = 'Automatic'; "Explanation" = 'Automatically choose most profitable coin based on pools current statistics'} -$Modes += [PSCustomObject]@{"Option" = 1; "Mode" = 'Automatic24h'; "Explanation" = 'Automatically choose most profitable coin based on pools 24 hour statistics'} -$Modes += [PSCustomObject]@{"Option" = 2; "Mode" = 'Manual'; "Explanation" = 'Manual coin selection'} +Out-HorizontalLine "" +Out-HorizontalLine "SELECT OPTION" +Out-HorizontalLine "" + +$Modes = @( + [PSCustomObject]@{"Option" = 0; "Mode" = 'Automatic'; "Explanation" = 'Automatically choose most profitable coin based on pools current statistics'} + [PSCustomObject]@{"Option" = 1; "Mode" = 'Automatic24h'; "Explanation" = 'Automatically choose most profitable coin based on pools 24 hour statistics'} + [PSCustomObject]@{"Option" = 2; "Mode" = 'Manual'; "Explanation" = 'Manual coin selection'} +) -if ($FarmRigs) { - $Modes += [PSCustomObject]@{"Option" = 3; "Mode" = 'Farm Monitoring'; "Explanation" = 'I want to see my rigs state'} -} $Modes | Format-Table Option, Mode, Explanation If ($MiningMode -eq "") { @@ -65,256 +39,251 @@ If ($MiningMode -eq "") { Write-Host "SELECTED OPTION: $MiningMode" } else { Write-Host "SELECTED BY PARAMETER OPTION: $MiningMode" } -if ($MiningMode -ne "FARM MONITORING") { - #-----------------Ask user for pool/s to use, if a pool is indicated in parameters no prompt +#-----------------Ask user for pool/s to use, if a pool is indicated in parameters no prompt - $Pools = Get-Pools -Querymode "Info" | Where-Object ("ActiveOn" + $MiningMode + "Mode") -eq $true | Sort-Object name +$Pools = Get-Pools -Querymode "Info" | Where-Object ("ActiveOn" + $MiningMode + "Mode") -eq $true | Sort-Object name - $Pools | Add-Member Option "0" - $counter = 0 - $Pools | ForEach-Object { - $_.Option = $counter - $counter++} - - #Clear-Host - Print-HorizontalLine "" - Print-HorizontalLine "SELECT POOL/S TO MINE" - Print-HorizontalLine "" +$Pools | Add-Member Option "0" +$counter = 0 +$Pools | ForEach-Object { + $_.Option = $counter + $counter++ +} - $Pools | Format-Table Option, name, rewardtype, disclaimer +#Clear-Host +Out-HorizontalLine "" +Out-HorizontalLine "SELECT POOL/S TO MINE" +Out-HorizontalLine "" - If (-not $PoolsName) { - if ($MiningMode -eq "Manual") { - $SelectedOption = Read-Host -Prompt 'SELECT ONE OPTION:' - while ($SelectedOption -like '*,*') { - $SelectedOption = Read-Host -Prompt 'SELECT ONLY ONE OPTION:' - } - } else { - $SelectedOption = Read-Host -Prompt 'SELECT OPTION/S (separated by comma). 999 for all pools:' - } +$Pools | Format-Table Option, Name, RewardType, Disclaimer - if ($SelectedOption -eq "999") { - $PoolsName = $Pools.name -join ',' -replace "\s+" - } else { - $PoolsName = ($SelectedOption -split ',' | ForEach-Object {$Pools[$_].name}) -join ',' -replace "\s+" +If (-not $PoolsName) { + if ($MiningMode -eq "Manual") { + $SelectedOption = Read-Host -Prompt 'SELECT ONE OPTION:' + while ($SelectedOption -like '*,*') { + $SelectedOption = Read-Host -Prompt 'SELECT ONLY ONE OPTION:' } + } else { + $SelectedOption = Read-Host -Prompt 'SELECT OPTION/S (separated by comma). 999 for all pools:' + } - Write-Host "SELECTED OPTION: $PoolsName" + if ($SelectedOption -eq "999") { + $PoolsName = $Pools.name -join ',' -replace "\s+" } else { - Write-Host "SELECTED BY PARAMETER: $PoolsName" + $PoolsName = ($SelectedOption -split ',' | ForEach-Object {$Pools[$_].name}) -join ',' -replace "\s+" } - #-----------------Ask user for coins---------------------------------------------------- + Write-Host "SELECTED OPTION: $PoolsName" +} else { + Write-Host "SELECTED BY PARAMETER: $PoolsName" +} - if ($MiningMode -eq "manual") { +#-----------------Ask user for coins---------------------------------------------------- - If (-not $CoinsName) { +if ($MiningMode -eq "manual") { - #Load coins from pools - $CoinsPool = Get-Pools -Querymode "Menu" -PoolsFilterList $PoolsName -location $Location | Select-Object Info, Symbol, Algorithm, Workers, PoolHashRate, Blocks_24h, Price -unique | Sort-Object info + If (-not $CoinsName) { - $CoinsPool | Add-Member Option "0" - $CoinsPool | Add-Member YourHashRate ([Double]0.0) - $CoinsPool | Add-Member BTCPrice ([Double]0.0) - $CoinsPool | Add-Member Reward ([Double]0.0) - $CoinsPool | Add-Member BtcProfit ([Double]0.0) - $CoinsPool | Add-Member LocalProfit ([Double]0.0) - $CoinsPool | Add-Member LocalPrice ([Double]0.0) + #Load coins from pools + $CoinsPool = Get-Pools -Querymode "Core" -PoolsFilterList $PoolsName -location $Config.Location | Select-Object Info, Symbol, Algorithm, Workers, PoolHashRate, Blocks_24h, Price -unique | Sort-Object info - 'Calling Coindesk API' | Write-Host - $CDKResponse = try { Invoke-RestMethod -Uri "https://api.coindesk.com/v1/bpi/currentprice/$LocalCurrency.json" -UseBasicParsing -TimeoutSec 5 | Select-Object -ExpandProperty BPI } catch { $null; Write-Host "Not responding" } + $CoinsPool | Add-Member Option "0" + $CoinsPool | Add-Member YourHashRate ([Double]0.0) + $CoinsPool | Add-Member BTCPrice ([Double]0.0) + $CoinsPool | Add-Member Reward ([Double]0.0) + $CoinsPool | Add-Member BtcProfit ([Double]0.0) + $CoinsPool | Add-Member LocalProfit ([Double]0.0) + $CoinsPool | Add-Member LocalPrice ([Double]0.0) - if (($CoinsPool | Where-Object Price -gt 0).count -gt 0) { - $Counter = 0 - foreach ($Coin in $CoinsPool) { - $Coin.Option = $Counter - $counter++ - $Coin.YourHashRate = (Get-BestHashRateAlgo $Coin.Algorithm).HashRate - $Coin.BtcProfit = $Coin.price * $Coin.YourHashRate - $Coin.LocalProfit = $CDKResponse.$LocalCurrency.rate_float * [double]$Coin.BtcProfit - } - } else { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - 'Calling CoinMarketCap API' | Write-Host - $CMCResponse = try { Invoke-RestMethod -Uri "https://api.coinmarketcap.com/v1/ticker/?limit=0" -UseBasicParsing -TimeoutSec 10 } catch { $null; Write-Host "Not responding" } - 'Calling Bittrex API' | Write-Host - $BTXResponse = try { Invoke-RestMethod -Uri "https://bittrex.com/api/v1.1/public/getmarketsummaries" -UseBasicParsing -TimeoutSec 10 | Select-Object -ExpandProperty 'result' } catch { $null; Write-Host "Not responding" } - # 'Calling Cryptopia API' | Write-Host - # $CRYResponse = try { Invoke-RestMethod -Uri "https://www.cryptopia.co.nz/api/GetMarkets/BTC" -UseBasicParsing -TimeoutSec 10 | Select-Object -ExpandProperty 'data' } catch { $null; Write-Host "Not responding" } - - #Add main page coins - $WtmUrl = 'https://whattomine.com/coins.json?' + - @( - 'bcd=true&factor[bcd_hr]=10&factor[bcd_p]=0' #BCD - 'bk14=true&factor[bk14_hr]=10&factor[bk14_p]=0' #Decred - 'cn=true&factor[cn_hr]=10&factor[cn_p]=0' #CryptoNight - 'cn7=true&factor[cn7_hr]=10&factor[cn7_p]=0' #CryptoNightV7 - 'cn8=true&factor[cn8_hr]=10&factor[cn8_p]=0' #CryptoNightV8 - 'cnf=true&factor[cnf_hr]=10&factor[cnf_p]=0' #CryptoNightFast - 'cnh=true&factor[cnh_hr]=10&factor[cnh_p]=0' #CryptoNightHeavy - 'cnhn=true&factor[cnhn_hr]=10&factor[cnhn_p]=0' #CryptoNightHaven - 'cns=true&factor[cns_hr]=10&factor[cns_p]=0' #CryptoNightSaber - 'cr29=true&factor[cr29_hr]=10&factor[cr29_p]=0' #Cuckaroo29 - 'eq=true&factor[eq_hr]=10&factor[eq_p]=0' #Equihash - 'eqa=true&factor[eqa_hr]=10&factor[eqa_p]=0' #AION (Equihash210) - 'eth=true&factor[eth_hr]=10&factor[eth_p]=0' #Ethash - 'grof=true&factor[gro_hr]=10&factor[gro_p]=0' #Groestl - 'hx=true&factor[hx_hr]=10&factor[hx_p]=0' #Hex - 'l2z=true&factor[l2z_hr]=10&factor[l2z_p]=0' #Lyra2z - 'lbry=true&factor[lbry_hr]=10&factor[lbry_p]=0' #Lbry - 'lre=true&factor[lrev2_hr]=10&factor[lrev2_p]=0' #Lyra2v2 - 'lrev3=true&factor[lrev3_hr]=10&factor[lrev3_p]=0' #Lyra2v3 - 'mtp=true&factor[mtp_hr]=10&factor[mtp_p]=0' #MTP - 'n5=true&factor[n5_hr]=10&factor[n5_p]=0' #Nist5 - 'ns=true&factor[ns_hr]=10&factor[ns_p]=0' #NeoScrypt - 'pas=true&factor[pas_hr]=10&factor[pas_p]=0' #Pascal - 'phi=true&factor[phi_hr]=10&factor[phi_p]=0' #PHI - 'phi2=true&factor[phi2_hr]=10&factor[phi2_p]=0' #PHI2 - 'ppw=true&factor[ppw_hr]=10&factor[ppw_p]=0' #ProgPOW - 'skh=true&factor[skh_hr]=10&factor[skh_p]=0' #Skunk - 'tt10=true&factor[tt10_hr]=10&factor[tt10_p]=0' #TimeTravel10 - 'x11gf=true&factor[x11g_hr]=10&factor[x11g_p]=0' #X11gost - 'x16r=true&factor[x16r_hr]=10&factor[x16r_p]=0' #X16r - 'x22i=true&factor[x22i_hr]=10&factor[x22i_p]=0' #X22i - 'xn=true&factor[xn_hr]=10&factor[xn_p]=0' #Xevan - 'zh=true&factor[zh_hr]=10&factor[zh_p]=0' #ZHash (Equihash144) - ) -join '&' - - 'Calling WhatToMine API' | Write-Host - $WTMResponse = try { Invoke-RestMethod -Uri $WtmUrl -UseBasicParsing -TimeoutSec 10 | Select-Object -ExpandProperty coins } catch { $null; Write-Host "Not responding" } - } + 'Calling Coindesk API' | Write-Host + $CDKResponse = try { Invoke-RestMethod -Uri "https://api.coindesk.com/v1/bpi/currentprice/$($Config.LocalCurrency).json" -UseBasicParsing -TimeoutSec 5 | Select-Object -ExpandProperty BPI } catch { $null; Write-Host "Not responding" } + if (($CoinsPool | Where-Object Price -gt 0).count -gt 0) { $Counter = 0 foreach ($Coin in $CoinsPool) { $Coin.Option = $Counter $counter++ $Coin.YourHashRate = (Get-BestHashRateAlgo $Coin.Algorithm).HashRate + $Coin.BtcProfit = $Coin.price * $Coin.YourHashRate + $Coin.LocalProfit = $CDKResponse.$($Config.LocalCurrency).rate_float * [double]$Coin.BtcProfit + } + } else { + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + 'Calling CoinMarketCap API' | Write-Host + $CMCResponse = try { Invoke-RestMethod -Uri "https://api.coinmarketcap.com/v1/ticker/?limit=0" -UseBasicParsing -TimeoutSec 10 } catch { $null; Write-Host "Not responding" } + 'Calling Bittrex API' | Write-Host + $BTXResponse = try { Invoke-RestMethod -Uri "https://bittrex.com/api/v1.1/public/getmarketsummaries" -UseBasicParsing -TimeoutSec 10 | Select-Object -ExpandProperty 'result' } catch { $null; Write-Host "Not responding" } + # 'Calling Cryptopia API' | Write-Host + # $CRYResponse = try { Invoke-RestMethod -Uri "https://www.cryptopia.co.nz/api/GetMarkets/BTC" -UseBasicParsing -TimeoutSec 10 | Select-Object -ExpandProperty 'data' } catch { $null; Write-Host "Not responding" } + + #Add main page coins + $WtmUrl = 'https://whattomine.com/coins.json?' + + @( + 'bcd=true&factor[bcd_hr]=10&factor[bcd_p]=0' #BCD + 'bk14=true&factor[bk14_hr]=10&factor[bk14_p]=0' #Decred + 'cn=true&factor[cn_hr]=10&factor[cn_p]=0' #CryptoNight + 'cn7=true&factor[cn7_hr]=10&factor[cn7_p]=0' #CryptoNightV7 + 'cn8=true&factor[cn8_hr]=10&factor[cn8_p]=0' #CryptoNightV8 + 'cnf=true&factor[cnf_hr]=10&factor[cnf_p]=0' #CryptoNightFast + 'cnh=true&factor[cnh_hr]=10&factor[cnh_p]=0' #CryptoNightHeavy + 'cnhn=true&factor[cnhn_hr]=10&factor[cnhn_p]=0' #CryptoNightHaven + 'cns=true&factor[cns_hr]=10&factor[cns_p]=0' #CryptoNightSaber + 'cr29=true&factor[cr29_hr]=10&factor[cr29_p]=0' #Cuckaroo29 + 'eq=true&factor[eq_hr]=10&factor[eq_p]=0' #Equihash + 'eqa=true&factor[eqa_hr]=10&factor[eqa_p]=0' #AION (Equihash210) + 'eth=true&factor[eth_hr]=10&factor[eth_p]=0' #Ethash + 'grof=true&factor[gro_hr]=10&factor[gro_p]=0' #Groestl + 'hx=true&factor[hx_hr]=10&factor[hx_p]=0' #Hex + 'l2z=true&factor[l2z_hr]=10&factor[l2z_p]=0' #Lyra2z + 'lbry=true&factor[lbry_hr]=10&factor[lbry_p]=0' #Lbry + 'lre=true&factor[lrev2_hr]=10&factor[lrev2_p]=0' #Lyra2v2 + 'lrev3=true&factor[lrev3_hr]=10&factor[lrev3_p]=0' #Lyra2v3 + 'mtp=true&factor[mtp_hr]=10&factor[mtp_p]=0' #MTP + 'n5=true&factor[n5_hr]=10&factor[n5_p]=0' #Nist5 + 'ns=true&factor[ns_hr]=10&factor[ns_p]=0' #NeoScrypt + 'pas=true&factor[pas_hr]=10&factor[pas_p]=0' #Pascal + 'phi=true&factor[phi_hr]=10&factor[phi_p]=0' #PHI + 'phi2=true&factor[phi2_hr]=10&factor[phi2_p]=0' #PHI2 + 'ppw=true&factor[ppw_hr]=10&factor[ppw_p]=0' #ProgPOW + 'skh=true&factor[skh_hr]=10&factor[skh_p]=0' #Skunk + 'tt10=true&factor[tt10_hr]=10&factor[tt10_p]=0' #TimeTravel10 + 'x11gf=true&factor[x11g_hr]=10&factor[x11g_p]=0' #X11gost + 'x16r=true&factor[x16r_hr]=10&factor[x16r_p]=0' #X16r + 'x22i=true&factor[x22i_hr]=10&factor[x22i_p]=0' #X22i + 'xn=true&factor[xn_hr]=10&factor[xn_p]=0' #Xevan + 'zh=true&factor[zh_hr]=10&factor[zh_p]=0' #ZHash (Equihash144) + ) -join '&' + + 'Calling WhatToMine API' | Write-Host + $WTMResponse = try { Invoke-RestMethod -Uri $WtmUrl -UseBasicParsing -TimeoutSec 10 | Select-Object -ExpandProperty coins } catch { $null; Write-Host "Not responding" } + } - if ($ManualMiningApiUse -eq $true -and ![string]::IsNullOrEmpty($Coin.Symbol)) { + $Counter = 0 + foreach ($Coin in $CoinsPool) { + $Coin.Option = $Counter + $counter++ + $Coin.YourHashRate = (Get-BestHashRateAlgo $Coin.Algorithm).HashRate - $PriceCMC = [decimal]($CMCResponse | Where-Object Symbol -eq $Coin.Symbol | ForEach-Object {if ($(Get-CoinUnifiedName $_.Id) -eq $Coin.Info) {$_.price_btc} }) - $PriceBTX = [decimal]($BTXResponse | Where-Object MarketName -eq ('BTC-' + $Coin.Symbol) | Select-Object -ExpandProperty Last) - # $PriceCRY = [decimal]($CRYResponse | Where-Object Label -eq ($Coin.Symbol + '/BTC') | Select-Object -ExpandProperty LastPrice) + if ($ManualMiningApiUse -eq $true -and ![string]::IsNullOrEmpty($Coin.Symbol)) { - if ($PriceCMC -gt 0) { - $Coin.BTCPrice = $PriceCMC - } elseif ($PriceBTX -gt 0) { - $Coin.BTCPrice = $PriceBTX - # } elseif ($PriceCRY -gt 0) { - # $Coin.BTCPrice = $PriceCRY - } + $PriceCMC = [decimal]($CMCResponse | Where-Object Symbol -eq $Coin.Symbol | ForEach-Object {if ($(Get-CoinUnifiedName $_.Id) -eq $Coin.Info) {$_.price_btc} }) + $PriceBTX = [decimal]($BTXResponse | Where-Object MarketName -eq ('BTC-' + $Coin.Symbol) | Select-Object -ExpandProperty Last) + # $PriceCRY = [decimal]($CRYResponse | Where-Object Label -eq ($Coin.Symbol + '/BTC') | Select-Object -ExpandProperty LastPrice) + + if ($PriceCMC -gt 0) { + $Coin.BTCPrice = $PriceCMC + } elseif ($PriceBTX -gt 0) { + $Coin.BTCPrice = $PriceBTX + # } elseif ($PriceCRY -gt 0) { + # $Coin.BTCPrice = $PriceCRY + } + + Remove-Variable PriceCMC + Remove-Variable PriceBTX + # Remove-Variable PriceCRY + + #Data from WTM + if ($WTMResponse) { + $WtmCoin = $WTMResponse.PSObject.Properties.Value | Where-Object tag -eq $Coin.Symbol | ForEach-Object {if ($(Get-AlgoUnifiedName $_.algorithm) -eq $Coin.Algorithm) {$_}} + if ($WtmCoin) { + + $WTMFactor = switch ($Coin.Algorithm) { + "Allium" { 1e6 } + "BCD" { 1e6 } + "Bitcore" { 1e6 } + "Blake2s" { 1e6 } + "CnFast" { 1 } + "CnHaven" { 1 } + "CnHeavy" { 1 } + "CnLiteV7" { 1 } + "CnSaber" { 1 } + "CnV7" { 1 } + "CnV8" { 1 } + "Cuckaroo29" { 1 } + "Cuckaroo31" { 1 } + "Energi" { 1e6 } + "Equihash144" { 1 } + "Equihash192" { 1 } + "Equihash210" { 1 } + "Equihash96" { 1e3 } + "Ethash" { 1e6 } + "Hex" { 1e6 } + "Keccak" { 1e6 } + "KeccakC" { 1e6 } + "LBK3" { 1e3 } + "Lyra2v2" {1e3} + "Lyra2v3" {1e6} + "Lyra2z" { 1e6 } + "M7M" { 1e3 } + "MTP" { 1e3 } + "NeoScrypt" { 1e3 } + "Phi" { 1e6 } + "Phi2" { 1e6 } + "ProgPOW" { 1e6 } + "RandomHash" { 1e3 } + "Skunk" { 1e6 } + "SonoA" { 1e3 } + "Tensority" { 1 } + "Ubqhash" { 1e6 } + "X16r" { 1e6 } + "X16rt" { 1e6 } + "X16s" { 1e6 } + "X17" { 1e3 } + "X22i" { 1e6 } + "Yescrypt" { 1 } + default { $null } + } - Remove-Variable PriceCMC - Remove-Variable PriceBTX - # Remove-Variable PriceCRY - - #Data from WTM - if ($WTMResponse -ne $null) { - $WtmCoin = $WTMResponse.PSObject.Properties.Value | Where-Object tag -eq $Coin.Symbol | ForEach-Object {if ($(Get-AlgoUnifiedName $_.algorithm) -eq $Coin.Algorithm) {$_}} - if ($WtmCoin -ne $null) { - - $WTMFactor = switch ($Coin.Algorithm) { - "Allium" { 1e6 } - "BCD" { 1e6 } - "Bitcore" { 1e6 } - "Blake2s" { 1e6 } - "CnFast" { 1 } - "CnHaven" { 1 } - "CnHeavy" { 1 } - "CnLiteV7" { 1 } - "CnSaber" { 1 } - "CnV7" { 1 } - "CnV8" { 1 } - "Cuckaroo29" { 1 } - "Cuckaroo31" { 1 } - "Energi" { 1e6 } - "Equihash144" { 1 } - "Equihash192" { 1 } - "Equihash210" { 1 } - "Equihash96" { 1e3 } - "Ethash" { 1e6 } - "Hex" { 1e6 } - "Keccak" { 1e6 } - "KeccakC" { 1e6 } - "LBK3" { 1e3 } - "Lyra2v2" {1e3} - "Lyra2v3" {1e6} - "Lyra2z" { 1e6 } - "M7M" { 1e3 } - "MTP" { 1e3 } - "NeoScrypt" { 1e3 } - "Phi" { 1e6 } - "Phi2" { 1e6 } - "ProgPOW" { 1e6 } - "RandomHash" { 1e3 } - "Skunk" { 1e6 } - "SonoA" { 1e3 } - "Tensority" { 1 } - "Ubqhash" { 1e6 } - "X16r" { 1e6 } - "X16rt" { 1e6 } - "X16s" { 1e6 } - "X17" { 1e3 } - "X22i" { 1e6 } - "Yescrypt" { 1 } - default { $null } - } - - if ($WTMFactor) { - $Coin.Reward = [double]([double]$WtmCoin.estimated_rewards * ([double]$Coin.YourHashRate / [double]$WTMFactor)) - $Coin.BtcProfit = [double]([double]$WtmCoin.Btc_revenue * ([double]$Coin.YourHashRate / [double]$WTMFactor)) - } + if ($WTMFactor) { + $Coin.Reward = [double]([double]$WtmCoin.estimated_rewards * ([double]$Coin.YourHashRate / [double]$WTMFactor)) + $Coin.BtcProfit = [double]([double]$WtmCoin.Btc_revenue * ([double]$Coin.YourHashRate / [double]$WTMFactor)) } } - $Coin.LocalProfit = $CDKResponse.$LocalCurrency.rate_float * $Coin.BtcProfit - $Coin.LocalPrice = $CDKResponse.$LocalCurrency.rate_float * $Coin.BtcPrice } + $Coin.LocalProfit = $CDKResponse.($Config.LocalCurrency).rate_float * $Coin.BtcProfit + $Coin.LocalPrice = $CDKResponse.($Config.LocalCurrency).rate_float * $Coin.BtcPrice } + } - # Clear-Host - Print-HorizontalLine "" - Print-HorizontalLine "SELECT COIN TO MINE" - Print-HorizontalLine "" - $CoinsPool | Format-Table -Wrap ( - @{Label = "Opt."; Expression = {$_.Option}; Align = 'right'} , - @{Label = "Name"; Expression = {$_.Info}; Align = 'left'} , - @{Label = "Symbol"; Expression = {$_.symbol}; Align = 'left'}, - @{Label = "Algorithm"; Expression = {$_.algorithm}; Align = 'left'}, - @{Label = "HashRate"; Expression = {(ConvertTo-Hash ($_.YourHashRate)) + "/s"}; Align = 'right'}, - @{Label = "BTCPrice"; Expression = {if ($_.BTCPrice -gt 0) {[math]::Round($_.BTCPrice, 6).ToString("n6")}}; Align = 'right'}, - @{Label = $LocalCurrency + "Price"; Expression = { [math]::Round($_.LocalPrice, 2)}; Align = 'right'}, - @{Label = "Reward"; Expression = {if ($_.Reward -gt 0 ) {[math]::Round($_.Reward, 3)}}; Align = 'right'}, - @{Label = "mBTCProfit"; Expression = {if ($_.BtcProfit -gt 0 ) {($_.BtcProfit * 1000).ToString("n5")}}; Align = 'right'}, - @{Label = $LocalCurrency + "Profit"; Expression = {if ($_.LocalProfit -gt 0 ) {[math]::Round($_.LocalProfit, 2)}}; Align = 'right'} - ) - - $SelectedOption = Read-Host -Prompt 'SELECT ONE OPTION:' - while ($SelectedOption -like '*,*') { - $SelectedOption = Read-Host -Prompt 'SELECT ONLY ONE OPTION:' - } - $CoinsName = $CoinsPool[$SelectedOption].Info -replace '_', ',' #for dual mining - $AlgosName = $CoinsPool[$SelectedOption].Algorithm -replace '_', ',' #for dual mining - - Write-Host SELECTED OPTION:: $CoinsName - $AlgosName - } else { - Write-Host SELECTED BY PARAMETER :: $CoinsName + # Clear-Host + Out-HorizontalLine "" + Out-HorizontalLine "SELECT COIN TO MINE" + Out-HorizontalLine "" + $CoinsPool | Format-Table -Wrap ( + @{Label = "Opt."; Expression = {$_.Option}; Align = 'right'} , + @{Label = "Name"; Expression = {$_.Info}; Align = 'left'} , + @{Label = "Symbol"; Expression = {$_.symbol}; Align = 'left'}, + @{Label = "Algorithm"; Expression = {$_.algorithm}; Align = 'left'}, + @{Label = "HashRate"; Expression = {(ConvertTo-Hash ($_.YourHashRate)) + "/s"}; Align = 'right'}, + @{Label = "BTCPrice"; Expression = {if ($_.BTCPrice -gt 0) {[math]::Round($_.BTCPrice, 6).ToString("n6")}}; Align = 'right'}, + @{Label = $Config.LocalCurrency + "Price"; Expression = { [math]::Round($_.LocalPrice, 2)}; Align = 'right'}, + @{Label = "Reward"; Expression = {if ($_.Reward -gt 0 ) {[math]::Round($_.Reward, 3)}}; Align = 'right'}, + @{Label = "mBTCProfit"; Expression = {if ($_.BtcProfit -gt 0 ) {($_.BtcProfit * 1000).ToString("n5")}}; Align = 'right'}, + @{Label = $Config.LocalCurrency + "Profit"; Expression = {if ($_.LocalProfit -gt 0 ) {[math]::Round($_.LocalProfit, 2)}}; Align = 'right'} + ) + + $SelectedOption = Read-Host -Prompt 'SELECT ONE OPTION:' + while ($SelectedOption -like '*,*') { + $SelectedOption = Read-Host -Prompt 'SELECT ONLY ONE OPTION:' } - } + $CoinsName = $CoinsPool[$SelectedOption].Info -replace '_', ',' #for dual mining + $AlgosName = $CoinsPool[$SelectedOption].Algorithm -replace '_', ',' #for dual mining - #-----------------Launch Command - $Params = @{ - MiningMode = $MiningMode - PoolsName = $PoolsName -split ',' - } - if ($MiningMode -eq 'Manual') { - $Params.Algorithm = $AlgosName - if ($CoinsName) {$Params.CoinsName = $CoinsName} + Write-Host SELECTED OPTION:: $CoinsName - $AlgosName + } else { + Write-Host SELECTED BY PARAMETER :: $CoinsName } - $Params | Format-List - Pause - & .\Core.ps1 @Params +} -} else { - #FARM MONITORING - & .\Includes\FarmMonitor.ps1 +#-----------------Launch Command +$Params = @{ + MiningMode = $MiningMode + PoolsName = $PoolsName -split ',' +} +if ($MiningMode -eq 'Manual') { + $Params.Algorithm = $AlgosName + if ($CoinsName) {$Params.CoinsName = $CoinsName} } +$Params | Format-List +Pause +& .\Core.ps1 @Params diff --git a/Pools/AhashPool.ps1 b/Pools/AhashPool.ps1 index 2aacee3d..ec5bf4ab 100644 --- a/Pools/AhashPool.ps1 +++ b/Pools/AhashPool.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://www.ahashpool.com/api' $MineUrl = 'mine.ahashpool.com' $Location = 'US' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to BTC wallet, no registration required" + Disclaimer = "Autoexchange to BTC, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,10 +62,10 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { - if (!$CoinsWallets.BTC) { - Write-Warning "$Name BTC wallet not defined in config.ini" + if (-not $Wallets.BTC) { + Write-Warning "$Name BTC wallet not defined" Exit } @@ -93,8 +93,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Algo.name + "." + $MineUrl Port = $Algo.port - User = $CoinsWallets.BTC - Pass = "c=BTC,ID=#WorkerName#" + User = $Wallets.BTC + Pass = "c=BTC,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/BlazePool.ps1 b/Pools/BlazePool.ps1 index f4d6e89c..0f8a350c 100644 --- a/Pools/BlazePool.ps1 +++ b/Pools/BlazePool.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'http://api.blazepool.com/' $MineUrl = 'mine.blazepool.com' $Location = 'US' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to BTC wallet, no registration required" + Disclaimer = "Autoexchange to BTC, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet/" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet/" + $Info.user) -Retry 3 if ($Request) { @@ -62,10 +62,10 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { - if (!$CoinsWallets.BTC) { - Write-Warning "$Name BTC wallet not defined in config.ini" + if (-not $Wallets.BTC) { + Write-Warning "$Name BTC wallet not defined" Exit } @@ -75,8 +75,6 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } - $Request | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name | Where-Object { $Request.$_.HashRate -gt 0 } | ForEach-Object { @@ -95,8 +93,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Algo.name + "." + $MineUrl Port = $Algo.port - User = $CoinsWallets.BTC - Pass = "c=BTC,ID=#WorkerName#" + User = $Wallets.BTC + Pass = "c=BTC,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo @@ -105,7 +103,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { PoolWorkers = $Algo.workers PoolHashRate = $Algo.HashRate WalletMode = $WalletMode - WalletSymbol = $Currency + WalletSymbol = 'BTC' PoolName = $Name Fee = $Algo.fees / 100 RewardType = $RewardType diff --git a/Pools/BlockMasters.ps1 b/Pools/BlockMasters.ps1 index 1d224b6c..990b3d35 100644 --- a/Pools/BlockMasters.ps1 +++ b/Pools/BlockMasters.ps1 @@ -11,7 +11,7 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'http://blockmasters.co/api' $Locations = @{ 'US' = 'blockmasters.co' @@ -20,19 +20,19 @@ $Locations = @{ $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC/LTC/DOGE, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -41,7 +41,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -51,7 +51,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -64,7 +64,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -72,7 +72,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Config.("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC', 'LTC', 'DOGE') -notcontains $Currency -and @@ -81,8 +81,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -106,8 +106,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Locations.$Location Port = $Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/BsodPw.ps1 b/Pools/BsodPw.ps1 index 29d1842b..68a3e1f2 100644 --- a/Pools/BsodPw.ps1 +++ b/Pools/BsodPw.ps1 @@ -11,7 +11,7 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $false $ActiveOnAutomatic24hMode = $false -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'http://api.bsod.pw/api' $Locations = @{ 'US' = 'us.bsod.pw' @@ -21,19 +21,19 @@ $Locations = @{ $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "No registration, No autoexchange, need wallet for each coin on config.ini" + Disclaimer = "No registration, No autoexchange, need wallet for each coin" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -42,7 +42,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -52,7 +52,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -65,7 +65,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $RequestCurrencies) { @@ -105,8 +105,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Locations.$Location Port = [int]$Coin.port - User = $CoinsWallets.$Pool_Symbol - Pass = "c=$Pool_Symbol,ID=#WorkerName#" + User = $Wallets.$Pool_Symbol + Pass = "c=$Pool_Symbol,id=#WorkerName#" Location = $Location SSL = $false Symbol = $Pool_Symbol diff --git a/Pools/CoinCalc.ps1 b/Pools/CoinCalc.ps1 index 01f81e8a..b894be7b 100644 --- a/Pools/CoinCalc.ps1 +++ b/Pools/CoinCalc.ps1 @@ -1,7 +1,8 @@ <# -THIS IS A ADVANCED POOL, NOT FOR NOOB. +THIS IS A ADVANCED POOL. -THIS IS A VIRTUAL POOL, STATISTICS ARE TAKEN FROM WHATTOMINE AND RECALCULATED WITH YOUR BENCHMARKS HashRate, YOU CAN SET DESTINATION POOL YOU WANT FOR EACH COIN, BUT REMEMBER YOU MUST HAVE AND ACOUNT IF DESTINATION POOL IS NOT ANONYMOUS POOL +THIS IS A VIRTUAL POOL, STATISTICS ARE TAKEN FROM CoinCalculators.io AND RECALCULATED WITH YOUR BENCHMARKS HashRate, +YOU CAN SET DESTINATION POOL YOU WANT FOR EACH COIN, BUT REMEMBER YOU MUST HAVE AN ACOUNT IF DESTINATION POOL IS NOT ANONYMOUS #> param( @@ -17,13 +18,13 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = "MIXED" +$WalletMode = "Mixed" $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Based on CoinCalculator statistics, you must have accounts and wallets for each coin in config.ini" + Disclaimer = "Based on CoinCalculators statistics, you must have accounts and wallets for each coin" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode @@ -34,27 +35,30 @@ if ($Querymode -eq "info") { } if (($Querymode -eq "Speed")) { - if ($PoolRealName -ne $null) { + if ($null -ne $PoolRealName) { $Info.PoolName = $PoolRealName $Result = Get-Pools -Querymode "Speed" -PoolsFilterList $Info.PoolName -Info $Info } } -if (($Querymode -eq "Wallet") -or ($Querymode -eq "APIKey")) { - if ($PoolRealName -ne $null) { +if (($Querymode -eq "Wallet") -or ($Querymode -eq "ApiKey")) { + if ($null -ne $PoolRealName) { $Info.PoolName = $PoolRealName $Result = Get-Pools -Querymode $info.WalletMode -PoolsFilterList $Info.PoolName -Info $Info | select-object Pool, Currency, Balance } } -if (@("Core", "Menu") -contains $Querymode) { +if ($Querymode -eq "Core") { #Look for pools - $ConfigOrder = (Get-ConfigVariable "CoinCalcPoolOrder") -split ',' + $ConfigOrder = $Config.("PoolOrder_" + $Name) -split ',' $Pools = foreach ($PoolToSearch in $ConfigOrder) { $PoolsTmp = Get-Pools -Querymode "Core" -PoolsFilterList $PoolToSearch -location $Info.Location #Filter by minworkes variable (must be here for not selecting now a pool and after that discarded on core.ps1 filter) - $PoolsTmp | Where-Object {[string]::IsNullOrEmpty($_.PoolWorkers) -or $_.PoolWorkers -ge (Get-ConfigVariable "MinWorkers")} + $PoolsTmp | Where-Object { + $_.PoolWorkers -eq $null -or + $_.PoolWorkers -ge $(if ($Config.("MinWorkers_" + $Name)) {$Config.("MinWorkers_" + $Name)} else {$Config.MinWorkers}) + } } $Url = "https://www.coincalculators.io/api/allcoins.aspx?hashrate=1000&difficultytime=0" diff --git a/Pools/CryptoKnight.ps1 b/Pools/CryptoKnight.ps1 index efed87ca..0e307fca 100644 --- a/Pools/CryptoKnight.ps1 +++ b/Pools/CryptoKnight.ps1 @@ -16,7 +16,7 @@ $Location = 'US' $RewardType = 'PPLS' $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ Disclaimer = "No registration, No autoexchange, need wallet for each coin" ActiveOnManualMode = $ActiveOnManualMode @@ -28,7 +28,7 @@ if ($Querymode -eq "info") { } } -if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Pools = @() $Pools += [PSCustomObject]@{ Coin = "Aeon" ; Symbol = "AEON" ; Algo = "CnLiteV7" ; Port = 5542 ; WalletSymbol = "aeon" } @@ -65,7 +65,7 @@ if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { $Pools | ForEach-Object { - if ($CoinsWallets.($_.Symbol)) { + if ($Wallets.($_.Symbol)) { try { $Request = $null @@ -88,7 +88,7 @@ if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $(if ($_.Server) {$_.Server} else {$_.WalletSymbol + ".ingest.cryptoknight.cc"}) Port = $_.Port - User = $CoinsWallets.($_.Symbol) + User = $Wallets.($_.Symbol) Pass = "#WorkerName#" Location = $Location SSL = $false diff --git a/Pools/FairPool.ps1 b/Pools/FairPool.ps1 index ceb43799..8e4babc5 100644 --- a/Pools/FairPool.ps1 +++ b/Pools/FairPool.ps1 @@ -60,7 +60,7 @@ if ($Querymode -eq "Wallet") { } } -if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Pools = @() $Pools += [PSCustomObject]@{ Coin = "Akroma" ; Symbol = "AKA" ; Algo = "Ethash" ; WalletSymbol = "aka" ; Port = 2222 } @@ -84,7 +84,7 @@ if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { $Pools += [PSCustomObject]@{ Coin = "Wownero" ; Symbol = "WOW" ; Algo = "CnWow" ; WalletSymbol = "wow" ; Port = 6090 } $Pools | ForEach-Object { - if ($CoinsWallets.($_.Symbol)) { + if ($Wallets.($_.Symbol)) { $ApiResponse = Invoke-APIRequest -Url ("https://" + $_.WalletSymbol + ".fairpool.xyz/api/poolStats") $Result += [PSCustomObject]@{ Algorithm = $_.Algo @@ -93,7 +93,7 @@ if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { Host = "mine." + $_.WalletSymbol + ".fairpool.xyz" Port = $_.Port Price = [decimal]$ApiResponse.ProfitBtc - User = $CoinsWallets.($_.Symbol) + "+#WorkerName#" + User = $Wallets.($_.Symbol) + "+#WorkerName#" Pass = "x" Location = "US" SSL = $false diff --git a/Pools/HashRefinery.ps1 b/Pools/HashRefinery.ps1 index f26b25cd..c0f1098d 100644 --- a/Pools/HashRefinery.ps1 +++ b/Pools/HashRefinery.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://pool.hashrefinery.com/api' $MineUrl = 'us.hashrefinery.com' $Location = 'US' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC/LTC, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -70,7 +70,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Config.("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC', 'LTC') -notcontains $Currency -and @@ -79,8 +79,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -102,8 +102,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Algo.name + "." + $MineUrl Port = $Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/IceMining.ps1 b/Pools/IceMining.ps1 index a054231d..9fe20350 100644 --- a/Pools/IceMining.ps1 +++ b/Pools/IceMining.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $false -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://icemining.ca/api' $MineUrl = 'stratum.icemining.ca' $Location = 'US' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "No registration, No autoexchange, need wallet for each coin on config.ini" + Disclaimer = "No registration, No autoexchange, need wallet for each coin" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $RequestCurrencies -or -not $Request) { @@ -90,8 +90,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $MineUrl Port = [int]$Coin.port - User = $CoinsWallets.$Pool_Symbol - Pass = "c=$Pool_Symbol,ID=#WorkerName#" + User = $Wallets.$Pool_Symbol + Pass = "c=$Pool_Symbol,id=#WorkerName#" Location = $Location SSL = $false Symbol = $Pool_Symbol diff --git a/Pools/MinerRocks.ps1 b/Pools/MinerRocks.ps1 index 0badcb0f..1a041c02 100644 --- a/Pools/MinerRocks.ps1 +++ b/Pools/MinerRocks.ps1 @@ -8,7 +8,7 @@ param( $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true -$WalletMode = "WALLET" +$WalletMode = "Wallet" $RewardType = "PPLS" $Result = @() @@ -51,14 +51,14 @@ if ($Querymode -eq "Wallet") { if ($Request) { $Result = [PSCustomObject]@{ Pool = $Name - currency = $Info.Symbol - balance = ($Request.stats.balance + $Request.stats.pendingIncome ) / $Divisor + Currency = $Info.Symbol + Balance = ($Request.stats.balance + $Request.stats.pendingIncome ) / $Divisor } Remove-Variable Request } } -if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Response = Invoke-WebRequest -Uri "https://miner.rocks" @@ -81,21 +81,22 @@ if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { $Algo = Get-AlgoUnifiedName $_.Algo switch ($_.Coin) { + "BitTube" { $Algo = 'CnSaber' } "Haven" { $Algo = 'CnHaven' } + "Masari" { $Algo = 'CnHalf' } "Saronite" { $Algo = 'CnHaven' } - "BitTube" { $Algo = 'CnSaber' } } $Coin = Get-CoinUnifiedName $_.Coin - if ($CoinsWallets.($PoolResponse.config.symbol)) { + if ($Wallets.($PoolResponse.config.symbol)) { $Result += [PSCustomObject]@{ Info = $Coin Algorithm = $Algo Protocol = "stratum+tcp" Host = $($_.Url -split '//')[1] Port = [int]$($PoolResponse.config.ports | Sort-Object {$_.desc -like "*Modern*GPU*"} -Descending | Select-Object -First 1 -ExpandProperty port) - User = $CoinsWallets.($PoolResponse.config.symbol) + User = $Wallets.($PoolResponse.config.symbol) Pass = "w=#WorkerName#" Location = "EU" diff --git a/Pools/MiningDutch.ps1 b/Pools/MiningDutch.ps1 index 1c48d936..c318e452 100644 --- a/Pools/MiningDutch.ps1 +++ b/Pools/MiningDutch.ps1 @@ -11,11 +11,11 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $false $ActiveOnAutomatic24hMode = $false -$WalletMode = "NONE" +$WalletMode = "None" $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ Disclaimer = "Must register and set wallet for each coin on web" ActiveOnManualMode = $ActiveOnManualMode @@ -27,37 +27,36 @@ if ($Querymode -eq "info") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { - if (!$UserName) { - Write-Warning "$Name UserName not defined in config.ini" + if (-not $Config.UserName -and -not $Config.("UserName_" + $Name)) { + Write-Warning "$Name UserName not defined" Exit } $Pools = @() - $Pools += [PSCustomObject]@{coin = "Cerberus"; algo = "NeoScrypt"; symbol = "CBS"; port = 3426}; - $Pools += [PSCustomObject]@{coin = "Crowdcoin"; algo = "NeoScrypt"; symbol = "CRC"; port = 3315}; - $Pools += [PSCustomObject]@{coin = "Desire"; algo = "NeoScrypt"; symbol = "DSR"; port = 3635}; - $Pools += [PSCustomObject]@{coin = "Feathercoin"; algo = "NeoScrypt"; symbol = "FTC"; port = 3347}; - $Pools += [PSCustomObject]@{coin = "Gobyte"; algo = "NeoScrypt"; symbol = "GBX"; port = 3606}; - $Pools += [PSCustomObject]@{coin = "Guncoin"; algo = "NeoScrypt"; symbol = "GUN"; port = 3615}; - $Pools += [PSCustomObject]@{coin = "Innova"; algo = "NeoScrypt"; symbol = "INN"; port = 3389}; - $Pools += [PSCustomObject]@{coin = "Nyxcoin"; algo = "NeoScrypt"; symbol = "NYX"; port = 3419}; - $Pools += [PSCustomObject]@{coin = "Onexcash"; algo = "NeoScrypt"; symbol = "ONEX"; port = 3655}; - $Pools += [PSCustomObject]@{coin = "Orbitcoin"; algo = "NeoScrypt"; symbol = "ORB"; port = 3614}; - $Pools += [PSCustomObject]@{coin = "Qbic"; algo = "NeoScrypt"; symbol = "QBIC"; port = 3416}; - $Pools += [PSCustomObject]@{coin = "Sparks"; algo = "NeoScrypt"; symbol = "SPK"; port = 3408}; - $Pools += [PSCustomObject]@{coin = "Trezarcoin"; algo = "NeoScrypt"; symbol = "TZC"; port = 3616}; - $Pools += [PSCustomObject]@{coin = "Ufocoin"; algo = "NeoScrypt"; symbol = "UFO"; port = 3351}; - $Pools += [PSCustomObject]@{coin = "Vivo"; algo = "NeoScrypt"; symbol = "VIVO"; port = 3610}; - - $Pools += [PSCustomObject]@{coin = "Monacoin"; algo = "Lyra2rev2"; symbol = "MONA"; port = 3420}; - $Pools += [PSCustomObject]@{coin = "Rupee"; algo = "Lyra2rev2"; symbol = "RUP"; port = 3427}; - $Pools += [PSCustomObject]@{coin = "Shield"; algo = "Lyra2rev2"; symbol = "XSH"; port = 3432}; - $Pools += [PSCustomObject]@{coin = "Straks"; algo = "Lyra2rev2"; symbol = "STAK"; port = 3433}; - $Pools += [PSCustomObject]@{coin = "Verge"; algo = "Lyra2rev2"; symbol = "XVG"; port = 3431}; - $Pools += [PSCustomObject]@{coin = "Vertcoin"; algo = "Lyra2rev2"; symbol = "VTC"; port = 3429}; + $Pools += [PSCustomObject]@{ Coin = "Cerberus" ; Algo = "NeoScrypt" ; Symbol = "CBS" ; Port = 3426 } + $Pools += [PSCustomObject]@{ Coin = "Crowdcoin" ; Algo = "NeoScrypt" ; Symbol = "CRC" ; Port = 3315 } + $Pools += [PSCustomObject]@{ Coin = "Desire" ; Algo = "NeoScrypt" ; Symbol = "DSR" ; Port = 3635 } + $Pools += [PSCustomObject]@{ Coin = "Feathercoin" ; Algo = "NeoScrypt" ; Symbol = "FTC" ; Port = 3347 } + $Pools += [PSCustomObject]@{ Coin = "Gobyte" ; Algo = "NeoScrypt" ; Symbol = "GBX" ; Port = 3606 } + $Pools += [PSCustomObject]@{ Coin = "Guncoin" ; Algo = "NeoScrypt" ; Symbol = "GUN" ; Port = 3615 } + $Pools += [PSCustomObject]@{ Coin = "Innova" ; Algo = "NeoScrypt" ; Symbol = "INN" ; Port = 3389 } + $Pools += [PSCustomObject]@{ Coin = "Nyxcoin" ; Algo = "NeoScrypt" ; Symbol = "NYX" ; Port = 3419 } + $Pools += [PSCustomObject]@{ Coin = "Onexcash" ; Algo = "NeoScrypt" ; Symbol = "ONEX" ; Port = 3655 } + $Pools += [PSCustomObject]@{ Coin = "Orbitcoin" ; Algo = "NeoScrypt" ; Symbol = "ORB" ; Port = 3614 } + $Pools += [PSCustomObject]@{ Coin = "Qbic" ; Algo = "NeoScrypt" ; Symbol = "QBIC" ; Port = 3416 } + $Pools += [PSCustomObject]@{ Coin = "Sparks" ; Algo = "NeoScrypt" ; Symbol = "SPK" ; Port = 3408 } + $Pools += [PSCustomObject]@{ Coin = "Trezarcoin" ; Algo = "NeoScrypt" ; Symbol = "TZC" ; Port = 3616 } + $Pools += [PSCustomObject]@{ Coin = "Ufocoin" ; Algo = "NeoScrypt" ; Symbol = "UFO" ; Port = 3351 } + $Pools += [PSCustomObject]@{ Coin = "Vivo" ; Algo = "NeoScrypt" ; Symbol = "VIVO" ; Port = 3610 } + $Pools += [PSCustomObject]@{ Coin = "Monacoin" ; Algo = "Lyra2rev2" ; Symbol = "MONA" ; Port = 3420 } + $Pools += [PSCustomObject]@{ Coin = "Rupee" ; Algo = "Lyra2rev2" ; Symbol = "RUP" ; Port = 3427 } + $Pools += [PSCustomObject]@{ Coin = "Shield" ; Algo = "Lyra2rev2" ; Symbol = "XSH" ; Port = 3432 } + $Pools += [PSCustomObject]@{ Coin = "Straks" ; Algo = "Lyra2rev2" ; Symbol = "STAK" ; Port = 3433 } + $Pools += [PSCustomObject]@{ Coin = "Verge" ; Algo = "Lyra2rev2" ; Symbol = "XVG" ; Port = 3431 } + $Pools += [PSCustomObject]@{ Coin = "Vertcoin" ; Algo = "Lyra2rev2" ; Symbol = "VTC" ; Port = 3429 } $Pools | ForEach-Object { @@ -67,7 +66,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $_.Algo + ".mining-dutch.nl" Port = $_.Port - User = "$UserName.$WorkerName" + User = $(if ($Config.("UserName_" + $Name)) {$Config.("UserName_" + $Name)} else {$Config.UserName}) + ".#WorkerName#" Pass = "x" Location = "EU" SSL = $false diff --git a/Pools/MiningPoolHub.ps1 b/Pools/MiningPoolHub.ps1 index 1d012cc8..56da3e6a 100644 --- a/Pools/MiningPoolHub.ps1 +++ b/Pools/MiningPoolHub.ps1 @@ -11,13 +11,13 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = "APIKEY" +$WalletMode = "ApiKey" $RewardType = "PPLS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Registration required, set UserName/WorkerName in config.ini file" + Disclaimer = "Registration required, set UserName in config" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode @@ -26,7 +26,7 @@ if ($Querymode -eq "info") { } } -if ($Querymode -eq "APIKEY") { +if ($Querymode -eq "ApiKey") { $Request = Invoke-APIRequest -Url "https://$($Info.Symbol).miningpoolhub.com/index.php?page=api&action=getdashboarddata&api_key=$($Info.ApiKey)&id=&$(Get-Date -Format "yyyy-MM-dd_HH-mm")" -Retry 3 @@ -34,8 +34,8 @@ if ($Querymode -eq "APIKEY") { $Data = $Request.getdashboarddata.data $Result = [PSCustomObject]@{ Pool = $name - currency = $Info.Symbol - balance = $Data.balance.confirmed + + Currency = $Info.Symbol + Balance = $Data.balance.confirmed + $Data.balance.unconfirmed + $Data.balance_for_auto_exchange.confirmed + $Data.balance_for_auto_exchange.unconfirmed + @@ -46,7 +46,7 @@ if ($Querymode -eq "APIKEY") { } } -if ($Querymode -eq "SPEED") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url "https://$($Info.Symbol).miningpoolhub.com/index.php?page=api&action=getuserworkers&api_key=$($Info.ApiKey)&$(Get-Date -Format "yyyy-MM-dd_HH-mm")" -Retry 1 @@ -67,23 +67,23 @@ if ($Querymode -eq "SPEED") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { - if (!$UserName) { - Write-Warning "$Name UserName not defined in config.ini" + if (-not $Config.UserName -and -not $Config.("UserName_" + $Name)) { + Write-Warning "$Name UserName not defined" Exit } $MiningPoolHub_Request = Invoke-APIRequest -Url "https://miningpoolhub.com/index.php?page=api&action=getminingandprofitsstatistics&$(Get-Date -Format "yyyy-MM-dd_HH-mm")" -Retry 3 - if (!$MiningPoolHub_Request) { + if (-not $MiningPoolHub_Request) { Write-Warning "$Name API NOT RESPONDING...ABORTING" Exit } $Locations = "EU", "US", "Asia" - $MiningPoolHub_Request.return | Where-Object time_since_last_block -gt 0 | Where-Object profit -gt 0 | ForEach-Object { + $MiningPoolHub_Request.return | Where-Object time_since_last_block -gt 0 | ForEach-Object { $MiningPoolHub_Algorithm = Get-AlgoUnifiedName $_.algo $MiningPoolHub_Coin = Get-CoinUnifiedName $_.coin_name @@ -91,7 +91,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { $MiningPoolHub_OriginalCoin = $_.coin_name $MiningPoolHub_Hosts = $_.host_list -split ";" - $MiningPoolHub_Port = $_.direct_mining_algo_port + $MiningPoolHub_Port = $_.port $MiningPoolHub_Price = [double]($_.profit / 1e9) @@ -103,11 +103,10 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Algorithm = $MiningPoolHub_Algorithm Info = $MiningPoolHub_Coin Price = [decimal]$MiningPoolHub_Price - Price24h = [decimal]$MiningPoolHub_Price #MPH doesnt send this on api Protocol = "stratum+tcp" Host = $Server Port = $MiningPoolHub_Port - User = "$UserName.#WorkerName#" + User = $(if ($Config.("UserName_" + $Name)) {$Config.("UserName_" + $Name)} else {$Config.UserName}) + ".#WorkerName#" Pass = "x" Location = $Location Symbol = Get-CoinSymbol -Coin $MiningPoolHub_Coin diff --git a/Pools/MiningPoolHubCoins.ps1 b/Pools/MiningPoolHubCoins.ps1 deleted file mode 100644 index 1cdb9170..00000000 --- a/Pools/MiningPoolHubCoins.ps1 +++ /dev/null @@ -1,129 +0,0 @@ -param( - [Parameter(Mandatory = $true)] - [String]$Querymode = $null, - [Parameter(Mandatory = $false)] - [PSCustomObject]$Info -) - -#. .\Include.ps1 - -$Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName -$ActiveOnManualMode = $true -$ActiveOnAutomaticMode = $true -$ActiveOnAutomatic24hMode = $true -$WalletMode = "APIKEY" -$RewardType = "PPLS" -$Result = @() - -if ($Querymode -eq "info") { - $Result = [PSCustomObject]@{ - Disclaimer = "Registration required, set UserName/WorkerName in config.ini file" - ActiveOnManualMode = $ActiveOnManualMode - ActiveOnAutomaticMode = $ActiveOnAutomaticMode - ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - WalletMode = $WalletMode - RewardType = $RewardType - } -} - -if ($Querymode -eq "APIKEY") { - - $Request = Invoke-APIRequest -Url "https://$($Info.Symbol).miningpoolhub.com/index.php?page=api&action=getdashboarddata&api_key=$($Info.ApiKey)&id=&$(Get-Date -Format "yyyy-MM-dd_HH-mm")" -Retry 3 - - if ($Request.getdashboarddata.data) { - $Data = $Request.getdashboarddata.data - $Result = [PSCustomObject]@{ - Pool = $name - currency = $Info.Symbol - balance = $Data.balance.confirmed + - $Data.balance.unconfirmed + - $Data.balance_for_auto_exchange.confirmed + - $Data.balance_for_auto_exchange.unconfirmed + - $Data.balance_on_exchange - } - Remove-Variable Request - Remove-Variable Data - } -} - -if ($Querymode -eq "SPEED") { - - $Request = Invoke-APIRequest -Url "https://$($Info.Symbol).miningpoolhub.com/index.php?page=api&action=getuserworkers&api_key=$($Info.ApiKey)&$(Get-Date -Format "yyyy-MM-dd_HH-mm")" -Retry 1 - - if ($Request.getuserworkers.data) { - $Data = $Request.getuserworkers.data - $Result = $Data | ForEach-Object { - if ($_.HashRate -gt 0) { - [PSCustomObject]@{ - PoolName = $name - Diff = $_.difficulty - WorkerName = $_.UserName.split('.')[1] - HashRate = $_.HashRate - } - } - } - Remove-Variable Request - Remove-Variable Data - } -} - -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { - - if (!$UserName) { - Write-Warning "$Name UserName not defined in config.ini" - Exit - } - - $MiningPoolHub_Request = Invoke-APIRequest -Url "https://miningpoolhub.com/index.php?page=api&action=getminingandprofitsstatistics&$(Get-Date -Format "yyyy-MM-dd_HH-mm")" -Retry 3 - - if (!$MiningPoolHub_Request) { - Write-Warning "$Name API NOT RESPONDING...ABORTING" - Exit - } - - $Locations = "EU", "US", "Asia" - - $MiningPoolHub_Request.return | Where-Object time_since_last_block -gt 0 | ForEach-Object { - - $MiningPoolHub_Algorithm = Get-AlgoUnifiedName $_.algo - $MiningPoolHub_Coin = Get-CoinUnifiedName $_.coin_name - - $MiningPoolHub_OriginalCoin = $_.coin_name - - $MiningPoolHub_Hosts = $_.host_list -split ";" - $MiningPoolHub_Port = $_.port - - $MiningPoolHub_Price = [double]($_.profit / 1e9) - - foreach ($Location in $Locations) { - - $Server = $MiningPoolHub_Hosts | Sort-Object {$_ -like "$Location*"} -Descending | Select-Object -First 1 - - $Result += [PSCustomObject]@{ - Algorithm = $MiningPoolHub_Algorithm - Info = $MiningPoolHub_Coin - Price = [decimal]$MiningPoolHub_Price - Price24h = [decimal]$MiningPoolHub_Price #MPH doesnt send this on api - Protocol = "stratum+tcp" - Host = $Server - Port = $MiningPoolHub_Port - User = "$UserName.#WorkerName#" - Pass = "x" - Location = $Location - Symbol = Get-CoinSymbol -Coin $MiningPoolHub_Coin - ActiveOnManualMode = $ActiveOnManualMode - ActiveOnAutomaticMode = $ActiveOnAutomaticMode - WalletMode = $WalletMode - WalletSymbol = $MiningPoolHub_OriginalCoin - PoolName = $Name - Fee = 0.009 + 0.002 # Pool fee + AutoExchange fee - EthStMode = 2 - RewardType = $RewardType - } - } - } - Remove-Variable MiningPoolHub_Request -} - -$Result | ConvertTo-Json | Set-Content $Info.SharedFile -Remove-Variable Result diff --git a/Pools/MyPools.ps1 b/Pools/MyPools.ps1 index c236da30..30132e37 100644 --- a/Pools/MyPools.ps1 +++ b/Pools/MyPools.ps1 @@ -8,11 +8,11 @@ param( $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $false -$WalletMode = "NONE" +$WalletMode = "None" $RewardType = "PPLS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ Disclaimer = "Must set wallet for each coin on web, set login on config.ini file" ActiveOnManualMode = $ActiveOnManualMode @@ -23,13 +23,13 @@ if ($Querymode -eq "info") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Pools = @() # $Pools += [PSCustomObject]@{coin = "HPPcoin"; algo = "Lyra2h"; symbol = "HPP"; server = "pool.hppcoin.com"; port = 3008; fee = 0.02; user = "$UserName.#WorkerName#"} # $Pools += [PSCustomObject]@{coin = "HPPcoin"; algo = "Lyra2h"; symbol = "HPP"; server = "pool.hppcoin.com"; port = 3008; fee = 0.02; user = "$UserName.#WorkerName#"} - $Pools += [PSCustomObject]@{coin = "Dallar"; algo = "Throestl"; symbol = "DAL"; server = "pool.dallar.org"; port = 3032; fee = 0.01; user = $CoinsWallets.DAL} - $Pools += [PSCustomObject]@{coin = "Pascalcoin"; algo = "RandomHash"; symbol = "PASC"; server = "mine.pool.pascalpool.org"; port = 3333; fee = 0.01; user = $CoinsWallets.PASC} + $Pools += [PSCustomObject]@{coin = "Dallar"; algo = "Throestl"; symbol = "DAL"; server = "pool.dallar.org"; port = 3032; fee = 0.01; user = $Wallets.DAL} + $Pools += [PSCustomObject]@{coin = "Pascalcoin"; algo = "RandomHash"; symbol = "PASC"; server = "mine.pool.pascalpool.org"; port = 3333; fee = 0.01; user = $Wallets.PASC} $Pools += [PSCustomObject]@{coin = "Grin"; algo = "Cuckaroo29"; symbol = "GRIN"; server = "eu-west-stratum.grinmint.com"; port = 3416; fee = 0.01; user = '$($Config.Email)/#WorkerName#'} $Pools | ForEach-Object { diff --git a/Pools/NLPool.ps1 b/Pools/NLPool.ps1 index 500459b1..72008a3d 100644 --- a/Pools/NLPool.ps1 +++ b/Pools/NLPool.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://nlpool.nl/api' $MineUrl = 'mine.nlpool.nl' $Location = 'EU' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC/LTC, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -70,7 +70,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Config.("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC', 'LTC') -notcontains $Currency -and @@ -79,8 +79,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -102,8 +102,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $MineUrl Port = $Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/NanoPool.ps1 b/Pools/NanoPool.ps1 index c1bd60f6..63c234a6 100644 --- a/Pools/NanoPool.ps1 +++ b/Pools/NanoPool.ps1 @@ -11,13 +11,13 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = "WALLET" +$WalletMode = "Wallet" $RewardType = "PPLS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "No registration, No autoexchange, need wallet for each coin on config.ini" + Disclaimer = "No registration, No autoexchange, need wallet for each coin" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode @@ -27,7 +27,7 @@ if ($Querymode -eq "info") { } } -if ($Querymode -eq "SPEED") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $("https://api.nanopool.org/v1/" + $Info.symbol.tolower() + "/history/" + $Info.user) -Retry 1 if ($Request) { $Result = [PSCustomObject]@{ @@ -38,18 +38,18 @@ if ($Querymode -eq "SPEED") { } } -if ($Querymode -eq "WALLET") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $("https://api.nanopool.org/v1/" + $Info.symbol.tolower() + "/balance/" + $Info.user) -Retry 3 if ($Request) { $Result = [PSCustomObject]@{ Pool = $name - currency = $Info.Symbol - balance = $Request.data + Currency = $Info.Symbol + Balance = $Request.data } } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $PrePools = @() $PrePools += [PSCustomObject]@{coin = "Ethereum"; algo = "Ethash"; symbol = "ETH"; port = 9999; fee = 0.01; divisor = 1000000; protocol = "stratum+tcp"}; @@ -74,12 +74,11 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Algorithm = $_.algo Info = $_.Coin Price = [decimal]$RequestP.bitcoins / $_.Divisor / 1000 - Price24h = [decimal]$RequestP.bitcoins / $_.Divisor / 1000 Protocol = "stratum+tcp" #$_.Protocol Host = $loc.server Port = $_.Port - User = $CoinsWallets.($_.Symbol) - Pass = "x,#WorkerName#" + User = $Wallets.($_.Symbol) + "/#WorkerName#/$(Config.Email)" + Pass = "x" Location = $loc.location SSL = $false Symbol = $_.symbol diff --git a/Pools/NiceHash.ps1 b/Pools/NiceHash.ps1 index 385fd947..da3bd99d 100644 --- a/Pools/NiceHash.ps1 +++ b/Pools/NiceHash.ps1 @@ -11,23 +11,23 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = "WALLET" +$WalletMode = "Wallet" $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "No registration, Autoexchange to BTC always" + Disclaimer = "Autoexchange to BTC, No registration required. Register and set BTC_NICE for lower fees" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Info.user = $Info.user.split('.')[0] $Request = Invoke-APIRequest -Url $("https://api.nicehash.com/api?method=stats.provider.workers&addr=" + $Info.user) -Retry 1 @@ -51,7 +51,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Info.user = ($Info.user -split '\.')[0] $Request = Invoke-APIRequest -Url $("https://api.nicehash.com/api?method=stats.provider&addr=" + $Info.user) -Retry 3 | Select-Object -ExpandProperty result | Select-Object -ExpandProperty stats @@ -66,9 +66,9 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { - if (!$CoinsWallets.BTC_NICE -and !$CoinsWallets.BTC) { + if (-not $Wallets.BTC_NICE -and -not $Wallets.BTC) { Write-Warning "$Name BTC or BTC_NICE wallets not defined in config.ini" Exit } @@ -101,14 +101,13 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Algorithm = $Algo Info = $Algo Price = [decimal]$_.paying / $Divisor - Price24h = [decimal]$_.paying / $Divisor Protocol = "stratum+tcp" ProtocolSSL = "ssl" Host = $_.name + "." + $Locations.$location + ".nicehash.com" HostSSL = $_.name + "." + $Locations.$location + ".nicehash.com" Port = $_.port PortSSL = $_.port + 30000 - User = $(if ($CoinsWallets.BTC_NICE) {$CoinsWallets.BTC_NICE} else {$CoinsWallets.BTC}) + '.' + "#WorkerName#" + User = $(if ($Wallets.BTC_NICE) {$Wallets.BTC_NICE} else {$Wallets.BTC}) + '.' + "#WorkerName#" Pass = "x" Location = $Location SSL = $enableSSL @@ -118,7 +117,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { PoolName = $Name WalletMode = $WalletMode WalletSymbol = "BTC" - Fee = $(if ($CoinsWallets.BTC_NICE) {0.02} else {0.05}) + Fee = $(if ($Wallets.BTC_NICE) {0.02} else {0.05}) EthStMode = 3 RewardType = $RewardType } diff --git a/Pools/PhiPhiPool.ps1 b/Pools/PhiPhiPool.ps1 index d9c9262c..6cc42add 100644 --- a/Pools/PhiPhiPool.ps1 +++ b/Pools/PhiPhiPool.ps1 @@ -11,7 +11,7 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://phi-phi-pool.com/api' $Locations = @{ 'US' = 'us.phi-phi-pool.com' @@ -21,19 +21,19 @@ $Locations = @{ $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC, No registration required" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -42,7 +42,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -52,7 +52,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -65,7 +65,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -73,7 +73,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Config.("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC') -notcontains $Currency -and @@ -82,8 +82,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -107,8 +107,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Locations.$Location Port = $Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/StarPool.ps1 b/Pools/StarPool.ps1 index f61b1178..645641ec 100644 --- a/Pools/StarPool.ps1 +++ b/Pools/StarPool.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://www.starpool.biz/api' $MineUrl = 'starpool.biz' $Location = 'EU' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC/LTC/DASH/CANN/DGB, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -70,7 +70,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Config.("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC', 'LTC', 'DASH', 'CANN', 'DGB') -notcontains $Currency -and @@ -79,8 +79,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -102,8 +102,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Algo.name + '.' + $MineUrl Port = $Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/SuprNova.ps1 b/Pools/SuprNova.ps1 index 2c5afe38..da07047a 100644 --- a/Pools/SuprNova.ps1 +++ b/Pools/SuprNova.ps1 @@ -54,7 +54,7 @@ if ($Querymode -eq "Speed") { } } -if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { if (-not $Config.UserName -and -not $PoolConfig.$Name.UserName) { Write-Warning "$Name UserName not defined" @@ -96,7 +96,7 @@ if (($Querymode -eq "Core" ) -or ($Querymode -eq "Menu")) { HostSSL = $_.WalletSymbol + ".suprnova.cc" Port = $_.Port PortSSL = $_.PortSSL - User = "$UserName.#WorkerName#" + User = $(if ($Config.("UserName_" + $Name)) {$Config.("UserName_" + $Name)} else {$Config.UserName}) + ".#WorkerName#" Pass = "x" Location = "US" SSL = [bool]($_.PortSSL) diff --git a/Pools/UniMining.ps1 b/Pools/UniMining.ps1 index cf3fd5a5..6ff6d572 100644 --- a/Pools/UniMining.ps1 +++ b/Pools/UniMining.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $false $ActiveOnAutomatic24hMode = $false -$WalletMode = 'WALLET' -$ApiUrl = 'https://pool.unimining.net/api' +$WalletMode = 'Wallet' +$ApiUrl = 'https://unimining.net/api' $MineUrl = 'eu1.unimining.net' $Location = 'US' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "No registration, No autoexchange, need wallet for each coin on config.ini" + Disclaimer = "No registration, No autoexchange, need wallet for each coin" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $RequestCurrencies -or -not $Request) { @@ -91,8 +91,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Coin.algo + '.' + $MineUrl Port = [int]$Coin.port - User = $CoinsWallets.$Pool_Symbol - Pass = "c=$Pool_Symbol,ID=#WorkerName#" + User = $Wallets.$Pool_Symbol + Pass = "c=$Pool_Symbol,id=#WorkerName#" Location = $Location SSL = $false Symbol = $Pool_Symbol diff --git a/Pools/WhatToMine.ps1 b/Pools/WhatToMine.ps1 index 2a135ed0..f26a269b 100644 --- a/Pools/WhatToMine.ps1 +++ b/Pools/WhatToMine.ps1 @@ -48,14 +48,17 @@ if (($Querymode -eq "Wallet") -or ($Querymode -eq "ApiKey")) { } } -if ($Querymode -eq "Core" -or $Querymode -eq "Menu") { +if ($Querymode -eq "Core") { #Look for pools - $ConfigOrder = $PoolConfig.$Name.PoolOrder -split ',' + $ConfigOrder = $Config.("PoolOrder_" + $Name) -split ',' $HPools = foreach ($PoolToSearch in $ConfigOrder) { $HPoolsTmp = Get-Pools -Querymode "core" -PoolsFilterList $PoolToSearch -location $Info.Location #Filter by minworkes variable (must be here for not selecting now a pool and after that discarded on core.ps1 filter) - $HPoolsTmp | Where-Object {$_.Poolworkers -ge (Get-ConfigVariable "MINWORKERS") -or $_.Poolworkers -eq $null} + $HPoolsTmp | Where-Object { + $_.PoolWorkers -eq $null -or + $_.PoolWorkers -ge $(if ($Config.("MinWorkers_" + $PoolToSearch)) {$Config.("MinWorkers_" + $PoolToSearch)} else {$Config.MinWorkers}) + } } #Common Data from WTM diff --git a/Pools/YIIMP.ps1 b/Pools/YIIMP.ps1 index b6c93696..5446aa9b 100644 --- a/Pools/YIIMP.ps1 +++ b/Pools/YIIMP.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $false $ActiveOnAutomatic24hMode = $false -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'http://api.yiimp.eu/api' $MineUrl = 'yiimp.eu' $Location = 'EU' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "No registration, No autoexchange, need wallet for each coin on config.ini" + Disclaimer = "No registration, No autoexchange, need wallet for each coin" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $RequestCurrencies -or -not $Request) { @@ -91,8 +91,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $MineUrl Port = [int]$Coin.port - User = $CoinsWallets.$Pool_Symbol - Pass = "c=$Pool_Symbol,ID=#WorkerName#" + User = $Wallets.$Pool_Symbol + Pass = "c=$Pool_Symbol,id=#WorkerName#" Location = $Location SSL = $false Symbol = $Pool_Symbol diff --git a/Pools/ZergPool.ps1 b/Pools/ZergPool.ps1 index b91abd95..240557a8 100644 --- a/Pools/ZergPool.ps1 +++ b/Pools/ZergPool.ps1 @@ -11,26 +11,26 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'http://api.zergpool.com:8080/api' $MineUrl = 'mine.zergpool.com' $Location = 'US' $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC/LTC/DASH, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -39,7 +39,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -49,7 +49,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -62,7 +62,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -70,7 +70,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Config.("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC', 'LTC', 'DASH') -notcontains $Currency -and @@ -79,8 +79,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -102,8 +102,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Algo.name + "." + $MineUrl Port = [int]$Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Pools/Zpool.ps1 b/Pools/Zpool.ps1 index 73075e93..20bffa25 100644 --- a/Pools/Zpool.ps1 +++ b/Pools/Zpool.ps1 @@ -11,7 +11,7 @@ $Name = (Get-Item $script:MyInvocation.MyCommand.Path).BaseName $ActiveOnManualMode = $true $ActiveOnAutomaticMode = $true $ActiveOnAutomatic24hMode = $true -$WalletMode = 'WALLET' +$WalletMode = 'Wallet' $ApiUrl = 'https://www.zpool.ca/api' $Locations = @{ 'US' = 'na.mine.zpool.ca' @@ -21,19 +21,19 @@ $Locations = @{ $RewardType = "PPS" $Result = @() -if ($Querymode -eq "info") { +if ($Querymode -eq "Info") { $Result = [PSCustomObject]@{ - Disclaimer = "Autoexchange to @@currency coin specified in config.ini, no registration required" + Disclaimer = "Autoexchange to BTC/LTC/DASH, No registration" ActiveOnManualMode = $ActiveOnManualMode ActiveOnAutomaticMode = $ActiveOnAutomaticMode ActiveOnAutomatic24hMode = $ActiveOnAutomatic24hMode - ApiData = $True + ApiData = $true WalletMode = $WalletMode RewardType = $RewardType } } -if ($Querymode -eq "speed") { +if ($Querymode -eq "Speed") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/walletEx?address=" + $Info.user) -Retry 1 if ($Request) { @@ -42,7 +42,7 @@ if ($Querymode -eq "speed") { PoolName = $Name Version = $_.version Algorithm = Get-AlgoUnifiedName $_.Algo - WorkerName = (($_.password -split 'ID=')[1] -split ',')[0] + WorkerName = (($_.password -split 'id=')[1] -split ',')[0] Diff = $_.difficulty Rejected = $_.rejected HashRate = $_.accepted @@ -52,7 +52,7 @@ if ($Querymode -eq "speed") { } } -if ($Querymode -eq "wallet") { +if ($Querymode -eq "Wallet") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/wallet?address=" + $Info.user) -Retry 3 if ($Request) { @@ -65,7 +65,7 @@ if ($Querymode -eq "wallet") { } } -if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { +if ($Querymode -eq "Core") { $Request = Invoke-APIRequest -Url $($ApiUrl + "/status") -Retry 3 $RequestCurrencies = Invoke-APIRequest -Url $($ApiUrl + "/currencies") -Retry 3 if (-not $Request) { @@ -73,7 +73,7 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Exit } - $Currency = if ([string]::IsNullOrEmpty($(Get-ConfigVariable "CURRENCY_$Name"))) { Get-ConfigVariable "CURRENCY" } else { Get-ConfigVariable "CURRENCY_$Name" } + $Currency = if ($Config.("Currency_" + $Name)) {$Confi.g("Currency_" + $Name)} else {$Config.Currency} if ( @('BTC', 'LTC', 'DASH') -notcontains $Currency -and @@ -82,8 +82,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Write-Warning "$Name $Currency may not be supported for payment" } - if (!$CoinsWallets.$Currency) { - Write-Warning "$Name $Currency wallet not defined in config.ini" + if (-not $Wallets.$Currency) { + Write-Warning "$Name $Currency wallet not defined" Exit } @@ -107,8 +107,8 @@ if (($Querymode -eq "core" ) -or ($Querymode -eq "Menu")) { Protocol = "stratum+tcp" Host = $Algo.name + "." + $Locations.$Location Port = $Algo.port - User = $CoinsWallets.$Currency - Pass = "c=$Currency,ID=#WorkerName#" + User = $Wallets.$Currency + Pass = "c=$Currency,id=#WorkerName#" Location = $Location SSL = $false Symbol = Get-CoinSymbol -Coin $Pool_Algo diff --git a/Readme.md b/Readme.md index c4d53210..8e4bb8f0 100644 --- a/Readme.md +++ b/Readme.md @@ -42,7 +42,7 @@ NVIDIA miners are not 100% untested. * Profit display in mBTC instead of BTC with too many zeroes * Support profitability info for all coins on WhatToMine * Power usage approximation for AMD and CPU when Afterburner integration is off - - You will need to add TDP values for your hardware in _cpu-tdp.json_ or _amd-cards-tdp.json_ if they are not there + - You will need to add TDP values for your hardware in _/Data/cpu-tdp.json_ or _/Data/amd-cards-tdp.json_ if they are not there * Support any fiat currency which is supported by CoinDesk for profit display * Allow dual mining any Ethash coin instead of ETH/ETC only * Filter out algos without solved blocks in 24h on MPH and YIIMP type pools diff --git a/START.bat b/START.bat index f8ee7485..da5e9060 100644 --- a/START.bat +++ b/START.bat @@ -2,7 +2,14 @@ cd /d %~dp0 -powershell -version 5.0 -noexit -executionpolicy bypass -command "& .\Miner.ps1" -::pwsh -noexit -executionpolicy bypass -command "& .\Miner.ps1" +set Command="& .\Miner.ps1" +where pwsh >nul 2>nul || goto powershell +pwsh -noexit -executionpolicy bypass -command %Command% +goto end + +:powershell +powershell -version 5.0 -noexit -executionpolicy bypass -command %Command% + +:end pause