File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -96,20 +96,12 @@ inline uint160 Hash160(const T1& in1)
9696}
9797
9898/* * A writer stream (for serialization) that computes a 256-bit hash. */
99- class CHashWriter
99+ class HashWriter
100100{
101101private:
102102 CSHA256 ctx;
103103
104- const int nType;
105- const int nVersion;
106104public:
107-
108- CHashWriter (int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
109-
110- int GetType () const { return nType; }
111- int GetVersion () const { return nVersion; }
112-
113105 void write (Span<const std::byte> src)
114106 {
115107 ctx.Write (UCharCast (src.data ()), src.size ());
@@ -144,6 +136,26 @@ class CHashWriter
144136 return ReadLE64 (result.begin ());
145137 }
146138
139+ template <typename T>
140+ HashWriter& operator <<(const T& obj)
141+ {
142+ ::Serialize (*this , obj);
143+ return *this ;
144+ }
145+ };
146+
147+ class CHashWriter : public HashWriter
148+ {
149+ private:
150+ const int nType;
151+ const int nVersion;
152+
153+ public:
154+ CHashWriter (int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
155+
156+ int GetType () const { return nType; }
157+ int GetVersion () const { return nVersion; }
158+
147159 template <typename T>
148160 CHashWriter& operator <<(const T& obj) {
149161 // Serialize to this stream
You can’t perform that action at this time.
0 commit comments