#include "main.h"
#include "db.h"
+#include "txdb.h"
#include "init.h"
+#include "miner.h"
#include "bitcoinrpc.h"
using namespace json_spirit;
using namespace std;
-Value getgenerate(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() != 0)
- throw runtime_error(
- "getgenerate\n"
- "Returns true or false.");
-
- return GetBoolArg("-gen");
-}
-
-
-Value setgenerate(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() < 1 || params.size() > 2)
- throw runtime_error(
- "setgenerate <generate> [genproclimit]\n"
- "<generate> is true or false to turn generation on or off.\n"
- "Generation is limited to [genproclimit] processors, -1 is unlimited.");
-
- bool fGenerate = true;
- if (params.size() > 0)
- fGenerate = params[0].get_bool();
-
- if (params.size() > 1)
- {
- int nGenProcLimit = params[1].get_int();
- mapArgs["-genproclimit"] = itostr(nGenProcLimit);
- if (nGenProcLimit == 0)
- fGenerate = false;
- }
- mapArgs["-gen"] = (fGenerate ? "1" : "0");
-
- GenerateBitcoins(fGenerate, pwalletMain);
- return Value::null;
-}
-
-
-Value gethashespersec(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() != 0)
- throw runtime_error(
- "gethashespersec\n"
- "Returns a recent hashes per second performance measurement while generating.");
-
- if (GetTimeMillis() - nHPSTimerStart > 8000)
- return (boost::int64_t)0;
- return (boost::int64_t)dHashesPerSec;
-}
-
-
Value getmininginfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
"getmininginfo\n"
"Returns an object containing mining-related information.");
+ uint64 nMinWeight = 0, nMaxWeight = 0, nWeight = 0;
+ pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight);
+
Object obj;
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
+ obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits)));
+ obj.push_back(Pair("netmhashps", GetPoWMHashPS()));
+ obj.push_back(Pair("netstakeweight", GetPoSKernelPS()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
- obj.push_back(Pair("generate", GetBoolArg("-gen")));
- obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
- obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
+
+ obj.push_back(Pair("stakeweight", (uint64_t)nWeight));
+ obj.push_back(Pair("minweight", (uint64_t)nMinWeight));
+ obj.push_back(Pair("maxweight", (uint64_t)nMaxWeight));
+
+ obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetLastBlockIndex(pindexBest, true)->nTime, true)));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
- if (!pblock->SignBlock(*pwalletMain))
- throw JSONRPCError(-100, "Unable to sign block, wallet locked?");
-
return CheckWork(pblock, *pwalletMain, reservekey);
}
}
pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second;
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
- if (!pblock->SignBlock(*pwalletMain))
- throw JSONRPCError(-100, "Unable to sign block, wallet locked?");
-
return CheckWork(pblock, *pwalletMain, reservekey);
}
}
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
}
- if (!block.SignBlock(*pwalletMain))
- throw JSONRPCError(-100, "Unable to sign block, wallet locked?");
-
bool fAccepted = ProcessBlock(NULL, &block);
if (!fAccepted)
return "rejected";