forked from lkm543/BackupMining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
f2pool.php
86 lines (79 loc) · 2.09 KB
/
f2pool.php
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
<?php
date_default_timezone_set("Asia/Taipei").
#require_once(dirname(dirname(__FILE__))."/generalPool.php");
require_once("generalPool.php");
//Reported HashRate
class f2pool extends generalPool {
private $APIurl = "http://api.f2pool.com/eth/";
private $ReportedAPIurl;
public $ErrorMsg;
public $ErrorFlag;
//
public function __construct(){
if($this->Coin == "ETH"){
$this->APIurl = "http://api.f2pool.com/eth/";
#$this->ReportedAPIurl = "";
}
$this->ErrorFlag = False;
$this->ErrorMsg = "";
}
//
public function reset() {
if($this->Coin == "ETH"){
$this->APIurl = "http://api.f2pool.com/eth/";
#$this->ReportedAPIurl = "";
}
$this->ErrorFlag = False;
$this->ErrorMsg = "";
$this->Address = "NULL";
$this->Worker = "NULL";
$this->HashRate = 0.0;
$this->HashRate_LongTerm = 0.0;
$this->ReportedHashRate = 0.0;
$this->Balance = 0.0;
$this->Coin = "NULL";
}
//
public function getDataFromPool(){
try {
//Balance
$response = file_get_contents($this->APIurl.$this->Address);
//echo($APIurl.$Address);
$response = json_decode($response);
if(empty($response)!=1){
$this->ErrorFlag = False;
$this->ErrorMsg = "";
$this->Balance = $response->balance;
####
foreach($response->workers as $workers){
if($workers[0] == $this->Worker){
$this->HashRate = floatval($workers[1]*1E-6); #hashrate
$this->HashRate_LongTerm = floatval($workers[4]/(24*3600)*1E-6); #h24
}
}
}
else{
$this->ErrorFlag = True;
$this->ErrorMsg = $this->ErrorMsg.$response->error."<br>";
}
/*
#f2pool沒有Reported資料
//Worker: Reported
$response = file_get_contents($this->ReportedAPIurl.$this->Address."/".$this->Worker);
$response = json_decode($response);
if($response->status=='true'){
$this->ReportedHashRate = $response->data;
}
else{
$this->ErrorFlag = True;
$this->ErrorMsg = $this->ErrorMsg.$response->error."<br>";
}
*/
}
catch (Exception $e) {
$this->ErrorMsg = $e->getMessage();
$this->ErrorFlag = True;
}
}
}
?>