mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "univalue/univalue.h"
|
||||
|
||||
@@ -131,11 +132,11 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
int nHeight = 0;
|
||||
int nGenerate = params[0].get_int();
|
||||
|
||||
CScript coinbaseScript;
|
||||
boost::shared_ptr<CReserveScript> coinbaseScript;
|
||||
GetMainSignals().ScriptForMining(coinbaseScript);
|
||||
|
||||
//throw an error if no script was provided
|
||||
if (!coinbaseScript.size())
|
||||
if (!coinbaseScript->reserveScript.size())
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "No coinbase script available (mining requires a wallet)");
|
||||
|
||||
{ // Don't keep cs_main locked
|
||||
@@ -148,7 +149,7 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
UniValue blockHashes(UniValue::VARR);
|
||||
while (nHeight < nHeightEnd)
|
||||
{
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(coinbaseScript));
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(coinbaseScript->reserveScript));
|
||||
if (!pblocktemplate.get())
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
@@ -166,6 +167,9 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
|
||||
++nHeight;
|
||||
blockHashes.push_back(pblock->GetHash().GetHex());
|
||||
|
||||
//mark script as important because it was used at least for one coinbase output
|
||||
coinbaseScript->KeepScript();
|
||||
}
|
||||
return blockHashes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user