Browse Source

Merge pull request #4838

1e4f87f Use memcmp for uint256 equality/inequality (Pieter Wuille)
8a41e1e Use boost::unordered_map for mapBlockIndex (Pieter Wuille)
145d5be Introduce BlockMap type for mapBlockIndex (Pieter Wuille)
a0dbe43 checkpoints.cpp depends on main, it can use mapBlockIndex directly (Pieter Wuille)
0.10
Pieter Wuille 10 years ago
parent
commit
af9c3b0cff
No known key found for this signature in database
GPG Key ID: 8F653255C87992E0
  1. 4
      src/checkpoints.cpp
  2. 2
      src/checkpoints.h
  3. 2
      src/init.cpp
  4. 38
      src/main.cpp
  5. 9
      src/main.h
  6. 2
      src/qt/transactionrecord.cpp
  7. 2
      src/rpcblockchain.cpp
  8. 2
      src/rpcrawtransaction.cpp
  9. 2
      src/rpcwallet.cpp
  10. 5
      src/uint256.h
  11. 6
      src/wallet.cpp

4
src/checkpoints.cpp

@ -146,7 +146,7 @@ namespace Checkpoints {
return checkpoints.rbegin()->first; return checkpoints.rbegin()->first;
} }
CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex) CBlockIndex* GetLastCheckpoint()
{ {
if (!fEnabled) if (!fEnabled)
return NULL; return NULL;
@ -156,7 +156,7 @@ namespace Checkpoints {
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
{ {
const uint256& hash = i.second; const uint256& hash = i.second;
std::map<uint256, CBlockIndex*>::const_iterator t = mapBlockIndex.find(hash); BlockMap::const_iterator t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end()) if (t != mapBlockIndex.end())
return t->second; return t->second;
} }

2
src/checkpoints.h

@ -22,7 +22,7 @@ namespace Checkpoints {
int GetTotalBlocksEstimate(); int GetTotalBlocksEstimate();
// Returns last CBlockIndex* in mapBlockIndex that is a checkpoint // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex); CBlockIndex* GetLastCheckpoint();
double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks = true); double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks = true);

2
src/init.cpp

@ -1031,7 +1031,7 @@ bool AppInit2(boost::thread_group& threadGroup)
{ {
string strMatch = mapArgs["-printblock"]; string strMatch = mapArgs["-printblock"];
int nFound = 0; int nFound = 0;
for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{ {
uint256 hash = (*mi).first; uint256 hash = (*mi).first;
if (boost::algorithm::starts_with(hash.ToString(), strMatch)) if (boost::algorithm::starts_with(hash.ToString(), strMatch))

38
src/main.cpp

@ -38,7 +38,7 @@ using namespace boost;
CCriticalSection cs_main; CCriticalSection cs_main;
map<uint256, CBlockIndex*> mapBlockIndex; BlockMap mapBlockIndex;
CChain chainActive; CChain chainActive;
int64_t nTimeBestReceived = 0; int64_t nTimeBestReceived = 0;
CWaitableCriticalSection csBestBlock; CWaitableCriticalSection csBestBlock;
@ -328,7 +328,7 @@ void ProcessBlockAvailability(NodeId nodeid) {
assert(state != NULL); assert(state != NULL);
if (state->hashLastUnknownBlock != 0) { if (state->hashLastUnknownBlock != 0) {
map<uint256, CBlockIndex*>::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock);
if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) {
if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork)
state->pindexBestKnownBlock = itOld->second; state->pindexBestKnownBlock = itOld->second;
@ -344,7 +344,7 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
ProcessBlockAvailability(nodeid); ProcessBlockAvailability(nodeid);
map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(hash); BlockMap::iterator it = mapBlockIndex.find(hash);
if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { if (it != mapBlockIndex.end() && it->second->nChainWork > 0) {
// An actually better block was announced. // An actually better block was announced.
if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork)
@ -434,7 +434,7 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
CBlockIndex *CChain::FindFork(const CBlockLocator &locator) const { CBlockIndex *CChain::FindFork(const CBlockLocator &locator) const {
// Find the first block the caller has in the main chain // Find the first block the caller has in the main chain
BOOST_FOREACH(const uint256& hash, locator.vHave) { BOOST_FOREACH(const uint256& hash, locator.vHave) {
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end()) if (mi != mapBlockIndex.end())
{ {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
@ -2068,7 +2068,7 @@ CBlockIndex* AddToBlockIndex(CBlockHeader& block)
{ {
// Check for duplicate // Check for duplicate
uint256 hash = block.GetHash(); uint256 hash = block.GetHash();
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(hash); BlockMap::iterator it = mapBlockIndex.find(hash);
if (it != mapBlockIndex.end()) if (it != mapBlockIndex.end())
return it->second; return it->second;
@ -2079,9 +2079,9 @@ CBlockIndex* AddToBlockIndex(CBlockHeader& block)
LOCK(cs_nBlockSequenceId); LOCK(cs_nBlockSequenceId);
pindexNew->nSequenceId = nBlockSequenceId++; pindexNew->nSequenceId = nBlockSequenceId++;
} }
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; BlockMap::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
pindexNew->phashBlock = &((*mi).first); pindexNew->phashBlock = &((*mi).first);
map<uint256, CBlockIndex*>::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock); BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock);
if (miPrev != mapBlockIndex.end()) if (miPrev != mapBlockIndex.end())
{ {
pindexNew->pprev = (*miPrev).second; pindexNew->pprev = (*miPrev).second;
@ -2294,7 +2294,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
// Check for duplicate // Check for duplicate
uint256 hash = block.GetHash(); uint256 hash = block.GetHash();
std::map<uint256, CBlockIndex*>::iterator miSelf = mapBlockIndex.find(hash); BlockMap::iterator miSelf = mapBlockIndex.find(hash);
CBlockIndex *pindex = NULL; CBlockIndex *pindex = NULL;
if (miSelf != mapBlockIndex.end()) { if (miSelf != mapBlockIndex.end()) {
pindex = miSelf->second; pindex = miSelf->second;
@ -2302,7 +2302,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
return state.Invalid(error("AcceptBlock() : block is marked invalid"), 0, "duplicate"); return state.Invalid(error("AcceptBlock() : block is marked invalid"), 0, "duplicate");
} }
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint();
if (pcheckpoint && block.hashPrevBlock != (chainActive.Tip() ? chainActive.Tip()->GetBlockHash() : uint256(0))) if (pcheckpoint && block.hashPrevBlock != (chainActive.Tip() ? chainActive.Tip()->GetBlockHash() : uint256(0)))
{ {
// Extra checks to prevent "fill up memory by spamming with bogus blocks" // Extra checks to prevent "fill up memory by spamming with bogus blocks"
@ -2323,7 +2323,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
CBlockIndex* pindexPrev = NULL; CBlockIndex* pindexPrev = NULL;
int nHeight = 0; int nHeight = 0;
if (hash != Params().HashGenesisBlock()) { if (hash != Params().HashGenesisBlock()) {
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(block.hashPrevBlock); BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
if (mi == mapBlockIndex.end()) if (mi == mapBlockIndex.end())
return state.DoS(10, error("AcceptBlock() : prev block not found"), 0, "bad-prevblk"); return state.DoS(10, error("AcceptBlock() : prev block not found"), 0, "bad-prevblk");
pindexPrev = (*mi).second; pindexPrev = (*mi).second;
@ -2345,7 +2345,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
REJECT_CHECKPOINT, "checkpoint mismatch"); REJECT_CHECKPOINT, "checkpoint mismatch");
// Don't accept any forks from the main chain prior to last checkpoint // Don't accept any forks from the main chain prior to last checkpoint
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint();
if (pcheckpoint && nHeight < pcheckpoint->nHeight) if (pcheckpoint && nHeight < pcheckpoint->nHeight)
return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight)); return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight));
@ -2517,7 +2517,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
return error("ProcessBlock() : CheckBlock FAILED"); return error("ProcessBlock() : CheckBlock FAILED");
// If we don't already have its previous block (with full data), shunt it off to holding area until we get it // If we don't already have its previous block (with full data), shunt it off to holding area until we get it
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pblock->hashPrevBlock); BlockMap::iterator it = mapBlockIndex.find(pblock->hashPrevBlock);
if (pblock->hashPrevBlock != 0 && (it == mapBlockIndex.end() || !(it->second->nStatus & BLOCK_HAVE_DATA))) if (pblock->hashPrevBlock != 0 && (it == mapBlockIndex.end() || !(it->second->nStatus & BLOCK_HAVE_DATA)))
{ {
LogPrintf("ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n", (unsigned long)mapOrphanBlocks.size(), pblock->hashPrevBlock.ToString()); LogPrintf("ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n", (unsigned long)mapOrphanBlocks.size(), pblock->hashPrevBlock.ToString());
@ -2799,7 +2799,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
return NULL; return NULL;
// Return existing // Return existing
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end()) if (mi != mapBlockIndex.end())
return (*mi).second; return (*mi).second;
@ -2876,7 +2876,7 @@ bool static LoadBlockIndexDB()
LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled"); LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
// Load pointer to end of best chain // Load pointer to end of best chain
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
if (it == mapBlockIndex.end()) if (it == mapBlockIndex.end())
return true; return true;
chainActive.SetTip(it->second); chainActive.SetTip(it->second);
@ -3034,7 +3034,7 @@ void PrintBlockTree()
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
// pre-compute tree structure // pre-compute tree structure
map<CBlockIndex*, vector<CBlockIndex*> > mapNext; map<CBlockIndex*, vector<CBlockIndex*> > mapNext;
for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{ {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
mapNext[pindex->pprev].push_back(pindex); mapNext[pindex->pprev].push_back(pindex);
@ -3280,13 +3280,13 @@ void static ProcessGetData(CNode* pfrom)
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK) if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
{ {
bool send = false; bool send = false;
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash); BlockMap::iterator mi = mapBlockIndex.find(inv.hash);
if (mi != mapBlockIndex.end()) if (mi != mapBlockIndex.end())
{ {
// If the requested block is at a height below our last // If the requested block is at a height below our last
// checkpoint, only serve it if it's in the checkpointed chain // checkpoint, only serve it if it's in the checkpointed chain
int nHeight = mi->second->nHeight; int nHeight = mi->second->nHeight;
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint();
if (pcheckpoint && nHeight < pcheckpoint->nHeight) { if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
if (!chainActive.Contains(mi->second)) if (!chainActive.Contains(mi->second))
{ {
@ -3711,7 +3711,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (locator.IsNull()) if (locator.IsNull())
{ {
// If locator is null, return the hashStop block // If locator is null, return the hashStop block
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashStop); BlockMap::iterator mi = mapBlockIndex.find(hashStop);
if (mi == mapBlockIndex.end()) if (mi == mapBlockIndex.end())
return true; return true;
pindex = (*mi).second; pindex = (*mi).second;
@ -4513,7 +4513,7 @@ public:
CMainCleanup() {} CMainCleanup() {}
~CMainCleanup() { ~CMainCleanup() {
// block headers // block headers
std::map<uint256, CBlockIndex*>::iterator it1 = mapBlockIndex.begin(); BlockMap::iterator it1 = mapBlockIndex.begin();
for (; it1 != mapBlockIndex.end(); it1++) for (; it1 != mapBlockIndex.end(); it1++)
delete (*it1).second; delete (*it1).second;
mapBlockIndex.clear(); mapBlockIndex.clear();

9
src/main.h

@ -29,6 +29,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <boost/unordered_map.hpp>
class CBlockIndex; class CBlockIndex;
class CBloomFilter; class CBloomFilter;
class CInv; class CInv;
@ -81,11 +83,16 @@ static const unsigned char REJECT_DUST = 0x41;
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42; static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
static const unsigned char REJECT_CHECKPOINT = 0x43; static const unsigned char REJECT_CHECKPOINT = 0x43;
struct BlockHasher
{
size_t operator()(const uint256& hash) const { return hash.GetLow64(); }
};
extern CScript COINBASE_FLAGS; extern CScript COINBASE_FLAGS;
extern CCriticalSection cs_main; extern CCriticalSection cs_main;
extern CTxMemPool mempool; extern CTxMemPool mempool;
extern std::map<uint256, CBlockIndex*> mapBlockIndex; typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
extern BlockMap mapBlockIndex;
extern uint64_t nLastBlockTx; extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockSize; extern uint64_t nLastBlockSize;
extern const std::string strMessageMagic; extern const std::string strMessageMagic;

2
src/qt/transactionrecord.cpp

@ -170,7 +170,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
// Find the block the tx is in // Find the block the tx is in
CBlockIndex* pindex = NULL; CBlockIndex* pindex = NULL;
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(wtx.hashBlock); BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock);
if (mi != mapBlockIndex.end()) if (mi != mapBlockIndex.end())
pindex = (*mi).second; pindex = (*mi).second;

2
src/rpcblockchain.cpp

@ -392,7 +392,7 @@ Value gettxout(const Array& params, bool fHelp)
if (n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull()) if (n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull())
return Value::null; return Value::null;
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
CBlockIndex *pindex = it->second; CBlockIndex *pindex = it->second;
ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex())); ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex()));
if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT) if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT)

2
src/rpcrawtransaction.cpp

@ -88,7 +88,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
if (hashBlock != 0) { if (hashBlock != 0) {
entry.push_back(Pair("blockhash", hashBlock.GetHex())); entry.push_back(Pair("blockhash", hashBlock.GetHex()));
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) { if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) { if (chainActive.Contains(pindex)) {

2
src/rpcwallet.cpp

@ -1447,7 +1447,7 @@ Value listsinceblock(const Array& params, bool fHelp)
uint256 blockId = 0; uint256 blockId = 0;
blockId.SetHex(params[0].get_str()); blockId.SetHex(params[0].get_str());
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId); BlockMap::iterator it = mapBlockIndex.find(blockId);
if (it != mapBlockIndex.end()) if (it != mapBlockIndex.end())
pindex = it->second; pindex = it->second;
} }

5
src/uint256.h

@ -10,6 +10,7 @@
#include <stdexcept> #include <stdexcept>
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#include <cstring>
#include <vector> #include <vector>
class uint_error : public std::runtime_error { class uint_error : public std::runtime_error {
@ -215,8 +216,8 @@ public:
friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; } friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; } friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; } friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
friend inline bool operator==(const base_uint& a, const base_uint& b) { return a.CompareTo(b) == 0; } friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
friend inline bool operator!=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) != 0; } friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; } friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }
friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; } friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; }
friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; } friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; }

6
src/wallet.cpp

@ -2113,7 +2113,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) { for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) {
// iterate over all wallet transactions... // iterate over all wallet transactions...
const CWalletTx &wtx = (*it).second; const CWalletTx &wtx = (*it).second;
std::map<uint256, CBlockIndex*>::const_iterator blit = mapBlockIndex.find(wtx.hashBlock); BlockMap::const_iterator blit = mapBlockIndex.find(wtx.hashBlock);
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) {
// ... which are already in a block // ... which are already in a block
int nHeight = blit->second->nHeight; int nHeight = blit->second->nHeight;
@ -2233,7 +2233,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
} }
// Is the tx in a block that's in the main chain // Is the tx in a block that's in the main chain
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end()) if (mi == mapBlockIndex.end())
return 0; return 0;
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
@ -2250,7 +2250,7 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
// Find the block it claims to be in // Find the block it claims to be in
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end()) if (mi == mapBlockIndex.end())
return 0; return 0;
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;

Loading…
Cancel
Save