Browse Source

Small nit fixes

pull/145/head
Sean Bowe 8 years ago
parent
commit
6f1b70300d
  1. 11
      src/zcash/IncrementalMerkleTree.cpp
  2. 8
      src/zcash/IncrementalMerkleTree.hpp

11
src/zcash/IncrementalMerkleTree.cpp

@ -53,12 +53,7 @@ void IncrementalMerkleTree<Depth, Hash>::wfcheck() const {
}
// The last parent cannot be null.
bool wasnull = false;
BOOST_FOREACH(const boost::optional<Hash>& parent, parents) {
wasnull = !parent;
}
if (wasnull) {
if (!(parents.empty()) && !(parents.back())) {
throw std::ios_base::failure("tree has non-canonical representation of parent");
}
@ -89,7 +84,7 @@ void IncrementalMerkleTree<Depth, Hash>::append(Hash obj) {
// Combine the leaves and propagate it up the tree
boost::optional<Hash> combined = Hash::combine(*left, *right);
// Set the left leaf to the object and make the right object none
// Set the "left" leaf to the object and make the "right" leaf none
left = obj;
right = boost::none;
@ -261,7 +256,7 @@ MerklePath IncrementalMerkleTree<Depth, Hash>::path(std::deque<Hash> filler_hash
}
template<size_t Depth, typename Hash>
std::deque<Hash> IncrementalWitness<Depth, Hash>::uncle_train() const {
std::deque<Hash> IncrementalWitness<Depth, Hash>::partial_path() const {
std::deque<Hash> uncles(filled.begin(), filled.end());
if (cursor) {

8
src/zcash/IncrementalMerkleTree.hpp

@ -68,6 +68,8 @@ public:
private:
boost::optional<Hash> left;
boost::optional<Hash> right;
// Collapsed "left" subtrees ordered toward the root of the tree.
std::vector<boost::optional<Hash>> parents;
MerklePath path(std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
Hash root(size_t depth, std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
@ -82,11 +84,11 @@ friend class IncrementalMerkleTree<Depth, Hash>;
public:
MerklePath path() const {
return tree.path(uncle_train());
return tree.path(partial_path());
}
Hash root() const {
return tree.root(Depth, uncle_train());
return tree.root(Depth, partial_path());
}
void append(Hash obj);
@ -107,7 +109,7 @@ private:
std::vector<Hash> filled;
boost::optional<IncrementalMerkleTree<Depth, Hash>> cursor;
size_t cursor_depth;
std::deque<Hash> uncle_train() const;
std::deque<Hash> partial_path() const;
IncrementalWitness(IncrementalMerkleTree<Depth, Hash> tree) : tree(tree) {}
};

Loading…
Cancel
Save