Skip to content

Commit

Permalink
Merge pull request #21 from JRedinger/master
Browse files Browse the repository at this point in the history
FPOS Flip bugfix
  • Loading branch information
aistrych committed Jan 22, 2019
2 parents 1706801 + f7bf6a5 commit 16e40c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,20 @@ const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfSta
const CBlockIndex* GetLastBlockIndex2(const CBlockIndex* pindex, bool fFlashStake)
{
//bool bFlashStake = true;
while (pindex && pindex->pprev && IsFlashStake(pindex->nTime) != fFlashStake)
{
pindex = pindex->pprev;
if (pindex->nHeight >= 771000) {

while (pindex && pindex->pprev && !pindex->IsFPOS(fFlashStake))
pindex = pindex->pprev;

} else {

while (pindex && pindex->pprev && IsFlashStake(pindex->nTime) != fFlashStake)
pindex = pindex->pprev;
while (pindex && pindex->pprev && (!pindex->IsProofOfStake()))
pindex = pindex->pprev;
}
while (pindex && pindex->pprev && (!pindex->IsProofOfStake()))
pindex = pindex->pprev;
return pindex;

}

unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake, unsigned int nBlockTime)
Expand Down
6 changes: 3 additions & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,10 @@ class CBlockIndex
return (nFlags & BLOCK_PROOF_OF_STAKE);
}

bool IsFlashPOS() const
bool IsFPOS(bool nFlash) const
{
if (IsProofOfStake())
return (IsFlashStake(nTime));
if (IsProofOfStake())
return nFlash == IsFlashStake(nTime);

return false;
}
Expand Down

0 comments on commit 16e40c6

Please sign in to comment.