This repository has been archived by the owner on Mar 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
job.h
141 lines (96 loc) · 2.6 KB
/
job.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
#define MAX_AUXS 32
class YAAMP_REMOTE;
class YAAMP_COIND;
class YAAMP_COIND_AUX;
struct YAAMP_JOB_VALUES
{
char coinbase[4*1024];
char merkleroot_be[1024];
char header[1024];
char header_be[1024];
unsigned char header_bin[1024];
char hash_hex[1024];
char hash_be[1024];
unsigned char hash_bin[1024];
};
struct YAAMP_JOB_TEMPLATE
{
int created;
char flags[64];
char prevhash_hex[512];
char prevhash_be[512];
char header_hash[512];
char extradata_hex[512];
char extradata_be[512];
// todo: can use extra field
char claim_hex[128];
char claim_be[128];
int txcount;
char txmerkles[YAAMP_SMALLBUFSIZE];
vector<string> txsteps;
vector<string> txdata;
char version[32];
char nbits[32];
char ntime[32];
int height;
int target;
json_int_t value;
char coinb1[4*1024];
char coinb2[4*1024];
char header[256];
bool has_segwit_txs;
bool has_filtered_txs;
int filtered_txs_fee;
int auxs_size;
YAAMP_COIND_AUX *auxs[MAX_AUXS];
};
#define YAAMP_JOB_MAXSUBIDS 200
class YAAMP_JOB: public YAAMP_OBJECT
{
public:
bool block_found;
char name[1024];
int count;
double speed;
double maxspeed;
double profit;
YAAMP_COIND *coind; // either one of them
YAAMP_REMOTE *remote;
YAAMP_JOB_TEMPLATE *templ;
bool remote_subids[YAAMP_JOB_MAXSUBIDS];
};
inline void job_delete(YAAMP_OBJECT *object)
{
YAAMP_JOB *job = (YAAMP_JOB *)object;
if (!job) return;
if (job->templ && job->templ->txcount) {
job->templ->txsteps.clear();
job->templ->txdata.clear();
}
if (job->templ) delete job->templ;
delete job;
}
/////////////////////////////////////////////////////////////////////////////////////////////
int job_get_jobid();
void job_sort();
void job_relock_clients(int jobid_old, int jobid_new);
void job_unlock_clients(YAAMP_JOB *job=NULL);
void job_assign_locked_clients(YAAMP_JOB *job);
bool job_can_mine(YAAMP_JOB *job);
void job_reset_clients(YAAMP_JOB *job=NULL);
bool job_has_free_client();
//YAAMP_JOB_TEMPLATE *job_create_template(YAAMP_COIND *coind);
//void job_create_last(YAAMP_COIND *coind, bool force=false);
/////////////////////////
void job_send_jobid(YAAMP_CLIENT *client, int jobid);
void job_send_last(YAAMP_CLIENT *client);
void job_broadcast(YAAMP_JOB *job);
/////////////////////////
void *job_thread(void *p);
void job_signal();
void job_update();
void job_init();
void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *json_result);
vector<string> coind_aux_hashlist(YAAMP_COIND_AUX **auxs, int size);
vector<string> coind_aux_merkle_branch(YAAMP_COIND_AUX **auxs, int size, int index);
void coind_aux_build_auxs(YAAMP_JOB_TEMPLATE *templ);