Merge mining RPC: added merge_mining_get_job

This commit is contained in:
SChernykh
2023-11-05 17:59:32 +01:00
parent 75bb046f22
commit 40b2c2a858
4 changed files with 163 additions and 20 deletions

View File

@@ -99,6 +99,25 @@ static FORCEINLINE bool from_hex(char c, T& out_value) {
return false;
}
static FORCEINLINE bool from_hex(const char* s, size_t len, hash& h) {
if (len != HASH_SIZE * 2) {
return false;
}
hash result;
for (uint32_t i = 0; i < HASH_SIZE; ++i) {
uint8_t d[2];
if (!from_hex(s[i * 2], d[0]) || !from_hex(s[i * 2 + 1], d[1])) {
return false;
}
result.h[i] = (d[0] << 4) | d[1];
}
h = result;
return true;
}
template<typename T, bool is_signed> struct is_negative_helper {};
template<typename T> struct is_negative_helper<T, false> { static FORCEINLINE bool value(T) { return false; } };
template<typename T> struct is_negative_helper<T, true> { static FORCEINLINE bool value(T x) { return (x < 0); } };