Wildmeshing Toolkit
merkle_tree.cpp
Go to the documentation of this file.
1
2
#include "
merkle_tree.hpp
"
3
#include "
Hashable.hpp
"
4
#include "
MerkleTreeInteriorNode.hpp
"
5
namespace
wmtk::utils
{
6
nlohmann::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
Hashable.hpp
MerkleTreeInteriorNode.hpp
wmtk::hash
Definition:
hash.hpp:14
wmtk::utils::Hashable
Definition:
Hashable.hpp:8
wmtk::utils::Hashable::child_hashes
virtual std::map< std::string, size_t > child_hashes() const
Definition:
Hashable.cpp:32
wmtk::utils::MerkleTreeInteriorNode
Definition:
MerkleTreeInteriorNode.hpp:7
merkle_tree.hpp
wmtk::utils
Definition:
Tuple.hpp:22
wmtk::utils::merkle_tree
nlohmann::json merkle_tree(const Hashable &hashable)
Definition:
merkle_tree.cpp:6
json
nlohmann::json json
Definition:
input.cpp:9
src
wmtk
utils
merkle_tree.cpp
Generated by
1.9.1