|
|
@ -104,7 +104,6 @@ Value getwork(const Array& params, bool fHelp) |
|
|
|
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; |
|
|
|
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; |
|
|
|
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
|
|
|
|
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
|
|
|
|
static vector<CBlockTemplate*> vNewBlockTemplate; |
|
|
|
static vector<CBlockTemplate*> vNewBlockTemplate; |
|
|
|
static CReserveKey reservekey(pwalletMain); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (params.size() == 0) |
|
|
|
if (params.size() == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -134,7 +133,7 @@ Value getwork(const Array& params, bool fHelp) |
|
|
|
nStart = GetTime(); |
|
|
|
nStart = GetTime(); |
|
|
|
|
|
|
|
|
|
|
|
// Create new block
|
|
|
|
// Create new block
|
|
|
|
pblocktemplate = CreateNewBlock(reservekey); |
|
|
|
pblocktemplate = CreateNewBlock(*pMiningKey); |
|
|
|
if (!pblocktemplate) |
|
|
|
if (!pblocktemplate) |
|
|
|
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); |
|
|
|
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); |
|
|
|
vNewBlockTemplate.push_back(pblocktemplate); |
|
|
|
vNewBlockTemplate.push_back(pblocktemplate); |
|
|
@ -192,7 +191,7 @@ Value getwork(const Array& params, bool fHelp) |
|
|
|
pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; |
|
|
|
pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; |
|
|
|
pblock->hashMerkleRoot = pblock->BuildMerkleTree(); |
|
|
|
pblock->hashMerkleRoot = pblock->BuildMerkleTree(); |
|
|
|
|
|
|
|
|
|
|
|
return CheckWork(pblock, *pwalletMain, reservekey); |
|
|
|
return CheckWork(pblock, *pwalletMain, *pMiningKey); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -243,8 +242,6 @@ Value getblocktemplate(const Array& params, bool fHelp) |
|
|
|
if (IsInitialBlockDownload()) |
|
|
|
if (IsInitialBlockDownload()) |
|
|
|
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks..."); |
|
|
|
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks..."); |
|
|
|
|
|
|
|
|
|
|
|
static CReserveKey reservekey(pwalletMain); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update block
|
|
|
|
// Update block
|
|
|
|
static unsigned int nTransactionsUpdatedLast; |
|
|
|
static unsigned int nTransactionsUpdatedLast; |
|
|
|
static CBlockIndex* pindexPrev; |
|
|
|
static CBlockIndex* pindexPrev; |
|
|
@ -267,7 +264,7 @@ Value getblocktemplate(const Array& params, bool fHelp) |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
pblocktemplate = NULL; |
|
|
|
pblocktemplate = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
pblocktemplate = CreateNewBlock(reservekey); |
|
|
|
pblocktemplate = CreateNewBlock(*pMiningKey); |
|
|
|
if (!pblocktemplate) |
|
|
|
if (!pblocktemplate) |
|
|
|
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); |
|
|
|
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); |
|
|
|
|
|
|
|
|
|
|
|