Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove duplicate GetHash() in CBlockStore::CallbackCommitBlock.

  • Loading branch information...
commit d2a057967657cbbc59a3902cf87eb50f63df6a86 1 parent 80e3ac4
@TheBlueMatt authored
Showing with 9 additions and 9 deletions.
  1. +2 −2 src/blockstore.cpp
  2. +1 −1  src/blockstore.h
  3. +6 −6 src/main.cpp
View
4 src/blockstore.cpp
@@ -3,11 +3,11 @@
#include "net.h"
#include "main.h"
-void CBlockStore::CallbackCommitBlock(const CBlock &block)
+void CBlockStore::CallbackCommitBlock(const CBlock& block, const uint256& hash)
{
{
LOCK(cs_mapGetBlockIndexWaits);
- std::map<uint256, CSemaphore*>::iterator it = mapGetBlockIndexWaits.find(block.GetHash());
+ std::map<uint256, CSemaphore*>::iterator it = mapGetBlockIndexWaits.find(hash);
if (it != mapGetBlockIndexWaits.end() && it->second != NULL)
it->second->post_all();
}
View
2  src/blockstore.h
@@ -43,7 +43,7 @@ class CBlockStore
CBlockStoreSignalTable sigtable;
- void CallbackCommitBlock(const CBlock &block);
+ void CallbackCommitBlock(const CBlock& block, const uint256& hash);
void CallbackAskForBlocks(const uint256 hashEnd, const uint256 hashOriginator) { LOCK(sigtable.cs_sigAskForBlocks); sigtable.sigAskForBlocks(hashEnd, hashOriginator); }
View
12 src/main.cpp
@@ -1450,7 +1450,7 @@ bool CBlockStore::Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
}
// Connect longer branch
- list<CBlock> lCommitted;
+ list<pair<uint256, CBlock> > lCommitted;
BOOST_FOREACH(CBlockIndex* pindex, lConnect)
{
CBlock block;
@@ -1466,7 +1466,7 @@ bool CBlockStore::Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
}
// Queue memory transactions to delete
- lCommitted.push_back(block);
+ lCommitted.push_back(make_pair(*(pindex->phashBlock), block));
}
if (!txdb.WriteHashBestChain(pindexNew->GetBlockHash()))
return error("CBlockStore::Reorganize() : WriteHashBestChain failed");
@@ -1490,11 +1490,11 @@ bool CBlockStore::Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
mempool.accept(txdb, tx, false, NULL);
// Delete redundant memory transactions that are in the connected branch
- BOOST_FOREACH(CBlock& block, lCommitted)
+ for (list<pair<uint256, CBlock> >::iterator it = lCommitted.begin(); it != lCommitted.end(); it++)
{
- BOOST_FOREACH(CTransaction& tx, block.vtx)
+ BOOST_FOREACH(CTransaction& tx, it->second.vtx)
mempool.remove(tx);
- CallbackCommitBlock(block);
+ CallbackCommitBlock(it->second, it->first);
}
printf("REORGANIZE: done\n");
@@ -1526,7 +1526,7 @@ bool CBlockStore::SetBestChainInner(CBlock& block, uint256& hash, CTxDB& txdb, C
for (unsigned int i = 0; i < nTxes; i++)
mempool.remove(block.vtx[i], block.vMerkleTree[i]);
- CallbackCommitBlock(block);
+ CallbackCommitBlock(block, hash);
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.