mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-27 15:24:39 +00:00
WIP: fixed getblocktemplate.
This commit is contained in:
parent
ed57dabf1e
commit
5424d869fa
@ -952,12 +952,12 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
std::string kevaBlockData = HexStr(stream.begin(), stream.end());
|
||||
cryptonote::tx_extra_keva_block extra_keva_block;
|
||||
extra_keva_block.keva_block = kevaBlockData;
|
||||
if (cryptonote::append_keva_block_to_extra(cn_block.miner_tx.extra, extra_keva_block)) {
|
||||
if (!cryptonote::append_keva_block_to_extra(cn_block.miner_tx.extra, extra_keva_block)) {
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Internal error: failed to add block");
|
||||
}
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
const double difficulty = ConvertNBitsToDiff(pblock->nBits);
|
||||
const uint64_t difficulty = ConvertNBitsToDiff(pblock->nBits);
|
||||
result.push_back(Pair("blocktemplate_blob", pblock->hashPrevBlock.GetHex()));
|
||||
result.push_back(Pair("difficulty", (double)difficulty));
|
||||
result.push_back(Pair("height", (uint64_t)height));
|
||||
|
@ -962,7 +962,7 @@ int64_t GetStartupTime()
|
||||
return nStartupTime;
|
||||
}
|
||||
|
||||
double ConvertNBitsToDiff(uint32_t nBits)
|
||||
uint64_t ConvertNBitsToDiff(uint32_t nBits)
|
||||
{
|
||||
int nShift = (nBits >> 24) & 0xff;
|
||||
|
||||
@ -981,5 +981,5 @@ double ConvertNBitsToDiff(uint32_t nBits)
|
||||
nShift--;
|
||||
}
|
||||
|
||||
return dDiff;
|
||||
return (uint64_t)round(dDiff);
|
||||
}
|
@ -349,6 +349,6 @@ std::unique_ptr<T> MakeUnique(Args&&... args)
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
double ConvertNBitsToDiff(uint32_t nBits);
|
||||
uint64_t ConvertNBitsToDiff(uint32_t nBits);
|
||||
|
||||
#endif // BITCOIN_UTIL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user