Skip to content

Commit

Permalink
Merge pull request #668 from qtumproject/neil/fix-staker
Browse files Browse the repository at this point in the history
Use actual tip block when staking
  • Loading branch information
qtum-neil authored Apr 13, 2019
2 parents 9a9fc3b + 7df5d12 commit 2ec8c7b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ void ThreadStakeMiner(CWallet *pwallet, CConnman* connman)
if (fTryToSync) {
fTryToSync = false;
if (connman->GetNodeCount(CConnman::CONNECTIONS_ALL) < 3 ||
pindexBestHeader->GetBlockTime() < GetTime() - 10 * 60) {
chainActive.Tip()->GetBlockTime() < GetTime() - 10 * 60) {
MilliSleep(60000);
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4065,7 +4065,7 @@ bool SignBlock(std::shared_ptr<CBlock> pblock, CWallet& wallet, const CAmount& n
//IsProtocolV2 mean POS 2 or higher, so the modified line is:
if (wallet.CreateCoinStake(wallet, pblock->nBits, nTotalFees, nTimeBlock, txCoinStake, key))
{
if (nTimeBlock >= pindexBestHeader->GetMedianTimePast()+1)
if (nTimeBlock >= chainActive.Tip()->GetMedianTimePast()+1)
{
// make sure coinstake would meet timestamp protocol
// as it would be the same as the block timestamp
Expand All @@ -4075,7 +4075,7 @@ bool SignBlock(std::shared_ptr<CBlock> pblock, CWallet& wallet, const CAmount& n
pblock->prevoutStake = pblock->vtx[1]->vin[0].prevout;

// Check timestamp against prev
if(pblock->GetBlockTime() <= pindexBestHeader->GetBlockTime() || FutureDrift(pblock->GetBlockTime()) < pindexBestHeader->GetBlockTime())
if(pblock->GetBlockTime() <= chainActive.Tip()->GetBlockTime() || FutureDrift(pblock->GetBlockTime()) < chainActive.Tip()->GetBlockTime())
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3460,7 +3460,7 @@ uint64_t CWallet::GetStakeWeight() const

bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, const CAmount& nTotalFees, uint32_t nTimeBlock, CMutableTransaction& tx, CKey& key)
{
CBlockIndex* pindexPrev = pindexBestHeader;
CBlockIndex* pindexPrev = chainActive.Tip();
arith_uint256 bnTargetPerCoinDay;
bnTargetPerCoinDay.SetCompact(nBits);

Expand Down

0 comments on commit 2ec8c7b

Please sign in to comment.