Skip to content

Commit

Permalink
Switched operator in GetBlockWork().
Browse files Browse the repository at this point in the history
  • Loading branch information
presstab committed Feb 10, 2019
1 parent 2ef2fdd commit 607fe50
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/chain.cpp
Expand Up @@ -145,15 +145,18 @@ int64_t CBlockIndex::GetBlockWork() const
if (pprev && pprev->pprev)
nTimeSpan = pprev->GetBlockTime() - pprev->pprev->GetBlockTime();
int64_t nBlockWork = 1000 - nTimeSpan;
if (nBlockWork <= 0)
nBlockWork = 1;

//PoS blocks have the final decision on consensus, if it is between a PoW block and PoS block
// PoS blocks are also the only type of block that has the scoring of the block directly based on the elapsed time
// of this block and the prev. PoW is not bound by timestamps the same way PoS is, so it is not as safe to do with PoW
if (IsProofOfStake()) {
nBlockWork += 1000 + (GetBlockTime() - pprev->GetBlockTime());
nTimeSpan = GetBlockTime() - pprev->GetBlockTime();
if (nTimeSpan < 0)
nTimeSpan = 1;
nBlockWork += (1000 - nTimeSpan);
}
if (nBlockWork <= 0)
nBlockWork = 1;
return nBlockWork;
}

Expand Down

0 comments on commit 607fe50

Please sign in to comment.