This repository was archived by the owner on Mar 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathforest.h
More file actions
51 lines (41 loc) · 1.37 KB
/
Copy pathforest.h
File metadata and controls
51 lines (41 loc) · 1.37 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
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef UTREEXO_FOREST_H
#define UTREEXO_FOREST_H
#include <uint256.h>
#include <string>
#include <unordered_map>
#include <vector>
class undoBlock;
class BlockProof;
struct LeafTXO;
struct Proof;
class Forest
{
public:
void Add(const std::vector<LeafTXO> adds);
void Remove(const std::vector<uint64_t>& dels);
undoBlock Modify(const std::vector<LeafTXO>& adds, const std::vector<uint64_t> dels);
Proof Prove(const uint256& wanted) const;
std::vector<Proof> ProveMany(const std::vector<uint256>& wanted) const;
bool Verify(const Proof& p) const;
bool VerifyMany(const std::vector<Proof>& p) const;
BlockProof ProveBlock(const std::vector<uint256>& hs) const;
bool VerifyBlockProof(const BlockProof& bp) const;
void Undo(const undoBlock& ub) const;
void PosMapSanity() const;
std::string Stats() const;
std::string ToString() const;
std::vector<uint256> GetTops() const;
undoBlock BuildUndoData(uint64_t numadds, const std::vector<uint64_t>& dels) const;
uint64_t HistoricHashes;
private:
void reMap(uint8_t destHeight);
void reHash(const std::vector<uint64_t>& dirt);
void cleanup();
void sanity() const;
uint64_t numLeaves;
uint8_t height;
std::vector<uint256> forest;
std::unordered_map<uint64_t, uint256> positionMap;
std::unordered_map<uint64_t, bool> dirtyMap;
};
#endif // UTREEXO_FOREST_H