aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-07-04 01:12:44 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-07-04 01:12:44 -0400
commitf77654a0e9424f13cad04f82c014abd78fbb5e38 (patch)
tree29b9dd80f03edde949c5a7abdf3a5913cd91e889
parent96929a5515bb0ffee67aab7283b5ae9fcc1641d5 (diff)
downloadbitcoin-f77654a0e9424f13cad04f82c014abd78fbb5e38.tar.xz
CTxMemPool: eliminate redundant lock, GetHash() call
::addUnchecked()'s only caller already takes the necessary lock, and has already calculated the TX's hash.
-rw-r--r--src/main.cpp6
-rw-r--r--src/main.h2
2 files changed, 3 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c1ca96bfd2..8e1deac4bb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -600,7 +600,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
printf("CTxMemPool::accept() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str());
remove(*ptxOld);
}
- addUnchecked(tx);
+ addUnchecked(hash, tx);
}
///// are we sure this is ok when loading transactions or restoring block txes
@@ -619,13 +619,11 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
return mempool.accept(txdb, *this, fCheckInputs, pfMissingInputs);
}
-bool CTxMemPool::addUnchecked(CTransaction &tx)
+bool CTxMemPool::addUnchecked(const uint256& hash, CTransaction &tx)
{
// Add to memory pool without checking anything. Don't call this directly,
// call CTxMemPool::accept to properly check the transaction first.
{
- LOCK(cs);
- uint256 hash = tx.GetHash();
mapTx[hash] = tx;
for (unsigned int i = 0; i < tx.vin.size(); i++)
mapNextTx[tx.vin[i].prevout] = CInPoint(&mapTx[hash], i);
diff --git a/src/main.h b/src/main.h
index bb094ad3c7..c841fdaf18 100644
--- a/src/main.h
+++ b/src/main.h
@@ -1602,7 +1602,7 @@ public:
bool accept(CTxDB& txdb, CTransaction &tx,
bool fCheckInputs, bool* pfMissingInputs);
- bool addUnchecked(CTransaction &tx);
+ bool addUnchecked(const uint256& hash, CTransaction &tx);
bool remove(CTransaction &tx);
void queryHashes(std::vector<uint256>& vtxid);