-
Notifications
You must be signed in to change notification settings - Fork 6
/
Block.h
47 lines (32 loc) · 1.03 KB
/
Block.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
#ifndef BLOCK_H
#define BLOCK_H
#include <QObject>
#include <QByteArray>
#include <QHash>
#include "Transaction.h"
#include "BigInt.h"
class Block
{
QByteArray m_preHash;
QHash<QByteArray, Transaction> m_transactions;
BigInt m_solution;
int m_index;
QByteArray m_cachedBlockHash;
public:
Block(int index = 0);
Block(int index, const QHash<QByteArray, Transaction> &transactions, const QByteArray &preHash);
QByteArray toJson() const;
QByteArray toMessageJson() const;
void addTransaction(const Transaction &t);
void removeTransaction(const Transaction &t);
int getIndex() const;
void setSolution(BigInt solution);
bool isValid();
const QByteArray &getPreHash() const;
const QByteArray &getCacheBlockHash();
const QHash<QByteArray, Transaction> &getTransactions() const;
void refreshBlockHash();
static unsigned int getTarget(int index);
bool parseFromQJsonObject(const QJsonObject &obj);
};
#endif // BLOCK_H