Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect usage of begin() when genesis block is requested in "protx diff" #2699

Merged
merged 2 commits into from
Feb 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/evo/simplifiedmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,27 @@ bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& bloc
AssertLockHeld(cs_main);
mnListDiffRet = CSimplifiedMNListDiff();

BlockMap::iterator baseBlockIt = mapBlockIndex.begin();
const CBlockIndex* baseBlockIndex = chainActive[0];
codablock marked this conversation as resolved.
Show resolved Hide resolved
if (!baseBlockHash.IsNull()) {
baseBlockIt = mapBlockIndex.find(baseBlockHash);
auto it = mapBlockIndex.find(baseBlockHash);
if (it == mapBlockIndex.end()) {
errorRet = strprintf("block %s not found", baseBlockHash.ToString());
return false;
}
baseBlockIndex = it->second;
}
auto blockIt = mapBlockIndex.find(blockHash);
if (baseBlockIt == mapBlockIndex.end()) {
errorRet = strprintf("block %s not found", baseBlockHash.ToString());
return false;
}
if (blockIt == mapBlockIndex.end()) {
errorRet = strprintf("block %s not found", blockHash.ToString());
return false;
}
const CBlockIndex* blockIndex = blockIt->second;

if (!chainActive.Contains(baseBlockIt->second) || !chainActive.Contains(blockIt->second)) {
if (!chainActive.Contains(baseBlockIndex) || !chainActive.Contains(blockIndex)) {
errorRet = strprintf("block %s and %s are not in the same chain", baseBlockHash.ToString(), blockHash.ToString());
return false;
}
if (baseBlockIt->second->nHeight > blockIt->second->nHeight) {
if (baseBlockIndex->nHeight > blockIndex->nHeight) {
errorRet = strprintf("base block %s is higher then block %s", baseBlockHash.ToString(), blockHash.ToString());
return false;
}
Expand All @@ -150,7 +152,7 @@ bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& bloc

// TODO store coinbase TX in CBlockIndex
CBlock block;
if (!ReadBlockFromDisk(block, blockIt->second, Params().GetConsensus())) {
if (!ReadBlockFromDisk(block, blockIndex, Params().GetConsensus())) {
errorRet = strprintf("failed to read block %s from disk", blockHash.ToString());
return false;
}
Expand Down