| 190 | /** Writes data to an underlying source stream, while hashing the written data. */ |
| 191 | template <typename Source> |
| 192 | class HashedSourceWriter : public HashWriter |
| 193 | { |
| 194 | private: |
| 195 | Source& m_source; |
| 196 | |
| 197 | public: |
| 198 | explicit HashedSourceWriter(Source& source LIFETIMEBOUND) : HashWriter{}, m_source{source} {} |
| 199 | |
| 200 | void write(std::span<const std::byte> src) |
| 201 | { |
| 202 | m_source.write(src); |
| 203 | HashWriter::write(src); |
| 204 | } |
| 205 | |
| 206 | template <typename T> |
| 207 | HashedSourceWriter& operator<<(const T& obj) |
| 208 | { |
| 209 | ::Serialize(*this, obj); |
| 210 | return *this; |
| 211 | } |
| 212 | }; |
| 213 | |
| 214 | /** Single-SHA256 a 32-byte input (represented as uint256). */ |
| 215 | [[nodiscard]] uint256 SHA256Uint256(const uint256& input); |
nothing calls this directly
no test coverage detected