/Users/brunogarcia/projects/bitcoin-core-dev/src/util/hash_type.h
Line | Count | Source |
1 | | // Copyright (c) 2020-2021 The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_UTIL_HASH_TYPE_H |
6 | | #define BITCOIN_UTIL_HASH_TYPE_H |
7 | | |
8 | | template <typename HashType> |
9 | | class BaseHash |
10 | | { |
11 | | protected: |
12 | | HashType m_hash; |
13 | | |
14 | | public: |
15 | 0 | BaseHash() : m_hash() {}Unexecuted instantiation: BaseHash<uint160>::BaseHash() Unexecuted instantiation: BaseHash<uint256>::BaseHash() |
16 | 0 | explicit BaseHash(const HashType& in) : m_hash(in) {}Unexecuted instantiation: BaseHash<uint160>::BaseHash(uint160 const&) Unexecuted instantiation: BaseHash<uint256>::BaseHash(uint256 const&) |
17 | | |
18 | | unsigned char* begin() |
19 | 0 | { |
20 | 0 | return m_hash.begin(); |
21 | 0 | } Unexecuted instantiation: BaseHash<uint256>::begin() Unexecuted instantiation: BaseHash<uint160>::begin() |
22 | | |
23 | | const unsigned char* begin() const |
24 | 0 | { |
25 | 0 | return m_hash.begin(); |
26 | 0 | } Unexecuted instantiation: BaseHash<uint160>::begin() const Unexecuted instantiation: BaseHash<uint256>::begin() const |
27 | | |
28 | | unsigned char* end() |
29 | 0 | { |
30 | 0 | return m_hash.end(); |
31 | 0 | } |
32 | | |
33 | | const unsigned char* end() const |
34 | 0 | { |
35 | 0 | return m_hash.end(); |
36 | 0 | } Unexecuted instantiation: BaseHash<uint160>::end() const Unexecuted instantiation: BaseHash<uint256>::end() const |
37 | | |
38 | | operator std::vector<unsigned char>() const |
39 | | { |
40 | | return std::vector<unsigned char>{m_hash.begin(), m_hash.end()}; |
41 | | } |
42 | | |
43 | | std::string ToString() const |
44 | 0 | { |
45 | 0 | return m_hash.ToString(); |
46 | 0 | } |
47 | | |
48 | | bool operator==(const BaseHash<HashType>& other) const noexcept |
49 | 0 | { |
50 | 0 | return m_hash == other.m_hash; |
51 | 0 | } Unexecuted instantiation: BaseHash<uint256>::operator==(BaseHash<uint256> const&) const Unexecuted instantiation: BaseHash<uint160>::operator==(BaseHash<uint160> const&) const |
52 | | |
53 | | bool operator!=(const BaseHash<HashType>& other) const noexcept |
54 | 0 | { |
55 | 0 | return !(m_hash == other.m_hash); |
56 | 0 | } |
57 | | |
58 | | bool operator<(const BaseHash<HashType>& other) const noexcept |
59 | 0 | { |
60 | 0 | return m_hash < other.m_hash; |
61 | 0 | } Unexecuted instantiation: BaseHash<uint160>::operator<(BaseHash<uint160> const&) const Unexecuted instantiation: BaseHash<uint256>::operator<(BaseHash<uint256> const&) const |
62 | | |
63 | | size_t size() const |
64 | 0 | { |
65 | 0 | return m_hash.size(); |
66 | 0 | } Unexecuted instantiation: BaseHash<uint256>::size() const Unexecuted instantiation: BaseHash<uint160>::size() const |
67 | | |
68 | 0 | unsigned char* data() { return m_hash.data(); } |
69 | 0 | const unsigned char* data() const { return m_hash.data(); }Unexecuted instantiation: BaseHash<uint160>::data() const Unexecuted instantiation: BaseHash<uint256>::data() const |
70 | | }; |
71 | | |
72 | | #endif // BITCOIN_UTIL_HASH_TYPE_H |