-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiner.h
32 lines (29 loc) · 860 Bytes
/
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
#ifndef MINER_h
#define MINER_H
#include "TransactionPool.h"
#include "Blockchain.h"
#include "Puzzle.h"
#include "Block.h"
#include <algorithm>
#include <mutex>
#include <atomic>
#include <chrono>
#include <thread>
const unsigned int MINERS_TO_SPAWN = 10;
using namespace std::this_thread;
using namespace std::chrono;
class Miner {
public:
Miner();
void mine(Puzzle* puzzle, TransactionPool* transactionPool, mutex * mtx, Blockchain* blockChain, atomic_int * confirmations);
bool verifyHash(string hash, Puzzle* puzzle);
Transaction* getHighestTransactionFees();
private:
bool setHighestTransactionsFees(TransactionPool* transactionPool);
string createHash(string input);
string getTransactionInput(Transaction* transactions);
string generateRandomString(size_t length);
Transaction* highestTransactionFees;
bool verified;
};
#endif // !MINER_h