@@ -1155,7 +1155,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
1155
1155
}
1156
1156
1157
1157
// Update the tx's hashBlock
1158
- hashBlock = pblock->GetHash ();
1158
+ hashBlock = pblock->GetHash (true );
1159
1159
1160
1160
// Locate the transaction
1161
1161
for (nIndex = 0 ; nIndex < (int )pblock->vtx .size (); nIndex++)
@@ -1577,7 +1577,7 @@ int CTxIndex::GetDepthInMainChain() const
1577
1577
if (!block.ReadFromDisk (pos.nFile , pos.nBlockPos , false ))
1578
1578
return 0 ;
1579
1579
// Find the block in the index
1580
- BlockMap::iterator mi = mapBlockIndex.find (block.GetHash ());
1580
+ BlockMap::iterator mi = mapBlockIndex.find (block.GetHash (true ));
1581
1581
if (mi == mapBlockIndex.end ())
1582
1582
return 0 ;
1583
1583
CBlockIndex* pindex = (*mi).second ;
@@ -1603,7 +1603,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock)
1603
1603
{
1604
1604
CBlock block;
1605
1605
if (block.ReadFromDisk (txindex.pos .nFile , txindex.pos .nBlockPos , false ))
1606
- hashBlock = block.GetHash ();
1606
+ hashBlock = block.GetHash (true );
1607
1607
return true ;
1608
1608
}
1609
1609
}
@@ -1629,7 +1629,7 @@ bool CBlock::ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions)
1629
1629
}
1630
1630
if (!ReadFromDisk (pindex->nFile , pindex->nBlockPos , fReadTransactions ))
1631
1631
return false ;
1632
- if (GetHash () != pindex->GetBlockHash ())
1632
+ if (GetHash (true ) != pindex->GetBlockHash ())
1633
1633
return error (" CBlock::ReadFromDisk() : GetHash() doesn't match index" );
1634
1634
return true ;
1635
1635
}
@@ -2949,7 +2949,7 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock &
2949
2949
// assert(pindexBest || hashBestChain == pindexBest->GetBlockHash());
2950
2950
// assert(nBestHeight = pindexBest->nHeight && nBestChainTrust == pindexBest->nChainTrust);
2951
2951
// assert(!pindexBest->pnext);
2952
- assert (pindexNew->GetBlockHash ()==blockNew.GetHash ());
2952
+ assert (pindexNew->GetBlockHash ()==blockNew.GetHash (true ));
2953
2953
/* note: it was already determined that this chain is better than current best */
2954
2954
/* assert(pindexNew->nChainTrust > nBestChainTrust); but may be overriden by command */
2955
2955
assert ( !pindexGenesisBlock == !pindexBest );
@@ -3025,16 +3025,16 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock &
3025
3025
{
3026
3026
if (!block.ReadFromDisk (pindex))
3027
3027
return error (" ReorganizeChain: ReadFromDisk for connect failed" );
3028
- assert (pindex->GetBlockHash ()==block.GetHash ());
3028
+ assert (pindex->GetBlockHash ()==block.GetHash (true ));
3029
3029
}
3030
3030
else
3031
3031
{
3032
3032
assert (pindex==pindexNew);
3033
- assert (pindexNew->GetBlockHash ()==block.GetHash ());
3034
- assert (pindexNew->GetBlockHash ()==blockNew.GetHash ());
3033
+ assert (pindexNew->GetBlockHash ()==block.GetHash (true ));
3034
+ assert (pindexNew->GetBlockHash ()==blockNew.GetHash (true ));
3035
3035
}
3036
3036
3037
- uint256 hash = block.GetHash ();
3037
+ uint256 hash = block.GetHash (true );
3038
3038
arith_uint256 nBestBlockTrust;
3039
3039
3040
3040
if (fDebug ) LogPrintf (" ReorganizeChain: connect %s" ,hash.ToString ());
@@ -3053,7 +3053,7 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock &
3053
3053
}
3054
3054
else
3055
3055
{
3056
- assert (pindex->GetBlockHash ()==block.GetHash ());
3056
+ assert (pindex->GetBlockHash ()==block.GetHash (true ));
3057
3057
assert (pindex->pprev == pindexBest);
3058
3058
if (!block.ConnectBlock (txdb, pindex, false , false ))
3059
3059
{
@@ -3218,7 +3218,7 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const
3218
3218
bool CBlock::AddToBlockIndex (unsigned int nFile, unsigned int nBlockPos, const uint256& hashProof)
3219
3219
{
3220
3220
// Check for duplicate
3221
- uint256 hash = GetHash ();
3221
+ uint256 hash = GetHash (true );
3222
3222
if (mapBlockIndex.count (hash))
3223
3223
return error (" AddToBlockIndex() : %s already exists" , hash.ToString ().substr (0 ,20 ).c_str ());
3224
3224
@@ -3291,7 +3291,7 @@ bool CBlock::CheckBlock(std::string sCaller, int height1, int64_t Mint, bool fCh
3291
3291
{
3292
3292
// Allow the genesis block to pass.
3293
3293
if (hashPrevBlock.IsNull () &&
3294
- GetHash () == (fTestNet ? hashGenesisBlockTestNet : hashGenesisBlock))
3294
+ GetHash (true ) == (fTestNet ? hashGenesisBlockTestNet : hashGenesisBlock))
3295
3295
return true ;
3296
3296
3297
3297
// These are checks that are independent of context
@@ -3307,7 +3307,7 @@ bool CBlock::CheckBlock(std::string sCaller, int height1, int64_t Mint, bool fCh
3307
3307
}
3308
3308
3309
3309
// Check proof of work matches claimed amount
3310
- if (fCheckPOW && IsProofOfWork () && !CheckProofOfWork (GetPoWHash ( ), nBits))
3310
+ if (fCheckPOW && IsProofOfWork () && !CheckProofOfWork (GetHash ( true ), nBits))
3311
3311
return DoS (50 , error (" CheckBlock[] : proof of work failed" ));
3312
3312
3313
3313
// Reject blocks with diff that has grown to an extrordinary level (should never happen)
@@ -3441,7 +3441,7 @@ bool CBlock::AcceptBlock(bool generated_by_me)
3441
3441
return DoS (100 , error (" AcceptBlock() : reject unknown block version %d" , nVersion));
3442
3442
3443
3443
// Check for duplicate
3444
- uint256 hash = GetHash ();
3444
+ uint256 hash = GetHash (true );
3445
3445
if (mapBlockIndex.count (hash))
3446
3446
return error (" AcceptBlock() : block already in mapBlockIndex" );
3447
3447
@@ -3544,7 +3544,7 @@ bool CBlock::AcceptBlock(bool generated_by_me)
3544
3544
// PoW is checked in CheckBlock[]
3545
3545
if (IsProofOfWork ())
3546
3546
{
3547
- hashProof = GetPoWHash ( );
3547
+ hashProof = GetHash ( true );
3548
3548
}
3549
3549
3550
3550
// Grandfather
@@ -3717,7 +3717,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock, bool generated_by_me)
3717
3717
AssertLockHeld (cs_main);
3718
3718
3719
3719
// Check for duplicate
3720
- uint256 hash = pblock->GetHash ();
3720
+ uint256 hash = pblock->GetHash (true );
3721
3721
if (mapBlockIndex.count (hash))
3722
3722
return error (" ProcessBlock() : already have block %d %s" , mapBlockIndex[hash]->nHeight , hash.ToString ().c_str ());
3723
3723
if (mapOrphanBlocks.count (hash))
@@ -3865,7 +3865,7 @@ bool CBlock::CheckBlockSignature() const
3865
3865
return false ;
3866
3866
if (vchBlockSig.empty ())
3867
3867
return false ;
3868
- return key.Verify (GetHash (), vchBlockSig);
3868
+ return key.Verify (GetHash (true ), vchBlockSig);
3869
3869
}
3870
3870
3871
3871
return false ;
@@ -4012,7 +4012,7 @@ bool LoadBlockIndex(bool fAllowNew)
4012
4012
block.nNonce = !fTestNet ? 130208 : 22436 ;
4013
4013
LogPrintf (" starting Genesis Check..." );
4014
4014
// If genesis block hash does not match, then generate new genesis hash.
4015
- if (block.GetHash () != (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet))
4015
+ if (block.GetHash (true ) != (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet))
4016
4016
{
4017
4017
LogPrintf (" Searching for genesis block..." );
4018
4018
// This will figure out a valid hash and Nonce if you're
@@ -4021,7 +4021,7 @@ bool LoadBlockIndex(bool fAllowNew)
4021
4021
arith_uint256 thash;
4022
4022
while (true )
4023
4023
{
4024
- thash = UintToArith256 (block.GetHash ());
4024
+ thash = UintToArith256 (block.GetHash (true ));
4025
4025
if (thash <= hashTarget)
4026
4026
break ;
4027
4027
if ((block.nNonce & 0xFFF ) == 0 )
@@ -4037,7 +4037,7 @@ bool LoadBlockIndex(bool fAllowNew)
4037
4037
}
4038
4038
LogPrintf (" block.nTime = %u " , block.nTime );
4039
4039
LogPrintf (" block.nNonce = %u " , block.nNonce );
4040
- LogPrintf (" block.GetHash = %s" , block.GetHash ().ToString ());
4040
+ LogPrintf (" block.GetHash = %s" , block.GetHash (true ).ToString ());
4041
4041
}
4042
4042
4043
4043
@@ -4048,7 +4048,7 @@ bool LoadBlockIndex(bool fAllowNew)
4048
4048
// GENESIS3: Official Merkle Root
4049
4049
uint256 merkle_root = uint256S (" 0x5109d5782a26e6a5a5eb76c7867f3e8ddae2bff026632c36afec5dc32ed8ce9f" );
4050
4050
assert (block.hashMerkleRoot == merkle_root);
4051
- assert (block.GetHash () == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet));
4051
+ assert (block.GetHash (true ) == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet));
4052
4052
assert (block.CheckBlock (" LoadBlockIndex" ,1 ,10 *COIN));
4053
4053
4054
4054
// Start new block file
@@ -4210,7 +4210,7 @@ void PrintBlockTree()
4210
4210
pindex->nHeight ,
4211
4211
pindex->nFile ,
4212
4212
pindex->nBlockPos ,
4213
- block.GetHash ().ToString ().c_str (),
4213
+ block.GetHash (true ).ToString ().c_str (),
4214
4214
block.nBits ,
4215
4215
DateTimeStrFormat (" %x %H:%M:%S" , block.GetBlockTime ()).c_str (),
4216
4216
FormatMoney (pindex->nMint ).c_str (),
@@ -5025,7 +5025,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5025
5025
CBlock block;
5026
5026
std::string acid = " " ;
5027
5027
vRecv >> block >> acid;
5028
- uint256 hashBlock = block.GetHash ();
5028
+ uint256 hashBlock = block.GetHash (true );
5029
5029
5030
5030
LogPrintf (" Received block %s; " , hashBlock.ToString ());
5031
5031
if (fDebug10 ) block.print ();
0 commit comments