diff options
author | Jonas Schnelli <jonas.schnelli@include7.ch> | 2015-07-01 08:32:30 +0200 |
---|---|---|
committer | Jonas Schnelli <jonas.schnelli@include7.ch> | 2015-07-01 16:06:14 +0200 |
commit | 5496253966abec287ea61a648cb518d14903f91f (patch) | |
tree | a8ed0fc4e07bfff4ac064ef80ff75f4882f4fe86 /src/wallet | |
parent | 087e65def97fd3a2f61fa11b9f1cd2d7bc2f5f90 (diff) |
add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 11 | ||||
-rw-r--r-- | src/wallet/wallet.h | 7 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 997ca1e2f5..238f62a575 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index c8ce5ad221..1774596af1 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -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(); } }; |