-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMilkyExplorer.h
More file actions
39 lines (31 loc) · 1.19 KB
/
MilkyExplorer.h
File metadata and controls
39 lines (31 loc) · 1.19 KB
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
#include "Block.h"
#include "Explorer.h"
#ifndef MILKYEXPLORER_H
#define MILKYEXPLORER_H
class MilkyExplorer : public Explorer {
private:
// Private constructor to prevent instantiation from outside the class
MilkyExplorer() {
// Add the genesis block
Block genesis("Genesis block", "");
milky_blocks.push_back(genesis);
}
// Private copy constructor and assignment operator to prevent copies of the class
MilkyExplorer(const MilkyExplorer&) = delete;
MilkyExplorer& operator=(const MilkyExplorer&) = delete;
public:
// Vector to hold the blocks in the blockchain
static vector<Block> milky_blocks;
// Static function to get a reference to the shared instance of the Blockchain class
static MilkyExplorer& getInstance() {
static MilkyExplorer instance;
return instance;
}
// Add a block to the blockchain
void addBlock(string data) {
Block block(data, milky_blocks.back().hash);
milky_blocks.push_back(block);
}
};
vector<Block> MilkyExplorer::milky_blocks = {};
#endif