MCPcopy Create free account
hub / github.com/ElementsProject/elements / HashedSourceWriter

Class HashedSourceWriter

src/hash.h:193–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191/** Writes data to an underlying source stream, while hashing the written data. */
192template <typename Source>
193class HashedSourceWriter : public CHashWriter
194{
195private:
196 Source& m_source;
197
198public:
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. */
216template<typename T>

Callers

nothing calls this directly

Calls 1

SerializeFunction · 0.70

Tested by

no test coverage detected