aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-10-23 01:16:26 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-10-23 01:43:33 +0200
commit4afc0b54112bd990217a4a6fea145574e5947f09 (patch)
tree00d3e4a096c933e6a24219fc936f86db94fffc29 /src/main.cpp
parentc2ed184f987fbb157880fce2f91ebc8514fd6e76 (diff)
Bugfix: actually use CCoinsViewMemPool
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 26cbab8483..be1e947ad3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -691,7 +691,13 @@ bool CTxMemPool::accept(CTransaction &tx, bool fCheckInputs,
if (fCheckInputs)
{
- CCoinsViewCache &view = *pcoinsTip;
+ CCoinsView dummy;
+ CCoinsViewCache view(dummy);
+
+ {
+ LOCK(cs);
+ CCoinsViewMemPool viewMemPool(*pcoinsTip, *this);
+ view.SetBackend(viewMemPool);
// do we already have it?
if (view.HaveCoins(hash))
@@ -711,6 +717,13 @@ bool CTxMemPool::accept(CTransaction &tx, bool fCheckInputs,
// are the actual inputs available?
if (!tx.HaveInputs(view))
return error("CTxMemPool::accept() : inputs already spent");
+
+ // Bring the best block into scope
+ view.GetBestBlock();
+
+ // we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
+ view.SetBackend(dummy);
+ }
// Check for non-standard pay-to-script-hash in inputs
if (!tx.AreInputsStandard(view) && !fTestNet)
@@ -741,7 +754,6 @@ bool CTxMemPool::accept(CTransaction &tx, bool fCheckInputs,
int64 nNow = GetTime();
{
- LOCK(cs);
// Use an exponentially decaying ~10-minute window:
dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime));
nLastTime = nNow;