add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
This commit is contained in:
@@ -2583,14 +2583,15 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::GetScriptForMining(CScript &script)
|
||||
void CWallet::GetScriptForMining(boost::shared_ptr<CReserveScript> &script)
|
||||
{
|
||||
CReserveKey reservekey(this);
|
||||
boost::shared_ptr<CReserveKey> rKey(new CReserveKey(this));
|
||||
CPubKey pubkey;
|
||||
if (!reservekey.GetReservedKey(pubkey))
|
||||
if (!rKey->GetReservedKey(pubkey))
|
||||
return;
|
||||
script = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
|
||||
reservekey.KeepKey();
|
||||
|
||||
script = rKey;
|
||||
script->reserveScript = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
|
||||
}
|
||||
|
||||
void CWallet::LockCoin(COutPoint& output)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*/
|
||||
@@ -680,7 +682,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void GetScriptForMining(CScript &script);
|
||||
void GetScriptForMining(boost::shared_ptr<CReserveScript> &script);
|
||||
void UpdateRequestCount(const CBlock& block)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
@@ -742,7 +744,7 @@ public:
|
||||
};
|
||||
|
||||
/** A key allocated from the key pool. */
|
||||
class CReserveKey
|
||||
class CReserveKey : public CReserveScript
|
||||
{
|
||||
protected:
|
||||
CWallet* pwallet;
|
||||
@@ -763,6 +765,7 @@ public:
|
||||
void ReturnKey();
|
||||
bool GetReservedKey(CPubKey &pubkey);
|
||||
void KeepKey();
|
||||
void KeepScript() { KeepKey(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user