#include <boost/format.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/iterator/counting_iterator.hpp>
using namespace json_spirit;
using namespace std;
"getmininginfo\n"
"Returns an object containing mining-related information.");
- Object obj, diff, weight;
+ Object obj, diff;
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
{
if (fHelp || params.size() != 1)
throw runtime_error(
- "scaninput {\"txid\":txid, \"vout\":[vout1, vout2, ..., voutN], \"difficulty\":difficulty, \"days\":days}\n"
+ "scaninput '{\"txid\":\"txid\", \"vout\":[vout1, vout2, ..., voutN], \"difficulty\":difficulty, \"days\":days}'\n"
"Scan specified transaction or input for suitable kernel solutions.\n"
" difficulty - upper limit for difficulty, current difficulty by default;\n"
" days - time window, 90 days by default.\n"
uint32_t nBits = GetNextTargetRequired(pindexBest, true);
const Value& diff_v = find_value(scanParams, "difficulty");
- if (diff_v.type() == real_type)
+ if (diff_v.type() == real_type || diff_v.type() == int_type)
{
double dDiff = diff_v.get_real();
if (dDiff <= 0)
vInputs.push_back(nOut);
}
}
+ else if(inputs_v.type() == int_type)
+ {
+ int nOut = inputs_v.get_int();
+ if (nOut < 0 || nOut > (int)tx.vout.size() - 1)
+ {
+ stringstream strErrorMsg;
+ strErrorMsg << boost::format("Invalid parameter, input number %d is out of range") % nOut;
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strErrorMsg.str());
+ }
+
+ vInputs.push_back(nOut);
+ }
else
{
- vInputs = vector<int>(boost::counting_iterator<int>( 0 ), boost::counting_iterator<int>( tx.vout.size() ));
+ for (size_t i = 0; i != tx.vout.size(); ++i) vInputs.push_back(i);
}
CTxDB txdb("r");
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "NovaCoin is downloading blocks...");
- typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
+ typedef map<uint256, pair<shared_ptr<CBlock>, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock;
- static vector<CBlock*> vNewBlock;
+ static vector<std::shared_ptr<CBlock>> vNewBlock;
static CReserveKey reservekey(pwalletMain);
if (params.size() == 0)
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
static int64_t nStart;
- static CBlock* pblock;
+ static shared_ptr<CBlock> pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
{
{
// Deallocate old blocks since they're obsolete now
mapNewBlock.clear();
- BOOST_FOREACH(CBlock* pblock, vNewBlock)
- delete pblock;
vNewBlock.clear();
}
nTransactionsUpdatedLast = nTransactionsUpdated;
// Get saved block
if (!mapNewBlock.count(pdata->hashMerkleRoot))
return false;
- CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first;
+ std::shared_ptr<CBlock> pblock = mapNewBlock[pdata->hashMerkleRoot].first;
pblock->nTime = pdata->nTime;
pblock->nNonce = pdata->nNonce;
if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "NovaCoin is downloading blocks...");
- typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
+ typedef map<uint256, pair<shared_ptr<CBlock>, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
- static vector<CBlock*> vNewBlock;
+ static vector<shared_ptr<CBlock>> vNewBlock;
static CReserveKey reservekey(pwalletMain);
if (params.size() == 0)
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
static int64_t nStart;
- static CBlock* pblock;
+ static shared_ptr<CBlock> pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
{
{
// Deallocate old blocks since they're obsolete now
mapNewBlock.clear();
- BOOST_FOREACH(CBlock* pblock, vNewBlock)
- delete pblock;
vNewBlock.clear();
}
// Get saved block
if (!mapNewBlock.count(pdata->hashMerkleRoot))
return false;
- CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first;
+ std::shared_ptr<CBlock> pblock = mapNewBlock[pdata->hashMerkleRoot].first;
pblock->nTime = pdata->nTime;
pblock->nNonce = pdata->nNonce;
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
static int64_t nStart;
- static CBlock* pblock;
+ static std::shared_ptr<CBlock> pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))
{
// Create new block
if(pblock)
{
- delete pblock;
- pblock = NULL;
+ pblock.reset();
}
pblock = CreateNewBlock(pwalletMain);
if (!pblock)