-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockchain.h
More file actions
34 lines (27 loc) · 866 Bytes
/
Blockchain.h
File metadata and controls
34 lines (27 loc) · 866 Bytes
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
#ifndef BLOCKCHAIN_H
#define BLOCKCHAIN_H
#include "Block.h"
#include <string>
class Blockchain {
public:
Blockchain();
~Blockchain();
void addBlock(const std::string& sender, const std::string& receiver, double amount);
void printBlockchain() const;
private:
struct Node {
Block* block;
Node* next;
Node(Block* b) : block(b), next(nullptr) {}
};
Node* head;
Node* lastBlock;
int difficulty;
void saveBlockToFile(const Block& block);
void removeLastBlock(); // Remove the last block from the chain
bool loadFromFile(const std::string& filename); // Load blockchain from file
void createGenesisBlock(); // Create and add genesis block if needed
bool validateBlockchain(); // Validate blockchain integrity
void saveBlockchainToFile();
};
#endif