File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ inline uint160 Hash160(const T1& in1)
98
98
class CHashWriter
99
99
{
100
100
private:
101
- CHash256 ctx;
101
+ CSHA256 ctx;
102
102
103
103
const int nType;
104
104
const int nVersion;
@@ -110,23 +110,36 @@ class CHashWriter
110
110
int GetVersion () const { return nVersion; }
111
111
112
112
void write (const char *pch, size_t size) {
113
- ctx.Write ({ (const unsigned char *)pch, size} );
113
+ ctx.Write ((const unsigned char *)pch, size);
114
114
}
115
115
116
- // invalidates the object
116
+ /* * Compute the double-SHA256 hash of all data written to this object.
117
+ *
118
+ * Invalidates this object.
119
+ */
117
120
uint256 GetHash () {
118
121
uint256 result;
119
- ctx.Finalize (result);
122
+ ctx.Finalize (result.begin ());
123
+ ctx.Reset ().Write (result.begin (), CSHA256::OUTPUT_SIZE).Finalize (result.begin ());
124
+ return result;
125
+ }
126
+
127
+ /* * Compute the SHA256 hash of all data written to this object.
128
+ *
129
+ * Invalidates this object.
130
+ */
131
+ uint256 GetSHA256 () {
132
+ uint256 result;
133
+ ctx.Finalize (result.begin ());
120
134
return result;
121
135
}
122
136
123
137
/* *
124
138
* Returns the first 64 bits from the resulting hash.
125
139
*/
126
140
inline uint64_t GetCheapHash () {
127
- unsigned char result[CHash256::OUTPUT_SIZE];
128
- ctx.Finalize (result);
129
- return ReadLE64 (result);
141
+ uint256 result = GetHash ();
142
+ return ReadLE64 (result.begin ());
130
143
}
131
144
132
145
template <typename T>
You can’t perform that action at this time.
0 commit comments