Changeset View
Changeset View
Standalone View
Standalone View
src/uint256.h
Show All 32 Lines | bool IsNull() const { | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void SetNull() { memset(data, 0, sizeof(data)); } | void SetNull() { memset(data, 0, sizeof(data)); } | ||||
inline int Compare(const base_blob &other) const { | inline int Compare(const base_blob &other) const { | ||||
// This doesn't quite work as you'd expect because the comparison use | for (size_t i = 0; i < sizeof(data); i++) { | ||||
// the wrong endianess. | uint8_t a = data[sizeof(data) - 1 - i]; | ||||
return memcmp(data, other.data, sizeof(data)); | uint8_t b = other.data[sizeof(data) - 1 - i]; | ||||
if (a > b) { | |||||
return 1; | |||||
} | |||||
if (a < b) { | |||||
return -1; | |||||
} | |||||
} | |||||
return 0; | |||||
} | } | ||||
friend inline bool operator==(const base_blob &a, const base_blob &b) { | friend inline bool operator==(const base_blob &a, const base_blob &b) { | ||||
return a.Compare(b) == 0; | return a.Compare(b) == 0; | ||||
} | } | ||||
friend inline bool operator!=(const base_blob &a, const base_blob &b) { | friend inline bool operator!=(const base_blob &a, const base_blob &b) { | ||||
return a.Compare(b) != 0; | return a.Compare(b) != 0; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |