Skip to content

Commit 944e793

Browse files
committed
[Cleanup] LoadStakeInput: no need for the previous block
1 parent c6f71b2 commit 944e793

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/kernel.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,8 @@ bool CStakeKernel::CheckKernelHash(bool fSkipLog) const
8787
*/
8888

8989
// helper function for CheckProofOfStake and GetStakeKernelHash
90-
bool LoadStakeInput(const CBlock& block, const CBlockIndex* pindexPrev, std::unique_ptr<CStakeInput>& stake)
90+
static bool LoadStakeInput(const CBlock& block, std::unique_ptr<CStakeInput>& stake)
9191
{
92-
// If previous index is not provided, look for it in the blockmap
93-
if (!pindexPrev) {
94-
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
95-
if (mi != mapBlockIndex.end() && (*mi).second) pindexPrev = (*mi).second;
96-
else return error("%s : couldn't find previous block", __func__);
97-
} else {
98-
// check that is the actual parent block
99-
if (block.hashPrevBlock != pindexPrev->GetBlockHash())
100-
return error("%s : previous block mismatch", __func__);
101-
}
102-
10392
// Check that this is a PoS block
10493
if (!block.IsProofOfStake())
10594
return error("called on non PoS block");
@@ -153,7 +142,7 @@ bool CheckProofOfStake(const CBlock& block, std::string& strError, const CBlockI
153142
const int nHeight = pindexPrev->nHeight + 1;
154143
// Initialize stake input
155144
std::unique_ptr<CStakeInput> stakeInput;
156-
if (!LoadStakeInput(block, pindexPrev, stakeInput)) {
145+
if (!LoadStakeInput(block, stakeInput)) {
157146
strError = "stake input initialization failed";
158147
return false;
159148
}
@@ -207,7 +196,7 @@ bool GetStakeKernelHash(uint256& hashRet, const CBlock& block, const CBlockIndex
207196
{
208197
// Initialize stake input
209198
std::unique_ptr<CStakeInput> stakeInput;
210-
if (!LoadStakeInput(block, pindexPrev, stakeInput))
199+
if (!LoadStakeInput(block, stakeInput))
211200
return error("%s : stake input initialization failed", __func__);
212201

213202
CStakeKernel stakeKernel(pindexPrev, stakeInput.get(), block.nBits, block.nTime);

0 commit comments

Comments
 (0)