-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bd9260
commit 9b97871
Showing
165 changed files
with
23,554 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,6 @@ | |
/win32/ariominer/x64 | ||
.idea | ||
cmake-build-debug | ||
proxy/reporting/package-lock.json | ||
proxy/reporting/node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// | ||
// Created by Haifa Bogdan Adnan on 24/02/2019. | ||
// | ||
|
||
#include "node_api.h" | ||
#include "simplejson/json.h" | ||
|
||
node_api::node_api(string wallet) { | ||
__wallet = wallet; | ||
__last_peer_update = 0; | ||
} | ||
|
||
account_balance node_api::get_account_balance() { | ||
account_balance balance; | ||
balance.amount = 0; | ||
balance.last24 = 0; | ||
|
||
string peer_url = __get_peer(); | ||
|
||
string response = _http_get(peer_url + "/api.php?q=getBalance&account=" + __wallet); | ||
|
||
if(!response.empty()) { | ||
json::JSON data = json::JSON::Load(response); | ||
if(data.JSONType() == json::JSON::Class::Object && | ||
data.hasKey("status") && | ||
data["status"].ToString() == "ok" && | ||
data.hasKey("data")) { | ||
balance.amount = atof(data["data"].ToString().c_str()); | ||
} | ||
} | ||
else { | ||
return balance; | ||
} | ||
|
||
time_t timestamp = time(NULL); | ||
response = _http_get(peer_url + "/api.php?q=getTransactions&account=" + __wallet); | ||
|
||
if(!response.empty()) { | ||
json::JSON data = json::JSON::Load(response); | ||
if(data.JSONType() == json::JSON::Class::Object && | ||
data.hasKey("status") && | ||
data["status"].ToString() == "ok" && | ||
data.hasKey("data")) { | ||
json::JSON info = data["data"]; | ||
if(info.JSONType() == json::JSON::Class::Array) { | ||
for(int i=0; i < info.length();i++) { | ||
json::JSON entry = info[i]; | ||
if(entry.JSONType() == json::JSON::Class::Object && | ||
entry.hasKey("date") && | ||
entry.hasKey("type") && | ||
entry.hasKey("val")) { | ||
time_t date = entry["date"].ToInt(); | ||
if (timestamp - date < 86400) { | ||
string type = entry["type"].ToString(); | ||
if (type == "mining" || type == "credit") { | ||
double amount = atof(entry["val"].ToString().c_str()); | ||
balance.last24 += amount; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return balance; | ||
} | ||
|
||
string node_api::__get_peer() { | ||
if(time(NULL) - __last_peer_update > 3600) { | ||
string result = _http_get("http://api.arionum.com/peers.txt"); | ||
if (!result.empty() && result.find("http://") != string::npos) { | ||
vector<string> peers; | ||
stringstream ss(result); | ||
string to; | ||
|
||
while (getline(ss, to, '\n')) { | ||
peers.push_back(to); | ||
} | ||
|
||
__peers_lock.lock(); | ||
__peers = peers; | ||
__peers_lock.unlock(); | ||
} | ||
|
||
__last_peer_update = time(NULL); | ||
} | ||
|
||
string peer_url = ""; | ||
__peers_lock.lock(); | ||
if (__peers.size() > 0) { | ||
int selected_index = rand() % __peers.size(); | ||
peer_url = __peers[selected_index]; | ||
} | ||
__peers_lock.unlock(); | ||
|
||
return peer_url; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Created by Haifa Bogdan Adnan on 24/02/2019. | ||
// | ||
|
||
#ifndef ARIOMINER_NODE_API_H | ||
#define ARIOMINER_NODE_API_H | ||
|
||
#include "../common/common.h" | ||
#include "http.h" | ||
|
||
struct account_balance { | ||
double amount; | ||
double last24; | ||
}; | ||
|
||
class node_api : public http { | ||
public: | ||
node_api(string wallet); | ||
|
||
account_balance get_account_balance(); | ||
|
||
private: | ||
string __get_peer(); | ||
|
||
string __wallet; | ||
|
||
time_t __last_peer_update; | ||
mutex __peers_lock; | ||
vector<string> __peers; | ||
}; | ||
|
||
|
||
#endif //ARIOMINER_NODE_API_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.