mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Smarter algorithm for finding the nHeight for the last block
This commit is contained in:
parent
6fc05e7fa8
commit
7481a27fe4
@ -2943,11 +2943,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
||||
{
|
||||
nHeight = pindexPrev->nHeight+1;
|
||||
} else { //out of order
|
||||
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex){
|
||||
if(item.first == block.hashPrevBlock) {
|
||||
nHeight = item.second->nHeight+1;
|
||||
}
|
||||
}
|
||||
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
||||
if (mi != mapBlockIndex.end() && (*mi).second)
|
||||
nHeight = (*mi).second->nHeight+1;
|
||||
}
|
||||
|
||||
if(nHeight != 0){
|
||||
|
@ -28,11 +28,9 @@ bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue){
|
||||
{
|
||||
nHeight = pindexPrev->nHeight+1;
|
||||
} else { //out of order
|
||||
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex){
|
||||
if(item.first == block.hashPrevBlock) {
|
||||
nHeight = item.second->nHeight+1;
|
||||
}
|
||||
}
|
||||
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
||||
if (mi != mapBlockIndex.end() && (*mi).second)
|
||||
nHeight = (*mi).second->nHeight+1;
|
||||
}
|
||||
|
||||
if(nHeight == 0){
|
||||
|
Loading…
Reference in New Issue
Block a user