Skip to content

Commit 475a3e3

Browse files
committed
staking regression
1 parent f1ca318 commit 475a3e3

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ bool CheckStakeKernelHash(uint32_t nBits, const CBlock& blockFrom, uint32_t nTxP
370370
CBigNum weightDayTarget = bnCoinDayWeight * bnTargetPerCoinDay;
371371
if (CBigNum(hashProofOfStake) > weightDayTarget)
372372
{
373-
printf("\n\n\n>>> hashStake = %s > weightDayTarget=%s and it should not be\n",
374-
CBigNum(hashProofOfStake).ToString().c_str(), weightDayTarget.ToString().c_str());
375-
printf(">>> CheckStakeKernelHash - hashProofOfStake too much\n\n\n");
373+
//printf("\n\n\n>>> hashStake = %s > weightDayTarget=%s and it should not be\n",
374+
//CBigNum(hashProofOfStake).ToString().c_str(), weightDayTarget.ToString().c_str());
375+
//printf(">>> CheckStakeKernelHash - hashProofOfStake too much\n\n\n");
376376
return false;
377377
}
378378
if (fDebug && !fPrintProofOfStake)

src/kernel_worker.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void KernelWorker::Do_generic()
2121
// Compute maximum possible target to filter out majority of obviously insufficient hashes
2222
CBigNum bnTargetPerCoinDay;
2323
bnTargetPerCoinDay.SetCompact(nBits);
24-
uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256();
24+
uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / nOneDay).getuint256();
2525

2626
SHA256_CTX ctx, workerCtx;
2727
// Init new sha256 context and update it
@@ -53,7 +53,7 @@ void KernelWorker::Do_generic()
5353
if (hashProofOfStake[7] > nMaxTarget32)
5454
continue;
5555

56-
CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay;
56+
CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / nOneDay;
5757
CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
5858

5959
if (bnTargetProofOfStake >= CBigNum(*pnHashProofOfStake))
@@ -81,7 +81,7 @@ bool ScanKernelBackward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTx
8181
CBigNum bnValueIn(nValueIn);
8282

8383
// Get maximum possible target to filter out the majority of obviously insufficient hashes
84-
uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256();
84+
uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / nOneDay).getuint256();
8585

8686
SHA256_CTX ctx, workerCtx;
8787
// Init new sha256 context and update it
@@ -110,7 +110,7 @@ bool ScanKernelBackward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTx
110110
if (hashProofOfStake > nMaxTarget)
111111
continue;
112112

113-
CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay;
113+
CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / nOneDay;
114114
CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
115115

116116
if (bnTargetProofOfStake >= CBigNum(hashProofOfStake))

src/kernelrecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ double KernelRecord::getProbToMintStake(double difficulty, int timeOffset) const
103103
//uint64_t coinAge = max(nValue * dayWeight / COIN, (int64_t)0);
104104
//return target * coinAge / pow(static_cast<double>(2), 256);
105105
int64_t Weight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge);
106-
uint64_t coinAge = max(nValue * Weight / (COIN * nOneDay), (int64_t)0);
106+
uint64_t coinAge = max(nValue * Weight / nOneDay, (int64_t)0);
107107
return coinAge / (pow(static_cast<double>(2),32) * difficulty);
108108
}
109109

src/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ void CWallet::GetStakeWeightFromValue(const int64_t& nTime, const int64_t& nValu
21332133
return;
21342134
}
21352135

2136-
CBigNum bnCoinDayWeight = CBigNum(nValue) * nTimeWeight / COIN / nOneDay;
2136+
CBigNum bnCoinDayWeight = CBigNum(nValue) * nTimeWeight / nOneDay;
21372137
nWeight = bnCoinDayWeight.getuint64();
21382138
}
21392139

0 commit comments

Comments
 (0)