using namespace std;
+extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH;
+
/**
* Return average network hashes per second based on the last 'lookup' blocks,
* or over the difficulty averaging window if 'lookup' is nonpositive.
throw runtime_error(
"getgenerate\n"
"\nReturn if the server is set to generate coins or not. The default is false.\n"
- "It is set with the command line argument -gen (or zcash.conf setting gen)\n"
+ "It is set with the command line argument -gen (or komodo.conf setting gen)\n"
"It can also be set with the setgenerate call.\n"
"\nResult\n"
"true|false (boolean) If the server is set to generate coins or not\n"
return GetBoolArg("-gen", false);
}
+extern uint8_t NOTARY_PUBKEY33[33];
+
+//Value generate(const Array& params, bool fHelp)
UniValue generate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 1)
UniValue blockHashes(UniValue::VARR);
unsigned int n = Params().EquihashN();
unsigned int k = Params().EquihashK();
+ uint64_t lastTime = 0;
while (nHeight < nHeightEnd)
{
+ // Validation may fail if block generation is too fast
+ if (GetTime() == lastTime) MilliSleep(1001);
+ lastTime = GetTime();
+
#ifdef ENABLE_WALLET
- unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
+ std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
#else
- unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey());
+ std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey());
#endif
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wallet keypool empty");
// (x_1, x_2, ...) = A(I, V, n, k)
std::function<bool(std::vector<unsigned char>)> validBlock =
- [&pblock](std::vector<unsigned char> soln) {
+ [&pblock](std::vector<unsigned char> soln)
+ {
+ LOCK(cs_main);
pblock->nSolution = soln;
solutionTargetChecks.increment();
- return CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus());
+ return CheckProofOfWork(*pblock,NOTARY_PUBKEY33,chainActive.Height(),Params().GetConsensus());
};
bool found = EhBasicSolveUncancellable(n, k, curr_state, validBlock);
ehSolverRuns.increment();
}
endloop:
CValidationState state;
- if (!ProcessNewBlock(state, NULL, pblock, true, NULL))
+ if (!ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL))
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
++nHeight;
blockHashes.push_back(pblock->GetHash().GetHex());
obj.push_back(Pair("difficulty", (double)GetNetworkDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
- obj.push_back(Pair("localsolps" , getlocalsolps(params, false)));
- obj.push_back(Pair("networksolps", getnetworksolps(params, false)));
+ if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH)
+ {
+ obj.push_back(Pair("localsolps" , getlocalsolps(params, false)));
+ obj.push_back(Pair("networksolps", getnetworksolps(params, false)));
+ }
+ else
+ {
+ obj.push_back(Pair("localhashps" , getlocalsolps(params, false)));
+ }
obj.push_back(Pair("networkhashps", getnetworksolps(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
if (vNodes.empty())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!");
- if (IsInitialBlockDownload())
- throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
+ //if (IsInitialBlockDownload())
+ // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
static unsigned int nTransactionsUpdatedLast;
if (tx.IsCoinBase()) {
// 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
- entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
- }
+ // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
+ //}
+ entry.push_back(Pair("coinbasevalue", 3*COIN));
entry.push_back(Pair("required", true));
txCoinbase = entry;
- } else {
+ } else
transactions.push_back(entry);
- }
}
UniValue aux(UniValue::VOBJ);
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
+ //fprintf(stderr,"return complete template\n");
return result;
}
CValidationState state;
submitblock_StateCatcher sc(block.GetHash());
RegisterValidationInterface(&sc);
- bool fAccepted = ProcessNewBlock(state, NULL, &block, true, NULL);
+ bool fAccepted = ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL);
UnregisterValidationInterface(&sc);
if (fBlockPresent)
{
"1. height (numeric, optional) The block height. If not provided, defaults to the current height of the chain.\n"
"\nResult:\n"
"{\n"
- " \"miner\" : x.xxx (numeric) The mining reward amount in ZEC.\n"
- " \"founders\" : x.xxx (numeric) The founders reward amount in ZEC.\n"
+ " \"miner\" : x.xxx (numeric) The mining reward amount in KMD.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblocksubsidy", "1000")
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus());
- CAmount nFoundersReward = 0;
- if ((nHeight > 0) && (nHeight <= Params().GetConsensus().GetLastFoundersRewardBlockHeight())) {
- nFoundersReward = nReward/5;
- nReward -= nFoundersReward;
- }
UniValue result(UniValue::VOBJ);
result.push_back(Pair("miner", ValueFromAmount(nReward)));
- result.push_back(Pair("founders", ValueFromAmount(nFoundersReward)));
+ //result.push_back(Pair("founders", ValueFromAmount(nFoundersReward)));
return result;
}