Skip to content

Commit

Permalink
Add num_digests_appended() method, not used but pretty cool doc on …
Browse files Browse the repository at this point in the history
…what `mask` means.
  • Loading branch information
greg7mdp committed Mar 29, 2024
1 parent 264dffe commit 0663a3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/chain/include/eosio/chain/incremental_merkle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class incremental_merkle_tree {
return {};
assert(!trees.empty());
return _get_root(0);
};
}

uint64_t num_digests_appended() const {
return mask;
}

private:
friend struct fc::reflector<incremental_merkle_tree>;
Expand Down
4 changes: 3 additions & 1 deletion unittests/merkle_tree_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ BOOST_AUTO_TEST_CASE(consistency_over_large_range) {
std::vector<digest_type> digests = create_test_digests(num_digests);
for (size_t i=1; i<num_digests; ++i) {
incremental_merkle_tree tree;
for (size_t j=0; j<i; ++j)
for (size_t j=0; j<i; ++j) {
BOOST_CHECK_EQUAL(tree.num_digests_appended(), j);
tree.append(digests[j]);
}
BOOST_CHECK_EQUAL(calculate_merkle({digests.begin(), digests.begin() + i}), tree.get_root());
}
}
Expand Down

0 comments on commit 0663a3d

Please sign in to comment.