1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
#FUNCTIONS
Function Get-EpochTime()
{
$D = ("01/01/1970" -as [DateTime])
[int]$int_nonce = ((New-TimeSpan -Start $D -End ([DateTime]::UtcNow)).TotalSeconds -as [string])
[string]$str_nonce = ($int_nonce -as [string])
return $str_nonce
}
#MAIN
cls;
#Url of json api requests (wallet whitout "0x")
$nanopoolApi_ETH_req_00 = "whatever";
$nanopoolApi_ETH_req_01 = "https://api.nanopool.org/v1/eth/prices"
$cryptocoApi_ETH_req_00 = "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=EUR";
#Initializing DATA
$balance_total = 0;
$file = New-Item -type file "log.txt" -Force
#When balanced_confirmed is incremented, we want to stock both epoch time and confirmed balance in order to compute mining speed.
$index = 1; #Represents the number of confirmed balance's increments over the script running's time
$field_id = 1; #Represents the id of the fields (1=epoch time)(2=confirmed balance) for each increments of confirmed_balance.
$matrix = New-Object 'object[,]' 100000,2;
$loop = 1
#Starting the loop
Do {
$t = Get-EpochTime;
#Converting eth.nanopool API requests to json Objects
$json_nanopoolApi_ETH_req_00 = (Invoke-WebRequest $nanopoolApi_ETH_req_00).content | ConvertFrom-Json ;
$json_nanopoolApi_ETH_req_01 = (Invoke-WebRequest $nanopoolApi_ETH_req_01).content | ConvertFrom-Json ;
#Converting other API requests to json Objects
$json_cryptocoApi_ETH_req_00 = (Invoke-WebRequest $cryptocoApi_ETH_req_00).content | ConvertFrom-Json ;
#Getting appropriate DATA
$balance_unconfirmed = [decimal]$json_nanopoolApi_ETH_req_00.data.unconfirmed_balance;
$balance_confirmed = [decimal]$json_nanopoolApi_ETH_req_00.data.balance;
$hashrate_current = [decimal]$json_nanopoolApi_ETH_req_00.data.hashrate;
$hashrate_avg_h01 = [decimal]$json_nanopoolApi_ETH_req_00.data.avghashrate.h1;
$hashrate_avg_h03 = [decimal]$json_nanopoolApi_ETH_req_00.data.avghashrate.h3;
$hashrate_avg_h06 = [decimal]$json_nanopoolApi_ETH_req_00.data.avghashrate.h6;
$hashrate_avg_h12 = [decimal]$json_nanopoolApi_ETH_req_00.data.avghashrate.h12;
$hashrate_avg_h24 = [decimal]$json_nanopoolApi_ETH_req_00.data.avghashrate.h24;
$eth_to_eur_nanopool = [decimal]$json_nanopoolApi_ETH_req_01.data.price_eur;
$eth_to_eur_cryptoco = [decimal]$json_cryptocoApi_ETH_req_00.eur;
$balance_total = $balance_confirmed + $balance_unconfirmed
$eth_total_eur = $eth_to_eur_nanopool*$balance_total
#Processing DATA
if ( $index -eq 1 )
{
$matrix[1, 1] += t;
$matrix[1, 2] += $balance_confirmed;
$index++;
}
else
{
if ( ( $balance_confirmed -gt $matrix[$index-1,2]) -And ( $index -ge 3 ) )
{
#Storing the time and balance_confirmed
$matrix[$index, 1] += $t;
$matrix[$index, 2] += $balance_confirmed;
#Delta of time and balance_confirmed between 2 consecutive increments of balance_confirmed
$balance_ti = $matrix[$index,1] - $matrix[1,1];
$ti = $matrix[$index,2] - $matrix[1,2];
#Statistics ETH/period
$eth_per_sec = $balance_ti/$ti
$eth_per_min = $eth_per_sec*60
$eth_per_hou = $eth_per_min*60
$eth_per_day = $eth_per_hou*24
$eth_per_wee = $eth_per_day*7
$eth_per_mon = $eth_per_day*30.42
$eth_per_yea = $eth_per_day*365
#Statistics EUR/period
$eur_per_sec = $eth_per_sec*$eth_to_eur_nanopool
$eur_per_min = $eth_per_min*$eth_to_eur_nanopool
$eur_per_hou = $eth_per_hou*$eth_to_eur_nanopool
$eur_per_day = $eth_per_day*$eth_to_eur_nanopool
$eur_per_wee = $eth_per_wee*$eth_to_eur_nanopool
$eur_per_mon = $eth_per_mon*$eth_to_eur_nanopool
$eur_per_yea = $eth_per_yea*$eth_to_eur_nanopool
$index++;
}
}
#Formating output DATA
cls;
"";
"LOOP N°" + $loop
"------------ RIG ETH ------------"
""
"< HASHRATE STATS >"
""
'Hashrate : Current = ' + $hashrate_current + ' Mh/s'
'Hashrate : H01 = ' + $hashrate_avg_h01 + ' Mh/s'
'Hashrate : H03 = ' + $hashrate_avg_h03 + ' Mh/s'
'Hashrate : H06 = ' + $hashrate_avg_h06 + ' Mh/s'
'Hashrate : H12 = ' + $hashrate_avg_h12 + ' Mh/s'
'Hashrate : H24 = ' + $hashrate_avg_h24 + ' Mh/s'
""
"< ETHERUM MINER STATS >"
""
'Balance : unconfirmed = ' + $balance_unconfirmed + ' ETH'
'Balance : confirmed = ' + $balance_confirmed + ' ETH'
'Balance : total = ' +$balance_total + ' ETH'
""
'1 ETH = ' + $eth_to_eur_nanopool + ' € from nanopool'
'1 ETH = ' + $eth_to_eur_cryptoco + ' € from cryptocompare'
'Total EUR = ' + $eth_total_eur + ' €'
""
"< ETHERUM MINING STATS >"
""
if ( $index -ge 3 )
{
'ETH per sec ' + $eth_per_sec
'ETH per min ' + $eth_per_min
'ETH per hou ' + $eth_per_hou
'ETH per day ' + $eth_per_day
'ETH per wee ' + $eth_per_wee
'ETH per mon ' + $eth_per_mon
'ETH per yea ' + $eth_per_yea
""
'EUR per sec ' + $eur_per_sec
'EUR per min ' + $eur_per_min
'EUR per hou ' + $eur_per_hou
'EUR per day ' + $eur_per_day
'EUR per wee ' + $eur_per_wee
'EUR per mon ' + $eur_per_mon
'EUR per yea ' + $eur_per_yea
}
else
{
"Ethereum mining stats cannot be displayed at the moment"
"It will take at least 30 minutes to get the first values"
"Values will become more and more accurate with time"
"6 hours required to display the first accurate values"
}
$loop++;
$te = Get-EpochTime;
$te = $te - $t;
$T = 10 - $te;
timeout -t $T
}
While (1) |
Partager