From 7b0611119f606824a7b9c409a40e46be2833ebb0 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 16 Jun 2015 12:52:10 +1000 Subject: [PATCH] Support testnet diffs --- src/libckpool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libckpool.c b/src/libckpool.c index cb91331a..f1b5c323 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -1967,7 +1967,10 @@ double diff_from_nbits(char *nbits) pow = nbits[0]; powdiff = (8 * (0x1d - 3)) - (8 * (pow - 3)); diff32 = be32toh(*((uint32_t *)nbits)) & 0x00FFFFFF; - numerator = 0xFFFFULL << powdiff; + if (likely(powdiff > 0)) + numerator = 0xFFFFULL << powdiff; + else + numerator = 0xFFFFULL >> -powdiff; return numerator / (double)diff32; }