getblock template with mode:disablecb this allows a pool to use the

daemons coinbase tx rather than build its own.
This commit is contained in:
blackjok3r
2018-11-13 23:28:36 +08:00
parent 4632956f4a
commit 29d67993c8

View File

@@ -518,10 +518,10 @@ 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;
std::string strMode;
if (params.size() > 0) if (params.size() > 0)
{ {
const UniValue& oparam = params[0].get_obj(); const UniValue& oparam = params[0].get_obj();
@@ -530,12 +530,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 */ 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,9 +570,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
} }
} }
if (strMode != "template")
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
if (vNodes.empty()) if (vNodes.empty())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!");
@@ -673,8 +673,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
uint256 txHash = tx.GetHash(); uint256 txHash = tx.GetHash();
setTxIndex[txHash] = i++; setTxIndex[txHash] = i++;
if (tx.IsCoinBase() && !coinbasetxn) //if (tx.IsCoinBase() && !coinbasetxn)
continue; // continue;
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
@@ -694,7 +694,7 @@ 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
@@ -729,10 +729,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
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 )
{ {
@@ -756,6 +756,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
return result; return result;
} }
class submitblock_StateCatcher : public CValidationInterface class submitblock_StateCatcher : public CValidationInterface
{ {
public: public: