| 191 | /** Writes data to an underlying source stream, while hashing the written data. */ |
| 192 | template <typename Source> |
| 193 | class HashedSourceWriter : public CHashWriter |
| 194 | { |
| 195 | private: |
| 196 | Source& m_source; |
| 197 | |
| 198 | public: |
| 199 | explicit HashedSourceWriter(Source& source LIFETIMEBOUND) : CHashWriter{source.GetType(), source.GetVersion()}, m_source{source} {} |
| 200 | |
| 201 | void write(Span<const std::byte> src) |
| 202 | { |
| 203 | m_source.write(src); |
| 204 | CHashWriter::write(src); |
| 205 | } |
| 206 | |
| 207 | template <typename T> |
| 208 | HashedSourceWriter& operator<<(const T& obj) |
| 209 | { |
| 210 | ::Serialize(*this, obj); |
| 211 | return *this; |
| 212 | } |
| 213 | }; |
| 214 | |
| 215 | /** Compute the 256-bit hash of an object's serialization, with optional sighash byte. */ |
| 216 | template<typename T> |
nothing calls this directly
no test coverage detected