-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblockexplorer.h
60 lines (46 loc) · 1.1 KB
/
blockexplorer.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
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef BLOCKEXPLORER
#define BLOCKEXPLORER
#include <string>
#include <createmeta.h>
#include <ldbwriter.h>
using namespace std;
namespace fantasybit_bx {
class BlockExplorer {
public:
BlockExplorer() : cm(ldb) {
prev = "";
}
CreateMeta cm;
std::string prev;
int height;
int start;
LdbWriter ldb;
int init(const std::string &startread) {
BlockMeta bm;
auto headid = ldb.read(startread);
ldb.read(headid,bm);
start = bm.blocknum();
prev = headid;
return start;
}
int init(int start) {
string sread = "blocknum_"+ to_string(start);
return init(sread);
}
int init() {
return init("blockhead");
}
void pblock(const fantasybit_bx::Block &b) {
prev = cm.DoMeta(b,prev);
ldb.write("blocknum_" + to_string(b.signedhead().head().num()),prev);
}
void endit() {
if ( prev != "")
ldb.write("blockhead",prev);
}
uint64_t SkillBalance(const std::string &fname) {
return cm.getSkillBalance(fname);
}
};
}
#endif // BLOCKEXPLORER