TLA Line data Source code
1 : // evmone: Fast Ethereum Virtual Machine implementation
2 : // Copyright 2022 The evmone Authors.
3 : // SPDX-License-Identifier: Apache-2.0
4 : #pragma once
5 :
6 : #include "hash_utils.hpp"
7 : #include <span>
8 : #include <unordered_map>
9 :
10 : namespace evmone::state
11 : {
12 : struct Account;
13 :
14 : /// Computes Merkle Patricia Trie root hash for the given collection of state accounts.
15 : hash256 mpt_hash(const std::unordered_map<address, Account>& accounts);
16 :
17 : /// Computes Merkle Patricia Trie root hash for the given list of structures.
18 : template <typename T>
19 : hash256 mpt_hash(std::span<const T> list);
20 :
21 : /// A helper to automatically convert collections (e.g. vector, array) to span.
22 : template <typename T>
23 CBC 159 : inline hash256 mpt_hash(const T& list)
24 : requires std::is_convertible_v<T, std::span<const typename T::value_type>>
25 : {
26 159 : return mpt_hash(std::span<const typename T::value_type>{list});
27 : }
28 :
29 : } // namespace evmone::state
|