Skip to content

Commit

Permalink
Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
fchirica committed Dec 1, 2020
1 parent f394c7f commit 36a3e56
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/2weso_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main() {
bool stopped = false;
fast_algorithm = false;
two_weso = true;
TwoWesolowskiCallback* weso = new TwoWesolowskiCallback(D);
TwoWesolowskiCallback* weso = new TwoWesolowskiCallback(D, f);
FastStorage* fast_storage = NULL;
std::thread vdf_worker(repeated_square, f, D, L, weso, fast_storage, std::ref(stopped));
// Test 1 - 1 million iters.
Expand Down
8 changes: 3 additions & 5 deletions src/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ class OneWesolowskiCallback: public WesolowskiCallback {

class TwoWesolowskiCallback: public WesolowskiCallback {
public:
TwoWesolowskiCallback(integer& D) : WesolowskiCallback(D) {
TwoWesolowskiCallback(integer& D, form f) : WesolowskiCallback(D) {
int space_needed = kSwitchIters / 10 + (kMaxItersAllowed - kSwitchIters) / 100;
forms = (form*) calloc(space_needed, sizeof(form));
form f = form::generator(D);
forms[0] = f;
kl = 10;
switch_iters = -1;
Expand Down Expand Up @@ -166,8 +165,7 @@ class TwoWesolowskiCallback: public WesolowskiCallback {

class FastAlgorithmCallback : public WesolowskiCallback {
public:
FastAlgorithmCallback(int segments, integer& D, bool multi_proc_machine) : WesolowskiCallback(D) {
form f = form::generator(D);
FastAlgorithmCallback(int segments, integer& D, form f, bool multi_proc_machine) : WesolowskiCallback(D) {
buckets_begin.push_back(0);
buckets_begin.push_back(bucket_size1 * window_size);
this->segments = segments;
Expand All @@ -179,7 +177,7 @@ class FastAlgorithmCallback : public WesolowskiCallback {
forms = (form*) calloc(space_needed, sizeof(form));
checkpoints = (form*) calloc((1 << 18), sizeof(form));

y_ret = form::generator(D);
y_ret = f;
for (int i = 0; i < segments; i++)
forms[buckets_begin[i]] = f;
checkpoints[0] = f;
Expand Down
2 changes: 1 addition & 1 deletion src/prover_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main() {
form f=form::generator(D);
bool multi_proc_machine = (std::thread::hardware_concurrency() >= 16) ? true : false;

WesolowskiCallback* weso = new FastAlgorithmCallback(segments, D, multi_proc_machine);
WesolowskiCallback* weso = new FastAlgorithmCallback(segments, D, f, multi_proc_machine);
std::cout << "Discriminant: " << D.impl << "\n";
bool stopped = false;
fast_algorithm = true;
Expand Down
10 changes: 5 additions & 5 deletions src/vdf_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ void InitSession(tcp::socket& sock) {
disc_int_size = atoi(disc_size);
boost::asio::read(sock, boost::asio::buffer(disc, disc_int_size), error);

boost::asio::read(sock, boost::asio::buffer(disc_size, 3), error);
char prefix_len[3];
for (int i = 0; i < 2; i++) {
memset(prefix_len, 0x00, sizeof(prefix_len));
Expand Down Expand Up @@ -175,7 +174,7 @@ void SessionFastAlgorithm(tcp::socket& sock) {
PrintInfo("Initial form: " + to_string(f.a.impl) + " " + to_string(f.b.impl));
std::vector<std::thread> threads;
const bool multi_proc_machine = (std::thread::hardware_concurrency() >= 16) ? true : false;
WesolowskiCallback* weso = new FastAlgorithmCallback(segments, D, multi_proc_machine);
WesolowskiCallback* weso = new FastAlgorithmCallback(segments, D, f, multi_proc_machine);
FastStorage* fast_storage = NULL;
if (multi_proc_machine) {
fast_storage = new FastStorage((FastAlgorithmCallback*)weso);
Expand Down Expand Up @@ -250,16 +249,17 @@ void SessionOneWeso(tcp::socket& sock) {
}

void SessionTwoWeso(tcp::socket& sock) {
const int kMaxProcessesAllowed = 3;
const int kMaxProcessesAllowed = 100;
InitSession(sock);
try {
integer D(disc);
integer L=root(-D, 4);
PrintInfo("Discriminant = " + to_string(D.impl));
integer init_A(form_a);
PrintInfo("Initial A: " + to_string(init_A.impl));
integer init_B(form_b);
PrintInfo("Initial B: " + to_string(init_B.impl));
form f = form::from_abd(init_A, init_B, D);
PrintInfo("Initial form: " + to_string(f.a.impl) + " " + to_string(f.b.impl));

// Tell client that I'm ready to get the challenges.
boost::asio::write(sock, boost::asio::buffer("OK", 2));
Expand All @@ -269,7 +269,7 @@ void SessionTwoWeso(tcp::socket& sock) {
std::vector<std::thread> threads;
// (iteration, thread_id)
std::set<std::pair<uint64_t, uint64_t> > seen_iterations;
WesolowskiCallback* weso = new TwoWesolowskiCallback(D);
WesolowskiCallback* weso = new TwoWesolowskiCallback(D, f);
FastStorage* fast_storage = NULL;
std::thread vdf_worker(repeated_square, f, std::ref(D), std::ref(L), weso, fast_storage, std::ref(stopped));

Expand Down

0 comments on commit 36a3e56

Please sign in to comment.