add disablecb option to getblocktemplate
This commit is contained in:
@@ -518,7 +518,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strMode = "template";
|
|
||||||
UniValue lpval = NullUniValue;
|
UniValue lpval = NullUniValue;
|
||||||
// TODO: Re-enable coinbasevalue once a specification has been written
|
// TODO: Re-enable coinbasevalue once a specification has been written
|
||||||
bool coinbasetxn = true;
|
bool coinbasetxn = true;
|
||||||
@@ -530,12 +529,15 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
strMode = modeval.get_str();
|
strMode = modeval.get_str();
|
||||||
else if (modeval.isNull())
|
else if (modeval.isNull())
|
||||||
{
|
{
|
||||||
/* Do nothing */
|
std::string strMode = "template";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||||
lpval = find_value(oparam, "longpollid");
|
lpval = find_value(oparam, "longpollid");
|
||||||
|
|
||||||
|
if (strMode == "disablecb")
|
||||||
|
coinbasetxn = false;
|
||||||
|
|
||||||
if (strMode == "proposal")
|
if (strMode == "proposal")
|
||||||
{
|
{
|
||||||
const UniValue& dataval = find_value(oparam, "data");
|
const UniValue& dataval = find_value(oparam, "data");
|
||||||
@@ -567,7 +569,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strMode != "template")
|
if (strMode != "template" || strMode != "disablecb")
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||||
|
|
||||||
if (vNodes.empty())
|
if (vNodes.empty())
|
||||||
@@ -694,17 +696,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
|
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
|
||||||
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template]));
|
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template]));
|
||||||
|
|
||||||
//if (tx.IsCoinBase()) {
|
if (tx.IsCoinBase() && coinbasetxn == true ) {
|
||||||
// Show founders' reward if it is required
|
// Show founders' reward if it is required
|
||||||
//if (pblock->vtx[0].vout.size() > 1) {
|
//if (pblock->vtx[0].vout.size() > 1) {
|
||||||
// Correct this if GetBlockTemplate changes the order
|
// Correct this if GetBlockTemplate changes the order
|
||||||
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
|
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
|
||||||
//}
|
//}
|
||||||
// CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus());
|
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus());
|
||||||
// entry.push_back(Pair("coinbasevalue", nReward));
|
entry.push_back(Pair("coinbasevalue", nReward));
|
||||||
// entry.push_back(Pair("required", true));
|
entry.push_back(Pair("required", true));
|
||||||
// txCoinbase = entry;
|
txCoinbase = entry;
|
||||||
// } else
|
} else
|
||||||
transactions.push_back(entry);
|
transactions.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,12 +728,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
result.push_back(Pair("version", pblock->nVersion));
|
result.push_back(Pair("version", pblock->nVersion));
|
||||||
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
|
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
|
||||||
result.push_back(Pair("transactions", transactions));
|
result.push_back(Pair("transactions", transactions));
|
||||||
//if (coinbasetxn) {
|
if (coinbasetxn) {
|
||||||
// assert(txCoinbase.isObject());
|
assert(txCoinbase.isObject());
|
||||||
// result.push_back(Pair("coinbasetxn", txCoinbase));
|
result.push_back(Pair("coinbasetxn", txCoinbase));
|
||||||
//} else {
|
} // else {
|
||||||
// result.push_back(Pair("coinbaseaux", aux));
|
// result.push_back(Pair("coinbaseaux", aux));
|
||||||
// result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
|
// result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
|
||||||
//}
|
//}
|
||||||
result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
|
result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
|
||||||
if ( ASSETCHAINS_STAKED != 0 )
|
if ( ASSETCHAINS_STAKED != 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user