Skip to content

Commit

Permalink
[Refactor] Remove arith_uint256::GetCheapHash() and fix uint256 implem.
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed May 5, 2021
1 parent fa08530 commit 7bbbae3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,11 @@ class base_uint
s.read((char*)pn, sizeof(pn));
}

// Temporary for migration to blob160/256
uint64_t GetCheapHash() const
{
return GetLow64();
}
void SetNull()
{
memset(pn, 0, sizeof(pn));
}

bool IsNull() const
{
for (int i = 0; i < WIDTH; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/coincontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CCoinControl

struct SimpleOutpointHash {
size_t operator() (const OutPointWrapper& obj) const {
return (UintToArith256(obj.outPoint.hash) + obj.outPoint.n).GetCheapHash();
return (UintToArith256(obj.outPoint.hash) + obj.outPoint.n).GetLow64();
}
};

Expand Down
9 changes: 3 additions & 6 deletions src/uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#ifndef PIVX_UINT256_H
#define PIVX_UINT256_H

#include "crypto/common.h"

#include <assert.h>
#include <cstring>
#include <stdexcept>
Expand Down Expand Up @@ -143,12 +145,7 @@ class uint256 : public base_blob<256> {
* provide values to trigger worst-case behavior.
* @note The result of this function is not stable between little and big endian.
*/
uint64_t GetCheapHash() const
{
uint64_t result;
memcpy((void*)&result, (void*)m_data, 8);
return result;
}
uint64_t GetCheapHash() const { return ReadLE64(begin()); }

};

Expand Down

0 comments on commit 7bbbae3

Please sign in to comment.