Wildmeshing Toolkit
Loading...
Searching...
No Matches
merkle_tree.cpp
Go to the documentation of this file.
1
2#include "merkle_tree.hpp"
3#include "Hashable.hpp"
5namespace wmtk::utils {
6nlohmann::json merkle_tree(const Hashable& hashable)
7{
8 nlohmann::json js;
9 for (const auto& [name, hash] : hashable.child_hashes()) {
10 js[name] = hash;
11 }
12
13 if (auto merkle_ptr = dynamic_cast<const MerkleTreeInteriorNode*>(&hashable);
14 merkle_ptr != nullptr) {
15 for (const auto& [name, hashable_ptr] : merkle_ptr->child_hashables()) {
16 js[name] = merkle_tree(*hashable_ptr);
17 }
18 }
19 return js;
20}
21} // namespace wmtk::utils
virtual std::map< std::string, size_t > child_hashes() const
Definition Hashable.cpp:32
nlohmann::json merkle_tree(const Hashable &hashable)