-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathminer.h
228 lines (192 loc) · 7.23 KB
/
miner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#define RAPIDJSON_NO_SIZETYPEDEFINE
namespace rapidjson { typedef size_t SizeType; }
using namespace rapidjson;
#include "rapidjson/document.h" // rapidjson's DOM-style API
#include "rapidjson/error/en.h"
#include <string.h>
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <map>
#include <vector>
#include <thread>
#pragma comment(lib,"Ws2_32.lib")
#include <ws2tcpip.h>
#include <mswsock.h> // Need for SO_UPDATE_CONNECT_CONTEXT
#include "curses.h"
//#include "panel.h"
#include "sph_shabal.h"
#include "mshabal.h"
#include "mshabal256.h"
#include "shabal_asm.h"
#include "InstructionSet.h"
#include "picohttpparser.h"
/*
#define GPU_ON_C 1
//#define GPU_ON_CPP
#ifdef GPU_ON_CPP
#define __CL_ENABLE_EXCEPTIONS 100
#include <CL\cl.hpp>
#include "OpenCL_Error.h"
#include "OpenCL_Platform.h"
#include "OpenCL_Device.h"
#endif
#ifdef GPU_ON_C
//#define __CL_ENABLE_EXCEPTIONS 100
#include <CL\cl.h>
#endif
*/
HANDLE hHeap;
bool exit_flag = false;
#ifdef __AVX2__
char const *const version = "v1.170820_AVX2";
#else
#ifdef __AVX__
char const *const version = "v1.170820_AVX";
#else
char const *const version = "v1.170820";
#endif
#endif
unsigned long long startnonce = 0;
unsigned long nonces = 0;
unsigned int scoop = 0;
unsigned long long deadline = 0;
int network_quality = 100;
char signature[33];
char str_signature[65];
char oldSignature[33];
unsigned long long height = 0;
unsigned long long baseTarget = 0;
unsigned long long targetDeadlineInfo = 0; // Ìàêñèìàëüíûé äåäëàéí ïóëà
unsigned long long my_target_deadline = MAXDWORD; // 4294967295;
volatile int stopThreads = 0;
char *pass = nullptr; // ïàðîëü
std::string nodeaddr = "localhost"; // àäðåñ ïóëà
std::string nodeport = "8125"; // ïîðò ïóëà
std::string updateraddr = "localhost";// àäðåñ ïóëà
std::string updaterport = "8125"; // ïîðò ïóëà
std::string infoaddr = "localhost"; // àäðåñ ïóëà
std::string infoport = "8125"; // ïîðò ïóëà
std::string proxyport = "8125"; // ïîðò ïóëà
char *p_minerPath = nullptr; // ïóòü ê ïàïêå ìàéíåðà
size_t miner_mode = 0; // ðåæèì ìàéíåðà. 0=ñîëî, 1=ïóë
size_t cache_size = 100000; // ðàçìåð êýøà ÷òåíèÿ ïëîòîâ
std::vector<std::string> paths_dir; // ïóòè
//bool show_msg = false; // Ïîêàçàòü îáùåíèå ñ ñåðâåðîì â îòïðàâùèêå
//bool show_updates = false; // Ïîêàçàòü îáùåíèå ñ ñåðâåðîì â àïäåéòåðå
FILE * fp_Log = nullptr; // óêàçàòåëü íà ëîã-ôàéë
size_t send_interval = 100; // âðåìÿ îæèäàíèÿ ìåæäó îòïðàâêàìè
size_t update_interval = 1000; // âðåìÿ îæèäàíèÿ ìåæäó àïäåéòàìè
short win_size_x = 80;
short win_size_y = 60;
//bool use_fast_rcv = false;
bool use_debug = false;
bool enable_proxy = false;
//bool send_best_only = true;
bool use_wakeup = false;
bool use_log = true; // Âåñòè ëîã
bool use_boost = false; // Èñïîëüçîâàòü ïîâûøåííûé ïðèîðèòåò äëÿ ïîòîêîâ
bool show_winner = false; // ïîêàçûâàòü ïîáåäèòåëÿ
//short can_generate = 0; // 0 - disable; 1 - can start generate; 2 - already run generator
SYSTEMTIME cur_time; // Òåêóùåå âðåìÿ
unsigned long long total_size = 0; // Îáùèé îáúåì ïëîòîâ
WINDOW * win_main;
//PANEL *panel_main;
std::vector<std::thread> worker;
struct t_worker_progress{
size_t Number;
unsigned long long Reads_bytes;
bool isAlive;
};
std::vector<t_worker_progress> worker_progress;
std::map <u_long, unsigned long long> satellite_size; // Ñòðóêòóðà ñ îáúåìàìè ïëîòîâ ñàòåëëèòîâ
struct t_files{
std::string Path;
std::string Name;
unsigned long long Size;// = 0;
unsigned long long Key;
unsigned long long StartNonce;
unsigned long long Nonces;
unsigned long long Stagger;
//unsigned State;// = 0;
//t_files(std::string p_Path, std::string p_Name, unsigned long long p_Size, unsigned p_State) : Path(std::move(p_Path)), Name(std::move(p_Name)), Size(p_Size), State(p_State){};
//t_files(t_files &&fill) : Path(std::move(fill.Path)), Name(std::move(fill.Name)), Size(fill.Size), State(fill.State){};
//t_files& operator=(const t_files& fill) = default;
};
struct t_shares{
std::string file_name;
unsigned long long account_id;// = 0;
unsigned long long best;// = 0;
unsigned long long nonce;// = 0;
//t_shares(std::string p_file_name, unsigned long long p_account_id, unsigned long long p_best, unsigned long long p_nonce) : file_name(std::move(p_file_name)), account_id(p_account_id), best(p_best), nonce(p_nonce){};
};
std::vector<t_shares> shares;
struct t_best{
unsigned long long account_id;// = 0;
unsigned long long best;// = 0;
unsigned long long nonce;// = 0;
unsigned long long DL;// = 0;
unsigned long long targetDeadline;// = 0;
//t_best(unsigned long long p_account_id, unsigned long long p_best, unsigned long long p_nonce, unsigned long long p_DL, unsigned long long p_targetDeadline) : account_id(p_account_id), best(p_best), nonce(p_nonce), DL(p_DL), targetDeadline(p_targetDeadline){};
};
std::vector<t_best> bests;
struct t_session{
SOCKET Socket;
// unsigned long long ID;
unsigned long long deadline;
t_shares body;
// unsigned long long best;// = 0;
// unsigned long long nonce;// = 0;
};
std::vector<t_session> sessions;
#ifdef GPU_ON_C
struct t_gpu{
size_t max_WorkGroupSize = 1;
size_t use_gpu_platform = 0;
size_t use_gpu_device = 0;
cl_device_id *devices = nullptr;
cl_uint num_devices = 0;
cl_uint max_ComputeUnits = 1;
};
t_gpu gpu_devices;
#endif
CRITICAL_SECTION sessionsLock; // îáíîâëåíèå sessions
CRITICAL_SECTION bestsLock; // îáíîâëåíèå bests
CRITICAL_SECTION sharesLock; // îáíîâëåíèå shares
// ========== HEADERS ==========
void ShowMemErrorExit(void);
void Log_init(void);
void Log(char const *const strLog);
void Log_server(char const *const strLog);
void Log_llu(unsigned long long const llu_num);
void Log_u(size_t const u_num);
int load_config(char const *const filename);
//LPSTR DisplayErrorText(DWORD dwLastError);
int xdigit(char const digit);
size_t xstr2strr(char *buf, size_t const bufsize, const char *const in);
//std::wstring str2wstr(std::string &s);
void GetPass(char const *const p_strFolderPath);
size_t GetFiles(const std::string &str, std::vector <t_files> *p_files);
size_t Get_index_acc(unsigned long long const key);
//void gen_nonce(unsigned long long addr, unsigned long long start_nonce, unsigned long long count);
//void generator_i(size_t number);
void proxy_i(void);
void send_i(void);
void procscoop_m_4(unsigned long long const nonce, unsigned long long const n, char const *const data, size_t const acc, const std::string &file_name);
void procscoop_m256_8(unsigned long long const nonce, unsigned long long const n, char const *const data, size_t const acc, const std::string &file_name);
void procscoop_sph(const unsigned long long nonce, const unsigned long long n, char const *const data, const size_t acc, const std::string &file_name);
void procscoop_asm(const unsigned long long nonce, const unsigned long long n, char const *const data, const size_t acc, const std::string &file_name);
void work_i(const size_t local_num);
char* GetJSON(char const *const req);
void GetBlockInfo(unsigned const num_block);
void pollLocal(void);
void updater_i(void);
void hostname_to_ip(char const *const in_addr, char* out_addr);
void GetCPUInfo(void);
//std::vector<std::shared_ptr<OpenclPlatform>> GPU_PlatformInfo(void);
//int GPU_DeviceInfo(unsigned platform);
//int GPU(void);
//int GPU1(void);
int main(int argc, char **argv);