btcollider/bfclient/src/bfclient.cpp

49 lines
1.4 KiB
C++
Raw Normal View History

//============================================================================
// Name : bfclient.cpp
// Author : Armin Friedl
// Version :
// Copyright : Public Domain
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <bytestr.h>
#include <ec_pubkey_fast.h>
#include <cstdlib>
#include <iostream>
#include <thread>
#include "bf/Brainflyer.h"
using namespace std;
#define BATCH_MAX 4096
#define WIN_SIZE 21
int main() {
util::bytestr key("db53d9bbd1f3a83b094eeca7dd970bd85b492fa2");
cout << "Initializing precomputation table" << endl;
// init with window size 16, not reading from file
if (secp256k1_ec_pubkey_precomp_table(WIN_SIZE, nullptr) != 0) {
cout << "Initialization of precomputation table failed" << endl;
return (EXIT_FAILURE);
}
cout << "Initializing threads" << endl;
unsigned int numThreads = thread::hardware_concurrency();
cout << numThreads << " hardware threads available" << endl;
thread* threads = new thread[numThreads];
cout << "Starting " << numThreads << " threads" << endl;
//numThreads = 1;
for (unsigned int i = 0; i < numThreads; i++) {
threads[i] = thread{bf::Brainflyer(i, "127.0.0.1", 26765, key)};
}
for (unsigned int i = 0; i < numThreads; i++) threads[i].join();
delete[] threads;
return (EXIT_SUCCESS);
}