Abstract uncommitted and depth personalization for IncrementalMerkleTree.

This commit is contained in:
Sean Bowe
2018-04-12 17:10:04 -06:00
parent 265eca3f47
commit a7cbb8475f
2 changed files with 22 additions and 10 deletions

View File

@@ -57,9 +57,9 @@ template<size_t Depth, typename Hash>
class EmptyMerkleRoots {
public:
EmptyMerkleRoots() {
empty_roots.at(0) = Hash();
empty_roots.at(0) = Hash::uncommitted();
for (size_t d = 1; d <= Depth; d++) {
empty_roots.at(d) = Hash::combine(empty_roots.at(d-1), empty_roots.at(d-1));
empty_roots.at(d) = Hash::combine(empty_roots.at(d-1), empty_roots.at(d-1), d-1);
}
}
Hash empty_root(size_t depth) {
@@ -213,7 +213,15 @@ public:
SHA256Compress() : uint256() {}
SHA256Compress(uint256 contents) : uint256(contents) { }
static SHA256Compress combine(const SHA256Compress& a, const SHA256Compress& b);
static SHA256Compress combine(
const SHA256Compress& a,
const SHA256Compress& b,
size_t depth
);
static SHA256Compress uncommitted() {
return SHA256Compress();
}
};
template<size_t Depth, typename Hash>