@@ -7,7 +7,6 @@ using boost::asio::ip::tcp;
7
7
const int max_length = 2048 ;
8
8
std::mutex socket_mutex;
9
9
10
- int process_number;
11
10
// Segments are 2^16, 2^18, ..., 2^30
12
11
// Best case it'll be able to proof for up to 2^36 due to 64-wesolowski restriction.
13
12
int segments = 8 ;
@@ -22,6 +21,8 @@ char disc[350];
22
21
char disc_size[5 ];
23
22
int disc_int_size;
24
23
24
+ uint8_t initial_form_s[BQFC_FORM_SIZE];
25
+
25
26
void WriteProof (uint64_t iteration, Proof& result, tcp::socket& sock) {
26
27
// Writes the number of iterations
27
28
uint8_t int_bytes[8 ];
@@ -78,13 +79,11 @@ void CreateAndWriteProofTwoWeso(integer& D, form f, uint64_t iters, TwoWesolowsk
78
79
WriteProof (iters, result, sock);
79
80
}
80
81
81
- uint8_t initial_form_s[BQFC_FORM_SIZE];
82
-
83
82
void InitSession (tcp::socket& sock) {
84
83
boost::system ::error_code error;
85
84
86
- memset (disc,0x00 ,sizeof (disc)); // For null termination
87
- memset (disc_size,0x00 ,sizeof (disc_size)); // For null termination
85
+ memset (disc, 0x00 , sizeof (disc)); // For null termination
86
+ memset (disc_size, 0x00 , sizeof (disc_size)); // For null termination
88
87
89
88
boost::asio::read (sock, boost::asio::buffer (disc_size, 3 ), error);
90
89
disc_int_size = atoi (disc_size);
@@ -99,14 +98,14 @@ void InitSession(tcp::socket& sock) {
99
98
else if (error)
100
99
throw boost::system::system_error (error); // Some other error.
101
100
102
- if (getenv ( " warn_on_corruption_in_production" )!= nullptr ) {
103
- warn_on_corruption_in_production= true ;
101
+ if (getenv (" warn_on_corruption_in_production" ) != nullptr ) {
102
+ warn_on_corruption_in_production = true ;
104
103
}
105
104
if (is_vdf_test) {
106
- PrintInfo ( " === Test mode ===" );
105
+ PrintInfo (" === Test mode ===" );
107
106
}
108
107
if (warn_on_corruption_in_production) {
109
- PrintInfo ( " === Warn on corruption enabled ===" );
108
+ PrintInfo (" === Warn on corruption enabled ===" );
110
109
}
111
110
assert (is_vdf_test); // assertions should be disabled in VDF_MODE==0
112
111
set_rounding_mode ();
@@ -123,7 +122,7 @@ void FinishSession(tcp::socket& sock) {
123
122
boost::asio::write (sock, boost::asio::buffer (" STOP" , 4 ));
124
123
125
124
char ack[5 ];
126
- memset (ack,0x00 ,sizeof (ack));
125
+ memset (ack, 0x00 , sizeof (ack));
127
126
boost::asio::read (sock, boost::asio::buffer (ack, 3 ), error);
128
127
assert (strncmp (ack, " ACK" , 3 ) == 0 );
129
128
} catch (std::exception & e) {
@@ -149,7 +148,7 @@ void SessionFastAlgorithm(tcp::socket& sock) {
149
148
InitSession (sock);
150
149
try {
151
150
integer D (disc);
152
- integer L= root (-D, 4 );
151
+ integer L = root (-D, 4 );
153
152
PrintInfo (" Discriminant = " + to_string (D.impl ));
154
153
form f = DeserializeForm (D, initial_form_s, sizeof (initial_form_s));
155
154
PrintInfo (" Initial form: " + to_string (f.a .impl ) + " " + to_string (f.b .impl ));
@@ -197,7 +196,7 @@ void SessionOneWeso(tcp::socket& sock) {
197
196
InitSession (sock);
198
197
try {
199
198
integer D (disc);
200
- integer L= root (-D, 4 );
199
+ integer L = root (-D, 4 );
201
200
PrintInfo (" Discriminant = " + to_string (D.impl ));
202
201
form f = DeserializeForm (D, initial_form_s, sizeof (initial_form_s));
203
202
// Tell client that I'm ready to get the challenges.
@@ -233,7 +232,7 @@ void SessionTwoWeso(tcp::socket& sock) {
233
232
InitSession (sock);
234
233
try {
235
234
integer D (disc);
236
- integer L= root (-D, 4 );
235
+ integer L = root (-D, 4 );
237
236
PrintInfo (" Discriminant = " + to_string (D.impl ));
238
237
form f = DeserializeForm (D, initial_form_s, sizeof (initial_form_s));
239
238
@@ -308,22 +307,19 @@ void SessionTwoWeso(tcp::socket& sock) {
308
307
FinishSession (sock);
309
308
}
310
309
311
- int gcd_base_bits= 50 ;
312
- int gcd_128_max_iter= 3 ;
310
+ int gcd_base_bits = 50 ;
311
+ int gcd_128_max_iter = 3 ;
313
312
314
- int main (int argc, char * argv[]) try
315
- {
313
+ int main (int argc, char * argv[]) try {
316
314
init_gmp ();
317
- if (argc != 4 )
318
- {
315
+ if (argc != 4 ) {
319
316
std::cerr << " Usage: ./vdf_client <host> <port> <counter>\n " ;
320
317
return 1 ;
321
318
}
322
319
323
- if (hasAVX2 ())
324
- {
325
- gcd_base_bits=63 ;
326
- gcd_128_max_iter=2 ;
320
+ if (hasAVX2 ()) {
321
+ gcd_base_bits = 63 ;
322
+ gcd_128_max_iter = 2 ;
327
323
}
328
324
329
325
boost::asio::io_service io_service;
0 commit comments