Skip to content

Commit

Permalink
Fix compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Nov 21, 2023
1 parent d335759 commit f3c1f98
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
57 changes: 29 additions & 28 deletions src/groestlcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,42 @@ class GroestlHasher {
GroestlHasher& operator=(GroestlHasher&& x);
};

class CGroestlHashWriter
/** A writer stream (for serialization) that computes a 256-bit hash. */
class GroestlHashWriter
{
private:
GroestlHasher ctx;
const int nVersion;
public:
CGroestlHashWriter(int nVersionIn) : nVersion{nVersionIn} {}

int GetVersion() const { return nVersion; }

void write(Span<const std::byte> src)
{
ctx.Write(UCharCast(src.data()), src.size());
}
GroestlHasher ctx;

// invalidates the object
uint256 GetHash() {
uint256 result;
ctx.Finalize(result);
return result;
}
public:
void write(Span<const std::byte> src)
{
ctx.Write(UCharCast(src.data()), src.size());
}

/**
* Returns the first 64 bits from the resulting hash.
/** Compute the hash of all data written to this object.
*
* Invalidates this object.
*/
inline uint64_t GetCheapHash() {
uint256 result = GetHash();
return ReadLE64(result.begin());
uint256 GetHash() {
uint256 result;
ctx.Finalize(result);
return result;
}

template<typename T>
CGroestlHashWriter& operator<<(const T& obj) {
::Serialize(*this, obj);
return (*this);
}
/**
* Returns the first 64 bits from the resulting hash.
*/
inline uint64_t GetCheapHash() {
uint256 result = GetHash();
return ReadLE64(result.begin());
}

template <typename T>
GroestlHashWriter& operator<<(const T& obj)
{
::Serialize(*this, obj);
return *this;
}
};


Expand Down
2 changes: 1 addition & 1 deletion src/primitives/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

uint256 CBlockHeader::GetHash() const
{
return (XCoin::CGroestlHashWriter{PROTOCOL_VERSION} << *this).GetHash(); // GRS
return (XCoin::GroestlHashWriter{} << *this).GetHash(); // GRS
}

std::string CBlock::ToString() const
Expand Down

0 comments on commit f3c1f98

Please sign in to comment.