File tree 1 file changed +21
-9
lines changed
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)
96
96
}
97
97
98
98
/* * A writer stream (for serialization) that computes a 256-bit hash. */
99
- class CHashWriter
99
+ class HashWriter
100
100
{
101
101
private:
102
102
CSHA256 ctx;
103
103
104
- const int nType;
105
- const int nVersion;
106
104
public:
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
-
113
105
void write (Span<const std::byte> src)
114
106
{
115
107
ctx.Write (UCharCast (src.data ()), src.size ());
@@ -144,6 +136,26 @@ class CHashWriter
144
136
return ReadLE64 (result.begin ());
145
137
}
146
138
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
+
147
159
template <typename T>
148
160
CHashWriter& operator <<(const T& obj) {
149
161
// Serialize to this stream
You can’t perform that action at this time.
0 commit comments