aboutsummaryrefslogtreecommitdiff
path: root/src/rpcmining.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2015-07-01 08:32:30 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-07-01 16:06:14 +0200
commit5496253966abec287ea61a648cb518d14903f91f (patch)
treea8ed0fc4e07bfff4ac064ef80ff75f4882f4fe86 /src/rpcmining.cpp
parent087e65def97fd3a2f61fa11b9f1cd2d7bc2f5f90 (diff)
add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r--src/rpcmining.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 3e4071befa..9c6fb10af0 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -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;
}