aboutsummaryrefslogtreecommitdiff
path: root/src/rpcrawtransaction.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-07-06 16:33:34 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-10-20 23:08:57 +0200
commitae8bfd12daa802d20791e69d3477e799d2b99f45 (patch)
tree848867135da5954b7155ebe98c09db66d09d5737 /src/rpcrawtransaction.cpp
parent450cbb0944cd20a06ce806e6679a1f4c83c50db2 (diff)
downloadbitcoin-ae8bfd12daa802d20791e69d3477e799d2b99f45.tar.xz
Batch block connection during IBD
During the initial block download (or -loadblock), delay connection of new blocks a bit, and perform them in a single action. This reduces the load on the database engine, as subsequent blocks often update an earlier block's transaction already.
Diffstat (limited to 'src/rpcrawtransaction.cpp')
-rw-r--r--src/rpcrawtransaction.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index c62898316c..647384f333 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -339,9 +339,8 @@ Value signrawtransaction(const Array& params, bool fHelp)
CCoinsViewCache view(viewDummy);
{
LOCK(mempool.cs);
- CCoinsDB coinsdb("r");
- CCoinsViewDB viewDB(coinsdb);
- CCoinsViewMemPool viewMempool(viewDB, mempool);
+ CCoinsViewCache &viewChain = *pcoinsTip;
+ CCoinsViewMemPool viewMempool(viewChain, mempool);
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) {
@@ -350,7 +349,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
view.GetCoins(prevHash, coins); // this is certainly allowed to fail
}
- view.SetBackend(viewDummy); // switch back to avoid locking db/mempool too long
+ view.SetBackend(viewDummy); // switch back to avoid locking mempool for too long
}
// Add previous txouts given in the RPC call:
@@ -502,17 +501,13 @@ Value sendrawtransaction(const Array& params, bool fHelp)
uint256 hashTx = tx.GetHash();
bool fHave = false;
+ CCoinsViewCache &view = *pcoinsTip;
CCoins existingCoins;
{
- CCoinsDB coinsdb("r");
- {
- CCoinsViewDB coinsviewDB(coinsdb);
- CCoinsViewMemPool coinsview(coinsviewDB, mempool);
- fHave = coinsview.GetCoins(hashTx, existingCoins);
- }
+ fHave = view.GetCoins(hashTx, existingCoins);
if (!fHave) {
// push to local node
- if (!tx.AcceptToMemoryPool(coinsdb))
+ if (!tx.AcceptToMemoryPool())
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected");
}
}