added claimtrie field back to getblocktemplate
I also included a test to ensure that we don't forget it next time
This commit is contained in:
parent
d3f29be779
commit
5cf649e90c
2 changed files with 16 additions and 6 deletions
|
@ -342,13 +342,14 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||
" \"value\" (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'\n"
|
||||
" ,...\n"
|
||||
" ],\n"
|
||||
" \"noncerange\" : \"00000000ffffffff\",(string) A range of valid nonces\n"
|
||||
" \"noncerange\" : \"00000000ffffffff\", (string) A range of valid nonces\n"
|
||||
" \"sigoplimit\" : n, (numeric) limit of sigops in blocks\n"
|
||||
" \"sizelimit\" : n, (numeric) limit of block size\n"
|
||||
" \"weightlimit\" : n, (numeric) limit of block weight\n"
|
||||
" \"curtime\" : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
|
||||
" \"bits\" : \"xxxxxxxx\", (string) compressed target of next block\n"
|
||||
" \"height\" : n (numeric) The height of the next block\n"
|
||||
" \"claimtrie\" : \"00000000ffffffff\", (string) The root hash of the claim trie in hex\n"
|
||||
"}\n"
|
||||
},
|
||||
RPCExamples{
|
||||
|
@ -424,15 +425,17 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||
if (strMode != "template")
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
if (Params().NetworkIDString() != "lbrycrdreg") // who should own this constant?
|
||||
{
|
||||
if (!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
|
||||
if (g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
|
||||
if (g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
|
||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!");
|
||||
|
||||
if (::ChainstateActive().IsInitialBlockDownload())
|
||||
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, PACKAGE_NAME " is in initial sync and waiting for blocks...");
|
||||
|
||||
}
|
||||
static unsigned int nTransactionsUpdatedLast;
|
||||
|
||||
if (!lpval.isNull())
|
||||
|
@ -639,6 +642,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||
result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
|
||||
result.pushKV("mutable", aMutable);
|
||||
result.pushKV("noncerange", "00000000ffffffff");
|
||||
|
||||
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
|
||||
int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
|
||||
if (fPreSegWit) {
|
||||
|
@ -654,7 +658,8 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||
}
|
||||
result.pushKV("curtime", pblock->GetBlockTime());
|
||||
result.pushKV("bits", strprintf("%08x", pblock->nBits));
|
||||
result.pushKV("height", (int64_t)(pindexPrev->nHeight+1));
|
||||
result.pushKV("height", (int64_t)(pindexPrev->nHeight)+1);
|
||||
result.pushKV("claimtrie", pblock->hashClaimTrie.GetHex());
|
||||
|
||||
if (!pblocktemplate->vchCoinbaseCommitment.empty()) {
|
||||
result.pushKV("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end()));
|
||||
|
|
|
@ -3947,9 +3947,13 @@ BOOST_AUTO_TEST_CASE(claim_rpcs_rollback3_test)
|
|||
|
||||
rpcfn_type getclaimsforname = tableRPC["getclaimsforname"]->actor;
|
||||
rpcfn_type getvalueforname = tableRPC["getvalueforname"]->actor;
|
||||
rpcfn_type getblocktemplate = tableRPC["getblocktemplate"]->actor;
|
||||
|
||||
JSONRPCRequest req;
|
||||
req.params = UniValue(UniValue::VARR);
|
||||
UniValue templateResults = getblocktemplate(req);
|
||||
BOOST_CHECK_EQUAL(templateResults["claimtrie"].get_str(), chainActive.Tip()->hashClaimTrie.GetHex());
|
||||
|
||||
req.params.push_back(UniValue(sName1));
|
||||
req.params.push_back(blockHash.GetHex());
|
||||
|
||||
|
@ -3959,6 +3963,7 @@ BOOST_AUTO_TEST_CASE(claim_rpcs_rollback3_test)
|
|||
UniValue valueResults = getvalueforname(req);
|
||||
BOOST_CHECK_EQUAL(valueResults["value"].get_str(), HexStr(sValue1));
|
||||
BOOST_CHECK_EQUAL(valueResults["amount"].get_int(), 3);
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in a new issue