Proof-of-stake related code refactoring and cleanup

This commit is contained in:
lateminer
2018-10-12 23:40:50 +03:00
parent da2c4ec6c9
commit 66dd63a23b
10 changed files with 163 additions and 164 deletions

View File

@@ -607,8 +607,8 @@ void CWallet::AvailableCoinsForStaking(std::vector<COutput>& vCoins) const
if (nDepth < 1)
continue;
if (nDepth < Params().GetConsensus().nStakeMinConfirmations)
continue;
if (nDepth < Params().GetConsensus().nStakeMinConfirmations)
continue;
if (pcoin->GetBlocksToMaturity() > 0)
continue;
@@ -626,6 +626,13 @@ void CWallet::AvailableCoinsForStaking(std::vector<COutput>& vCoins) const
}
}
bool CWallet::HaveAvailableCoinsForStaking() const
{
vector<COutput> vCoins;
AvailableCoinsForStaking(vCoins);
return vCoins.size() > 0;
}
// Select some coins without random shuffle or best subset approximation
bool CWallet::SelectCoinsForStaking(CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const
{

View File

@@ -904,9 +904,12 @@ public:
/* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
bool AbandonTransaction(const uint256& hashTx);
/* Staking */
bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CAmount& nFees, CMutableTransaction& tx, CKey& key);
bool SelectCoinsForStaking(CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const;
void AvailableCoinsForStaking(std::vector<COutput>& vCoins) const;
bool HaveAvailableCoinsForStaking() const;
uint64_t GetStakeWeight() const;
/* Returns the wallets help message */